public bool InitSensorInterface(bool bCopyLibs, ref bool bNeedRestart)
    {
        bool bOneCopied = false, bAllCopied = true;
        bool bArchX64 = KinectInterop.Is64bitArchitecture();

        string sTargetPath = KinectInterop.GetTargetDllPath(".", bArchX64) + "/";

        //string sTargetPath = "./";

        if (!bCopyLibs)
        {
            // check if the native library is there
            string sTargetLib = sTargetPath + "UnityInterface2.dll";
            bNeedRestart = false;

            string sZipFileName = !bArchX64 ? "OpenNI2UnityInterface.x86.zip" : "OpenNI2UnityInterface.x64.zip";
            long   iTargetSize  = KinectInterop.GetUnzippedEntrySize(sZipFileName, "UnityInterface2.dll");

//			FileInfo targetFile = new FileInfo(sTargetLib);
//			return targetFile.Exists && targetFile.Length == iTargetSize;
            return(KinectInterop.IsFileExists(sTargetLib, iTargetSize));
        }

        // check openni directory and resources
        string sOpenNIPath = KinectInterop.GetEnvironmentVariable(!bArchX64 ? "OPENNI2_REDIST" : "OPENNI2_REDIST64");

        if (sOpenNIPath == String.Empty || !Directory.Exists(sOpenNIPath))
        {
            Debug.LogWarning("OpenNI2-folder not found (check OPENNI2_REDIST).");
            return(false);
        }

        sOpenNIPath = sOpenNIPath.Replace('\\', '/');
        if (sOpenNIPath.EndsWith("/"))
        {
            sOpenNIPath = sOpenNIPath.Substring(0, sOpenNIPath.Length - 1);
        }

        // check nite directory and resources
        string sNiTEPath = KinectInterop.GetEnvironmentVariable(!bArchX64 ? "NITE2_REDIST" : "NITE2_REDIST64");

        if (sNiTEPath == String.Empty || !Directory.Exists(sNiTEPath))
        {
            Debug.LogWarning("NiTE2-folder not found (check NITE2_REDIST).");
            return(false);
        }

        sNiTEPath = sNiTEPath.Replace('\\', '/');
        if (sNiTEPath.EndsWith("/"))
        {
            sNiTEPath = sNiTEPath.Substring(0, sNiTEPath.Length - 1);
        }

        string sUnityInterfaceLib = "UnityInterface2.dll";
        string sOpenNI2Lib        = "OpenNI2.dll";
        string sNiTE22Lib         = "NiTE2.dll";

#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
        sUnityInterfaceLib = "UnityInterface2.dll";
        sOpenNI2Lib        = "libOpenNI2.dylib";
        sNiTE22Lib         = "libNiTE2.dylib";
#endif

        KinectInterop.CopyFile(sOpenNIPath + "/" + sOpenNI2Lib, sTargetPath + sOpenNI2Lib, ref bOneCopied, ref bAllCopied);
        KinectInterop.CopyFile(sNiTEPath + "/" + sNiTE22Lib, sTargetPath + sNiTE22Lib, ref bOneCopied, ref bAllCopied);

        if (!bArchX64)
        {
            Dictionary <string, string> dictFilesToUnzip = new Dictionary <string, string>();

            dictFilesToUnzip[sUnityInterfaceLib] = sTargetPath + sUnityInterfaceLib;
            //dictFilesToUnzip["OpenNI2.dll"] = sTargetPath + "OpenNI2.dll";
            //dictFilesToUnzip["NiTE2.dll"] = sTargetPath + "NiTE2.dll";
            dictFilesToUnzip["OpenNI.ini"] = sTargetPath + "OpenNI.ini";
            dictFilesToUnzip["NiTE.ini"]   = sTargetPath + "NiTE.ini";

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
            dictFilesToUnzip["msvcp100.dll"] = sTargetPath + "msvcp100.dll";
            dictFilesToUnzip["msvcr100.dll"] = sTargetPath + "msvcr100.dll";
#endif

            KinectInterop.UnzipResourceFiles(dictFilesToUnzip, "OpenNI2UnityInterface.x86.zip", ref bOneCopied, ref bAllCopied);
        }
        else
        {
            Dictionary <string, string> dictFilesToUnzip = new Dictionary <string, string>();

            dictFilesToUnzip[sUnityInterfaceLib] = sTargetPath + sUnityInterfaceLib;
            //dictFilesToUnzip["OpenNI2.dll"] = sTargetPath + "OpenNI2.dll";
            //dictFilesToUnzip["NiTE2.dll"] = sTargetPath + "NiTE2.dll";
            dictFilesToUnzip["OpenNI.ini"] = sTargetPath + "OpenNI.ini";
            dictFilesToUnzip["NiTE.ini"]   = sTargetPath + "NiTE.ini";

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
            dictFilesToUnzip["msvcp100.dll"] = sTargetPath + "msvcp100.dll";
            dictFilesToUnzip["msvcr100.dll"] = sTargetPath + "msvcr100.dll";
#endif

            KinectInterop.UnzipResourceFiles(dictFilesToUnzip, "OpenNI2UnityInterface.x64.zip", ref bOneCopied, ref bAllCopied);
        }

        if (File.Exists(sTargetPath + "OpenNI.ini"))
        {
            string sFileContent = File.ReadAllText(sTargetPath + "OpenNI.ini");
            sFileContent = sFileContent.Replace("%OPENNI_REDIST_DIR%", sOpenNIPath);
            File.WriteAllText(sTargetPath + "OpenNI.ini", sFileContent);
        }

        if (File.Exists(sTargetPath + "NiTE.ini"))
        {
            string sFileContent = File.ReadAllText(sTargetPath + "NiTE.ini");
            sFileContent = sFileContent.Replace("%NITE_REDIST_DIR%", sNiTEPath);
            File.WriteAllText(sTargetPath + "NiTE.ini", sFileContent);
        }

        bNeedRestart = (bOneCopied && bAllCopied);

        return(true);
    }