KinectManager.Awake C# (CSharp) Method

Awake() public method

public Awake ( ) : void
return void
    void Awake()
    {
        // ensure that dll and config are in place
        string srcDllPath = Application.dataPath + "/Plugins/UnityInterface.dll";
        bool bDllCopied = false;

        if(!File.Exists("UnityInterface.dll") && File.Exists(srcDllPath))
        {
            Debug.Log("Copying UnityInterface.dll ...");
            File.Copy(srcDllPath, "UnityInterface.dll");

            bDllCopied = File.Exists("UnityInterface.dll");
        }

        if(!File.Exists("OpenNI.xml"))
        {
            Debug.Log("Copying OpenNI.xml ...");
            TextAsset textRes = Resources.Load("OpenNI", typeof(TextAsset)) as TextAsset;

            if(textRes != null)
            {
                File.WriteAllText("OpenNI.xml", textRes.text);
            }
        }

        if(bDllCopied)
        {
            // reload the same level
            Application.LoadLevel(Application.loadedLevel);
        }
    }

Usage Example

Example #1
0
 /******************************
 *  description
 *       最初、
 *               Application.LoadLevel("KinectAvatarsDemo1");
 *       によって、sceneをReloadしようと思ったが、OSCController側がうまくResetできず、Reload後に挙動がおかしくなってしまった。
 *
 *       そこで、今回は、KinectのみResetさせることとした.
 ******************************/
 void RestartKinect()
 {
     KinectManager.Awake();
     enabled = true;
 }