Common functions for mobile phone operation in Unity

Source: Internet
Author: User

Recently in testing a small demo, using a lot of phone features. Posted here for later reference

Note: When packaging a release, plugins must import the following DLL files, otherwise the database <i18n,i18n cannot be connected after build. West,system.data,mysql.data>

1, the operation of mobile phone vibration; handheld.vibrate (); Judge yourself by adding conditions before shaking

2, input box call system input: Each plug-in TextBox control comes with this function, when practical, automatically call the phone input method.

3. Exit Application < Incomplete >:if (Input.getkeydown (keycode.escape) | | Input.getkeydown (Keycode.home))

{

OpenFileDialog ofd = new OpenFileDialog ();

if (OFD. ShowDialog () ==dialogresult.ok)

{

Exit program

UnityEngine.Application.Quit ();

}

}

4. Call Phone camera

IEnumerator opencamera (int whichone)
{
Yield return application.requestuserauthorization (USERAUTHORIZATION.WEBCAM);
if (Application.hasuserauthorization (Userauthorization.webcam))
{
Call the hardware to get the phone camera regardless of autofocus
webcamdevice[] devices = webcamtexture.devices;
if (Devices. Length <= Whichone)
{
Cameraname = Devices[0].name;
}
Else
{
Cameraname = Devices[whichone].name;
}
Cameratexture = new Webcamtexture (Cameraname, Screen.height, Screen.width, 15);
Cameratexture.play (); In Ongui, define a sprite to receive the image. Sprite = cameratexture;
Isplay = true; Similarly, if the video is taken in real-time image can also be achieved? Not verified
}

}

5, Unity3d connection MySQL, SQL Server, Sqllite database

Note: SQL Server, Sqllite needs to be in the Unity installation file in the system. Copy the Data.dll and System.sqllite.dll files to the plugins directory. The rest of the operation is consistent with ADO

    When you operate MySQL, you need to download a MySQL online. Data.dll file. Recommended version 5.5, preferably 5.0-5.2, the version is too high, unity does not recognize the load. The remaining operations are as above.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.