public static VirtualGoodCategory[] GetVirtualGoodCategoryArray(VirtualGoodCategoryArray virtualGoodCategoryArray)
        {
            VirtualGoodCategory[] virtualGoodCategoryInner = new VirtualGoodCategory[virtualGoodCategoryArray.ArraySize];
            AndroidJavaObject[]   bigArray = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(virtualGoodCategoryArray.Array);

            int count = 0;

            for (int i = 0; i < bigArray.Length; i++)
            {
                AndroidJavaObject   tempJavaObject = bigArray[i];
                AndroidJavaObject[] InnerArray     = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(tempJavaObject.GetRawObject());

                for (int j = 0; j < InnerArray.Length; j++)
                {
                    AndroidJavaObject tempObj = InnerArray[j];
                    virtualGoodCategoryInner[count] = new VirtualGoodCategory(tempObj.GetRawObject(), tempObj);
                    count++;
                }
            }
            return(virtualGoodCategoryInner);
        }
Example #2
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

#if !UNITY_ANDROID || UNITY_EDITOR
        var netVersion = new System.Version(Ovr.Hmd.OVR_VERSION_STRING);
        var ovrVersion = new System.Version(Ovr.Hmd.GetVersionString());
        if (netVersion > ovrVersion)
        {
            Debug.LogWarning("Using an older version of LibOVR.");
        }
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
        Application.targetFrameRate = 60;
        // don't allow the app to run in the background
        Application.runInBackground = false;
        // Disable screen dimming
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        if (!androidJavaInit)
        {
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            activity            = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            javaVrActivityClass = new AndroidJavaClass("com.oculusvr.vrlib.VrActivity");
            // Prepare for the RenderThreadInit()
            SetInitVariables(activity.GetRawObject(), javaVrActivityClass.GetRawClass());

            androidJavaInit = true;
        }

        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();
        // This will trigger the init on the render thread
        InitRenderThread();
#else
        SetEditorPlay(Application.isEditor);
#endif

        display = new OVRDisplay();
        tracker = new OVRTracker();

        // Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps().
        if (timeWarp)
        {
            bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9");
            QualitySettings.vSyncCount = useUnityVSync ? 1 : 0;
        }
    }
    void Awake()
    {
        goodName = PlayerPrefs.GetString("goodName", "");
        money    = PlayerPrefs.GetInt("money", 0);
        string itemCode = PlayerPrefs.GetString("goodid", "");
        string remain   = PlayerPrefs.GetString("remain", "");

        Debug.Log("itemCode=" + itemCode + " remain=" + remain);
        bLogined = PlayerPrefs.GetInt("login", 0) == 0 ? false : true;
        keyName  = PlayerPrefs.GetString("keyName", "");
        if (goodName.Equals("") || money == 0)
        {
            desc    = "";
            paytype = "";
        }
        else
        {
            desc    = PlayerPrefs.GetString("desc", "");
            paytype = PlayerPrefs.GetString("paytype", "");
        }
        if (keyName.Equals(""))
        {
            setDataType = "";
        }
        else
        {
            setDataType = PlayerPrefs.GetString("setDataType", "");
        }


        PlayerPrefs.DeleteAll();

        if (Application.platform == RuntimePlatform.Android)
        {
            using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                using (AndroidJavaObject curActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity")) {
                    setLoginListener(curActivity.GetRawObject(), "Main Camera", "LoginResult");
                    Debug.Log("Awake setDataType:" + setDataType);
                    if (bLogined == true)
                    {
                        Debug.Log("Alogin result = login success");
                        str = "login result = login success";
                        if (paytype.Equals(PAYTYPE_PAY))
                        {
                            str = "PAYTYPE_PAY";
                            pay(curActivity.GetRawObject(), "Main Camera", money, goodName, 1, desc, CP_PAY_SYNC_URL, "PayResult");
                        }
                        else if (paytype.Equals(PAYTYPE_CHARGE))
                        {
                            str = "PAYTYPE_CHARGE";
                            charge(curActivity.GetRawObject(), "Main Camera", goodName, money, 1, desc, CP_PAY_SYNC_URL, "PayResult");
                        }
                        else if (paytype.Equals(PAYTYPE_PAY_EXTEND))
                        {
                            str = "PAYTYPE_PAY_EXTEND";
                            payExtend(curActivity.GetRawObject(), "Main Camera", money, goodName, itemCode, remain,
                                      1, desc, CP_PAY_SYNC_URL, "PayResult");
                        }
                        else if (setDataType.Equals(PAYTYPE_ROLE))
                        {
                            str = "PAYTYPE_ROLE";
                            SFJSONObject gameinfo = new SFJSONObject();
                            gameinfo.put("roleId", "1");                                       //当前登录的玩家角色ID,必须为数字
                            gameinfo.put("roleName", "猎人");                                    //当前登录的玩家角色名,不能为空,不能为null
                            gameinfo.put("roleLevel", "100");                                  //当前登录的玩家角色等级,必须为数字,且不能为0,若无,传入1
                            gameinfo.put("zoneId", "1");                                       //当前登录的游戏区服ID,必须为数字,且不能为0,若无,传入1
                            gameinfo.put("zoneName", "阿狸一区");                                  //当前登录的游戏区服名称,不能为空,不能为null
                            gameinfo.put("balance", "0");                                      //用户游戏币余额,必须为数字,若无,传入0
                            gameinfo.put("vip", "1");                                          //当前用户VIP等级,必须为数字,若无,传入1
                            gameinfo.put("partyName", "无帮派");                                  //当前角色所属帮派,不能为空,不能为null,若无,传入“无帮派”
                            gameinfo.put("roleCTime", "21322222");                             //单位为秒,创建角色的时间
                            gameinfo.put("roleLevelMTime", "54456556");                        //单位为秒,角色等级变化时间,如果没有就传-1
                            setData(curActivity.GetRawObject(), keyName, gameinfo.toString()); //创建新角色时调用,必接接口
                        }
                    }
                    Debug.Log("user had payed str:" + str);
                }
            }
        }
        isPause = false;

        isFocus = false;
    }
Example #4
0
        public static Chat[] GetChatArray(ChatArray chatArray)
        {
            Chat[] chatInner             = new Chat[chatArray.ArraySize];
            AndroidJavaObject[] bigArray = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(chatArray.Array);

            int count = 0;

            for (int i = 0; i < bigArray.Length; i++)
            {
                AndroidJavaObject   tempJavaObject = bigArray[i];
                AndroidJavaObject[] InnerArray     = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(tempJavaObject.GetRawObject());

                for (int j = 0; j < InnerArray.Length; j++)
                {
                    AndroidJavaObject tempObj = InnerArray[j];
                    chatInner[count] = new Chat(tempObj.GetRawObject(), tempObj);
                    count++;
                }
            }
            return(chatInner);
        }
Example #5
0
    IEnumerator UpdateTexture(AndroidJavaObject webview)
    {
        while (true)
        {
            yield return(new WaitForEndOfFrame());

            var commandBuffer = new CommandBuffer();
            commandBuffer.IssuePluginEventAndData(get_update_texture_func(), texture.GetNativeTexturePtr().ToInt32(), webview.GetRawObject());
            Graphics.ExecuteCommandBuffer(commandBuffer);
        }
    }
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

        System.Version netVersion = OVRPlugin.wrapperVersion;
        System.Version ovrVersion = OVRPlugin.version;

        Debug.Log("Unity v" + Application.unityVersion + ", " +
                  "Oculus Integration v" + netVersion + ", " +
                  "OVRPlugin v" + ovrVersion + ".");

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;

        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if !UNITY_ANDROID || UNITY_EDITOR
        if (OVRUnityVersionChecker.hasBuiltInVR)
        {
            Debug.LogWarning("The Oculus Unity Legacy Integration is only supported in Unity 4.x releases. For Unity 5.x, please migrate to the Oculus Utilities for Unity package and use Unity's built-in VR support (available in Unity 5.1 and later).");
            isVRPresent = false;
        }
        else if (!ovrIsInitialized)
        {
            //HACK: For some reason, Unity doesn't call UnitySetGraphicsDevice until we make the first P/Invoke call.
            OVRPluginEvent.eventBase = OVRPluginEvent.eventBase;

#if !UNITY_ANDROID || UNITY_EDITOR
            //Handle all log messages
            OVR_FlushLog(OnLogMessage);
#endif

            // If unable to load the Oculus Runtime.
            if (!OVRPlugin.initialized)
            {
                bool isBadWinRenderer =
                    ((Application.platform == RuntimePlatform.WindowsEditor ||
                      Application.platform == RuntimePlatform.WindowsPlayer) &&
                     !SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"));

                if (isBadWinRenderer)
                {
                    Debug.LogWarning("Only D3D11 is supported on Windows.");
                }
                else
                {
                    Debug.LogWarning("Runtime is not present or no Rift attached. Running without VR.");
                }

                // Runtime is not installed if ovr_Initialize() fails.
                isVRPresent = false;
                // Go monoscopic in response.
                monoscopic = true;
            }
            else
            {
                OVRPluginEvent.Issue(RenderEventType.InitRenderThread);

                isVRPresent = true;

#if UNITY_EDITOR
                if (!OVRUnityVersionChecker.hasEditorVRSupport)
                {
                    // Only allow VR in standalones.
                    isVRPresent = false;
                    Debug.LogWarning("VR rendering is not supported in the editor. Please update to 4.6.7p4 or build a stand-alone player.");
                }
#endif
                if (netVersion.Major > ovrVersion.Major || netVersion.Major == ovrVersion.Major && netVersion.Minor > ovrVersion.Minor)
                {
                    isVRPresent = false;
                    Debug.LogWarning("Version check failed. Please make sure you are using OVRPlugin " +
                                     Ovr.Hmd.OVR_VERSION_STRING + " or newer.");
                }

                OVRPlugin.queueAheadFraction = 0f;

                ovrIsInitialized = true;
            }
        }

        SetEditorPlay(Application.isEditor);
#else // UNITY_ANDROID && !UNITY_EDITOR: Start of Android init.
        // Android integration does not dynamically load its runtime.
        isVRPresent = true;

        // log the unity version
        Debug.Log("Unity Version: " + Application.unityVersion);

        // don't allow the application to run if orientation is not landscape left.
        if (Screen.orientation != ScreenOrientation.LandscapeLeft)
        {
            Debug.LogError("********************************************************************************\n");
            Debug.LogError("***** Default screen orientation must be set to landscape left for VR.\n" +
                           "***** Stopping application.\n");
            Debug.LogError("********************************************************************************\n");

            Debug.Break();
            Application.Quit();
        }

        // don't enable gyro, it is not used and triggers expensive display calls
        if (Input.gyro.enabled)
        {
            Debug.LogError("*** Auto-disabling Gyroscope ***");
            Input.gyro.enabled = false;
        }

        // NOTE: On Adreno Lollipop, it is an error to have antiAliasing set on the
        // main window surface with front buffer rendering enabled. The view will
        // render black.
        // On Adreno KitKat, some tiling control modes will cause the view to render
        // black.
        if (QualitySettings.antiAliasing > 1)
        {
            Debug.LogError("*** Antialiasing must be disabled for Gear VR ***");
        }

        // we sync in the TimeWarp, so we don't want unity
        // syncing elsewhere
        QualitySettings.vSyncCount = 0;

        // try to render at 60fps
        Application.targetFrameRate = 60;
        // don't allow the app to run in the background
        Application.runInBackground = false;
        // Disable screen dimming
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        if (!androidJavaInit)
        {
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            activity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            // Prepare for the RenderThreadInit()
            SetInitVariables(activity.GetRawObject(), System.IntPtr.Zero);

#if USE_ENTITLEMENT_CHECK
            AndroidJavaObject entitlementChecker = new AndroidJavaObject("com.oculus.svclib.OVREntitlementChecker");
            entitlementChecker.CallStatic("doAutomatedCheck", activity);
#else
            Debug.Log("Inhibiting Entitlement Check!");
#endif

            androidJavaInit = true;
        }

        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();

        InitVolumeController();

        // set an event delegate like this if you wish to handle events like "reorient".
        //SetVrApiEventDelegate( VrApiEventDefaultDelegate );
#endif // End of android init.

        prevEyeTextureAntiAliasing = OVRManager.instance.eyeTextureAntiAliasing;
        prevEyeTextureDepth        = OVRManager.instance.eyeTextureDepth;
        prevEyeTextureFormat       = OVRManager.instance.eyeTextureFormat;
        prevNativeTextureScale     = OVRManager.instance.nativeTextureScale;
        prevVirtualTextureScale    = OVRManager.instance.virtualTextureScale;
        prevMonoscopic             = OVRManager.instance.monoscopic;
        prevHdr = OVRManager.instance.hdr;

        if (tracker == null)
        {
            tracker = new OVRTracker();
        }

        if (display == null)
        {
            display = new OVRDisplay();
        }
        else
        {
            wasRecreated = true;
        }

        if (input == null)
        {
            input = new OVRInput();
        }

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }

#if !UNITY_ANDROID || UNITY_EDITOR
        // Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps().
        if (timeWarp)
        {
            bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9");
            QualitySettings.vSyncCount      = useUnityVSync ? 1 : 0;
            QualitySettings.maxQueuedFrames = 0;
        }
#endif

#if UNITY_STANDALONE_WIN
        if (!OVRUnityVersionChecker.hasD3D9ExclusiveModeSupport && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9"))
        {
            MessageBox(0, "Direct3D 9 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }

        if (!OVRUnityVersionChecker.hasD3D11ExclusiveModeSupport && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"))
        {
            MessageBox(0, "Direct3D 11 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }
#endif
    }
Example #7
0
        public static IEnumerator GetArrayWithQuerySyncIEnumerator(Query query, QueryKind queryKind)
        {
            if (javaUnityApplicasaChat == null)
            {
                javaUnityApplicasaChat = new AndroidJavaClass("com.applicasaunity.Unity.ApplicasaChat");
            }

            AndroidJavaObject[] bigArray = javaUnityApplicasaChat.CallStatic <AndroidJavaObject[]>("ApplicasaChatGetArrayWithQuerySync", query.innerQueryJavaObject, (int)queryKind);

            Chat[] chatInner = null;;
            for (int i = 0; i < bigArray.Length; i++)
            {
                AndroidJavaObject tempJavaObject = bigArray[i];

                AndroidJavaObject[] InnerArray = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(tempJavaObject.GetRawObject());
                Chat[] chattemp = new Chat[InnerArray.Length];
                for (int j = 0; j < InnerArray.Length; j++)
                {
                    AndroidJavaObject tempObj = InnerArray[j];
                    chattemp[j] = new Chat(tempObj.GetRawObject(), tempObj);
                }
                if (chatInner == null)
                {
                    chatInner = chattemp;
                }
                else
                {
                    Chat[] firstOne = chatInner;
                    chatInner = new Chat[firstOne.Length + chattemp.Length];
                    firstOne.CopyTo(chatInner, 0);
                    chattemp.CopyTo(chatInner, firstOne.Length);
                }
                yield return(new WaitForSeconds(0.2f));
            }
            finalChat = chatInner;
        }
Example #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PikkartAR.RecognitionManager"/> class.
        /// </summary>
        /// <param name="width">Frame Width.</param>
        /// <param name="height">Frame Height.</param>
        /// <param name="localRecognitionService">Object that implements the communication interface.</param>
        public RecognitionManager(IMarkerObjectListener markerObjectListener)
        {
            _markerObjectListener = markerObjectListener;
            _recognitionRunning   = false;

#if UNITY_ANDROID && !UNITY_EDITOR
            AndroidJavaClass  jc           = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject context      = jc.GetStatic <AndroidJavaObject>("currentActivity");
            AndroidJavaObject assetManager = context.Call <AndroidJavaObject>("getAssets");
#endif
            _deviceId = RecognitionManager.GetDeviceId();

            // Native Recognition Service Initialization
            if (!_nativeWrapperInitialized)
            {
                int res = PikkartARCore.InitRecognition(
#if UNITY_ANDROID && !UNITY_EDITOR
                    assetManager.GetRawObject(),
#endif
                    _localMarkerNotFoundEventMinIntervalMillisecs,
#if UNITY_EDITOR_OSX || (UNITY_IOS && !UNITY_EDITOR_WIN)
                    GetAppDataPath(),
#else
                    new StringBuilder(GetAppDataPath()),
#endif
#if UNITY_EDITOR_WIN
                    new StringBuilder(Application.streamingAssetsPath),
    #if UNITY_5_6_OR_NEWER
                    new StringBuilder(PlayerSettings.applicationIdentifier),
    #else
                    new StringBuilder(PlayerSettings.bundleIdentifier),
    #endif
#elif UNITY_EDITOR_OSX
                    Application.streamingAssetsPath,
    #if UNITY_5_6_OR_NEWER
                    PlayerSettings.applicationIdentifier,
    #else
                    PlayerSettings.bundleIdentifier,
    #endif
#endif
                    Constants.PROCESS_WIDTH,
                    Constants.PROCESS_HEIGHT,
                    ScreenUtilities.GetScreenInches(),
                    Constants.CAMERA_REQUESTED_WIDTH,
                    Constants.CAMERA_REQUESTED_HEIGHT,
                    false);

                if (res > 0)
                {
                    _licenceChecked = true;
                }
                else
                {
                    _licenceChecked = false;
                }
                if (res == 0)
                {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
                    if (MonoBehaviour.FindObjectOfType <LicenseMessage>() != null)
                    {
                        MonoBehaviour.FindObjectOfType <LicenseMessage>().gameObject.SetActive(true);
                    }
                    if (MonoBehaviour.FindObjectOfType <TrialMessage>() != null)
                    {
                        MonoBehaviour.FindObjectOfType <TrialMessage>().gameObject.SetActive(false);
                    }
#elif UNITY_EDITOR
                    if (MonoBehaviour.FindObjectOfType <TrialMessage>() != null)
                    {
                        MonoBehaviour.FindObjectOfType <TrialMessage>().gameObject.SetActive(false);
                    }
                    if (MonoBehaviour.FindObjectOfType <LicenseMessage>() != null)
                    {
                        MonoBehaviour.FindObjectOfType <LicenseMessage>().gameObject.SetActive(false);
                    }
                    if (EditorUtility.DisplayDialog("Licence error!",
                                                    "You cannot use our sdk without a valid licence UNLESS you are in a trial!\n" +
                                                    "Please register to developer.pikkart.com to obtain your own licence or set your application identifier to 'com.pikkart.trial' to evaluate our SDK.", "Ok"))
                    {
                        EditorApplication.isPlaying = false;
                    }
#endif
                }
                else if (res == 1)
                {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
                    if (MonoBehaviour.FindObjectOfType <TrialMessage>())
                    {
                        MonoBehaviour.FindObjectOfType <TrialMessage>().gameObject.SetActive(true);
                    }
                    if (MonoBehaviour.FindObjectOfType <LicenseMessage>())
                    {
                        MonoBehaviour.FindObjectOfType <LicenseMessage>().gameObject.SetActive(false);
                    }
#elif UNITY_EDITOR
                    if (MonoBehaviour.FindObjectOfType <TrialMessage>())
                    {
                        MonoBehaviour.FindObjectOfType <TrialMessage>().gameObject.SetActive(false);
                    }
                    if (MonoBehaviour.FindObjectOfType <LicenseMessage>())
                    {
                        MonoBehaviour.FindObjectOfType <LicenseMessage>().gameObject.SetActive(false);
                    }
                    if (EditorUtility.DisplayDialog("No valid license",
                                                    "No valid license or running as com.pikkart.trial, press Ok to run in trial mode", "Ok"))
                    {
                        EditorApplication.isPlaying = true;
                    }
#endif
                }
                else
                {
                    if (MonoBehaviour.FindObjectOfType <TrialMessage>())
                    {
                        MonoBehaviour.FindObjectOfType <TrialMessage>().gameObject.SetActive(false);
                    }
                    if (MonoBehaviour.FindObjectOfType <LicenseMessage>())
                    {
                        MonoBehaviour.FindObjectOfType <LicenseMessage>().gameObject.SetActive(false);
                    }
                }

                PikkartARCore.SetProjectionMatrix(Constants.CAM_LARGE_FOV, Constants.CAM_SMALL_FOV);

                _nativeWrapperInitialized = true;
                //_nativeArray = Marshal.AllocHGlobal(Constants.BASE_RES_WIDTH * Constants.BASE_RES_HEIGHT * 3);
            }
            else
            {
                if (MonoBehaviour.FindObjectOfType <TrialMessage>())
                {
                    MonoBehaviour.FindObjectOfType <TrialMessage>().gameObject.SetActive(false);
                }
                if (MonoBehaviour.FindObjectOfType <LicenseMessage>())
                {
                    MonoBehaviour.FindObjectOfType <LicenseMessage>().gameObject.SetActive(false);
                }
            }


            _dataProvider = new RecognitionDataProvider(null, this, _deviceId);
        }
Example #9
0
        public bool Create()
        {
#if UNITY_ANDROID && !UNITY_EDITOR
            NativeApi.NRRenderingCreate(ref m_RenderingHandle);
            AndroidJavaClass  unityPlayer      = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject activity         = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            AndroidJavaObject unityPlayerObj   = activity.Get <AndroidJavaObject>("mUnityPlayer");
            AndroidJavaObject surfaceViewObj   = unityPlayerObj.Call <AndroidJavaObject>("getChildAt", 0);
            AndroidJavaObject surfaceHolderObj = surfaceViewObj.Call <AndroidJavaObject>("getHolder");
            AndroidJavaObject surfaceObj       = surfaceHolderObj.Call <AndroidJavaObject>("getSurface");
            var result = NativeApi.NRRenderingInitSetAndroidSurface(m_RenderingHandle, surfaceObj.GetRawObject());

            return(result == NativeResult.Success);
#else
            return(true);
#endif
        }
        internal AndroidNativeControllerProvider()
        {
            // Debug.Log("Initializing Daydream controller API.");

            int options = gvr_controller_get_default_options();

            options |= GVR_CONTROLLER_ENABLE_ACCEL;
            options |= GVR_CONTROLLER_ENABLE_GYRO;
            options |= GVR_CONTROLLER_ENABLE_POSITION;

            statePtr = gvr_controller_state_create();
            // Get a hold of the activity, context and class loader.
            AndroidJavaObject activity = GvrActivityHelper.GetActivity();

            if (activity == null)
            {
                error        = true;
                errorDetails = "Failed to get Activity from Unity Player.";
                return;
            }
            androidContext = GvrActivityHelper.GetApplicationContext(activity);
            if (androidContext == null)
            {
                error        = true;
                errorDetails = "Failed to get Android application context from Activity.";
                return;
            }
            classLoader = GetClassLoaderFromActivity(activity);
            if (classLoader == null)
            {
                error        = true;
                errorDetails = "Failed to get class loader from Activity.";
                return;
            }

            // Use IntPtr instead of GetRawObject() so that Unity can shut down gracefully on
            // Application.Quit(). Note that GetRawObject() is not pinned by the receiver so it's not
            // cleaned up appropriately on shutdown, which is a known bug in Unity.
            IntPtr androidContextPtr = AndroidJNI.NewLocalRef(androidContext.GetRawObject());
            IntPtr classLoaderPtr    = AndroidJNI.NewLocalRef(classLoader.GetRawObject());

            Debug.Log("Creating and initializing GVR API controller object.");
            api = gvr_controller_create_and_init_android(IntPtr.Zero, androidContextPtr, classLoaderPtr,
                                                         options, IntPtr.Zero);
            AndroidJNI.DeleteLocalRef(androidContextPtr);
            AndroidJNI.DeleteLocalRef(classLoaderPtr);
            if (IntPtr.Zero == api)
            {
                Debug.LogError("Error creating/initializing Daydream controller API.");
                error        = true;
                errorDetails = "Failed to initialize Daydream controller API.";
                return;
            }

            try {
                gvr_controller_state_get_battery_charging(statePtr);
                gvr_controller_state_get_battery_level(statePtr);
                hasBatteryMethods = true;
            } catch (EntryPointNotFoundException) {
                // Older VrCore version. Does not support battery indicator.
                // Note that controller API is not dynamically loaded as of June 2017 (b/35662043),
                // so we'll need to support this case indefinitely...
            }

            // Debug.Log("GVR API successfully initialized. Now resuming it.");
            gvr_controller_resume(api);
            // Debug.Log("GVR API resumed.");
        }
Example #11
0
 public static bool IsJavaNull(this AndroidJavaObject ajo)
 {
     return(ajo.GetRawObject().ToInt32() == 0);
 }
Example #12
0
        public static Colors[] GetArrayWithQuerySync(Query query, QueryKind queryKind)
        {
            if (javaUnityApplicasaColors == null)
            {
                javaUnityApplicasaColors = new AndroidJavaClass("com.applicasaunity.Unity.ApplicasaColors");
            }

            AndroidJavaObject[] bigArray = javaUnityApplicasaColors.CallStatic <AndroidJavaObject[]>("ApplicasaColorsGetArrayWithQuerySync", query.innerQueryJavaObject, (int)queryKind);

            Colors[] colorsInner = null;
            for (int i = 0; i < bigArray.Length; i++)
            {
                AndroidJavaObject tempJavaObject = bigArray[i];

                AndroidJavaObject[] InnerArray = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(tempJavaObject.GetRawObject());
                Colors[]            colorstemp = new Colors[InnerArray.Length];
                for (int j = 0; j < InnerArray.Length; j++)
                {
                    AndroidJavaObject tempObj = InnerArray[j];
                    colorstemp[j] = new Colors(tempObj.GetRawObject(), tempObj);
                }
                if (colorsInner == null)
                {
                    colorsInner = colorstemp;
                }
                else
                {
                    Colors[] firstOne = colorsInner;
                    colorsInner = new Colors[firstOne.Length + colorstemp.Length];
                    firstOne.CopyTo(colorsInner, 0);
                    colorstemp.CopyTo(colorsInner, firstOne.Length);
                }
            }
            return(colorsInner);
        }
    /**
     * <summary>プラグインの初期化(手動初期化用)</summary>
     * \par 説明:
     * プラグインの初期化を行います。<br/>
     * デフォルトでは本関数はAwake関数内で自動的に呼び出されるので、アプリケーションが直接呼び出す必要はありません。<br/>
     * <br/>
     * 初期化パラメタをスクリプトから動的に変更して初期化を行いたい場合、本関数を使用してください。<br/>
     * \par 注意:
     * 本関数を使用する場合は、 自動初期化を無効にするため、 ::CriWareInitializer::dontInitializeOnAwake プロパティをインスペクタ上でチェックしてください。<br/>
     * また、本関数を呼び出すタイミングは全てのプラグインAPIよりも前に呼び出す必要があります。Script Execution Orderが高いスクリプト上で行ってください。
     *
     */
    public void Initialize()
    {
        /* 初期化カウンタの更新 */
        initializationCount++;
        if (initializationCount != 1)
        {
            /* CriWareInitializer自身による多重初期化は許可しない */
            GameObject.Destroy(this);
            return;
        }

        /* CRI File Systemライブラリの初期化 */
        if (initializesFileSystem)
        {
            CriFsPlugin.SetConfigParameters(
                fileSystemConfig.numberOfLoaders,
                fileSystemConfig.numberOfBinders,
                fileSystemConfig.numberOfInstallers,
                (fileSystemConfig.installBufferSize * 1024),
                fileSystemConfig.maxPath,
                fileSystemConfig.minimizeFileDescriptorUsage
                );
            {
                /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */
                if (fileSystemConfig.androidDeviceReadBitrate == 0)
                {
                    fileSystemConfig.androidDeviceReadBitrate = CriFsConfig.defaultAndroidDeviceReadBitrate;
                }
            }
            CriFsPlugin.SetConfigAdditionalParameters_ANDROID(fileSystemConfig.androidDeviceReadBitrate);
            CriFsPlugin.InitializeLibrary();
            if (fileSystemConfig.userAgentString.Length != 0)
            {
                CriFsUtility.SetUserAgentString(fileSystemConfig.userAgentString);
            }
        }

        /* CRI Atomライブラリの初期化 */
        if (initializesAtom)
        {
            /* 初期化処理の実行 */
            CriAtomPlugin.SetConfigParameters(
                (int)Math.Max(atomConfig.maxVirtualVoices, CriAtomPlugin.GetRequiredMaxVirtualVoices(atomConfig)),
                atomConfig.maxVoiceLimitGroups,
                atomConfig.maxCategories,
                atomConfig.standardVoicePoolConfig.memoryVoices,
                atomConfig.standardVoicePoolConfig.streamingVoices,
                atomConfig.hcaMxVoicePoolConfig.memoryVoices,
                atomConfig.hcaMxVoicePoolConfig.streamingVoices,
                atomConfig.outputSamplingRate,
                atomConfig.asrOutputChannels,
                atomConfig.usesInGamePreview,
                atomConfig.serverFrequency,
                atomConfig.maxParameterBlocks,
                atomConfig.categoriesPerPlayback,
                atomConfig.maxBuses,
                false);

            CriAtomPlugin.SetConfigAdditionalParameters_PC(
                atomConfig.pcBufferingTime
                );

            CriAtomPlugin.SetConfigAdditionalParameters_IOS(
                (uint)Math.Max(atomConfig.iosBufferingTime, 16),
                atomConfig.iosOverrideIPodMusic
                );
            /* Android 固有の初期化パラメータを登録 */
            {
                /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */
                if (atomConfig.androidBufferingTime == 0)
                {
                    atomConfig.androidBufferingTime = (int)(4 * 1000.0 / atomConfig.serverFrequency);
                }
                if (atomConfig.androidStartBufferingTime == 0)
                {
                    atomConfig.androidStartBufferingTime = (int)(3 * 1000.0 / atomConfig.serverFrequency);
                }
                IntPtr android_context = IntPtr.Zero;
#if !UNITY_EDITOR && UNITY_ANDROID
                if (atomConfig.androidUsesAndroidFastMixer)
                {
                    AndroidJavaClass  jc       = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
                    AndroidJavaObject activity = jc.GetStatic <AndroidJavaObject>("currentActivity");
                    android_context = activity.GetRawObject();
                }
#endif
                CriAtomPlugin.SetConfigAdditionalParameters_ANDROID(
                    atomConfig.androidLowLatencyStandardVoicePoolConfig.memoryVoices,
                    atomConfig.androidLowLatencyStandardVoicePoolConfig.streamingVoices,
                    atomConfig.androidBufferingTime,
                    atomConfig.androidStartBufferingTime,
                    android_context);
            }
            CriAtomPlugin.InitializeLibrary();

            if (atomConfig.useRandomSeedWithTime == true)
            {
                /* 時刻を乱数種に設定 */
                CriAtomEx.SetRandomSeed((uint)System.DateTime.Now.Ticks);
            }

            /* ACFファイル指定時は登録 */
            if (atomConfig.acfFileName.Length != 0)
            {
                string acfPath = atomConfig.acfFileName;
                if (CriWare.IsStreamingAssetsPath(acfPath))
                {
                    acfPath = Path.Combine(CriWare.streamingAssetsPath, acfPath);
                }

                CriAtomEx.RegisterAcf(null, acfPath);
            }
        }

        /* CRI Manaライブラリの初期化 */
        if (initializesMana)
        {
            CriManaPlugin.SetConfigParameters(manaConfig.graphicsMultiThreaded, manaConfig.numberOfDecoders, manaConfig.numberOfMaxEntries);
            CriManaPlugin.InitializeLibrary();
        }

        /* シーンチェンジ後もオブジェクトを維持するかどうかの設定 */
        if (dontDestroyOnLoad)
        {
            DontDestroyOnLoad(transform.gameObject);
            DontDestroyOnLoad(CriWare.managerObject);
        }
    }
Example #14
0
        public static void Notify(string errorClass, string errorMessage, string severity, string context, string stackTrace, bool warmup)
        {
            var stackFrames = new ArrayList();

            foreach (Match frameMatch in unityExpression.Matches(stackTrace))
            {
                var method    = frameMatch.Groups[1].Value;
                var className = "";
                if (method == "")
                {
                    method = "Unknown method";
                }
                else
                {
                    var index = method.LastIndexOf(".");
                    if (index >= 0)
                    {
                        className = method.Substring(0, index);
                        method    = method.Substring(index + 1);
                    }
                }
                var file = frameMatch.Groups[2].Value;
                if (file == "" || file == "<filename unknown>")
                {
                    file = "unknown file";
                }
                var line = frameMatch.Groups[3].Value;
                if (line == "")
                {
                    line = "0";
                }

                var stackFrame = new AndroidJavaObject("java.lang.StackTraceElement", className, method, file, Convert.ToInt32(line));
                stackFrames.Add(stackFrame);
            }

            if (stackFrames.Count > 0 && warmup == false)
            {
                IntPtr stackFrameArrayObject = AndroidJNI.NewObjectArray(stackFrames.Count, ((AndroidJavaObject)(stackFrames[0])).GetRawClass(), ((AndroidJavaObject)(stackFrames[0])).GetRawObject());

                for (var i = 1; i < stackFrames.Count; i++)
                {
                    AndroidJNI.SetObjectArrayElement(stackFrameArrayObject, i, ((AndroidJavaObject)(stackFrames[i])).GetRawObject());
                }

                var Severity         = new AndroidJavaClass("com.bugsnag.android.Severity");
                var severityInstance = Severity.GetStatic <AndroidJavaObject>("ERROR");

                if (severity == "info")
                {
                    severityInstance = Severity.GetStatic <AndroidJavaObject>("INFO");
                }
                else if (severity == "warning")
                {
                    severityInstance = Severity.GetStatic <AndroidJavaObject>("WARNING");
                }

                // Add unity exception to meta data
                var      metaData = new AndroidJavaObject("com.bugsnag.android.MetaData");
                jvalue[] args     = new jvalue[3] {
                    new jvalue()
                    {
                        l = AndroidJNI.NewStringUTF("unity")
                    },
                    new jvalue()
                    {
                        l = AndroidJNI.NewStringUTF("unityException")
                    },
                    new jvalue()
                    {
                        l = AndroidJNI.NewStringUTF("true")
                    },
                };
                IntPtr addToTabMethodId = AndroidJNI.GetMethodID(metaData.GetRawClass(), "addToTab", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)V");
                AndroidJNI.CallVoidMethod(metaData.GetRawObject(), addToTabMethodId, args);

                // Build the arguments
                args = new jvalue[6] {
                    new jvalue()
                    {
                        l = AndroidJNI.NewStringUTF(errorClass)
                    },
                    new jvalue()
                    {
                        l = AndroidJNI.NewStringUTF(errorMessage)
                    },
                    new jvalue()
                    {
                        l = AndroidJNI.NewStringUTF(context)
                    },
                    new jvalue()
                    {
                        l = (IntPtr)stackFrameArrayObject
                    },
                    new jvalue()
                    {
                        l = severityInstance.GetRawObject()
                    },
                    new jvalue()
                    {
                        l = metaData.GetRawObject()
                    }
                };

                // Call Android's notify method
                IntPtr clientConstructorId = AndroidJNI.GetStaticMethodID(Bugsnag.GetRawClass(), "notify", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/StackTraceElement;Lcom/bugsnag/android/Severity;Lcom/bugsnag/android/MetaData;)V");
                if (warmup == false)
                {
                    AndroidJNI.CallStaticVoidMethod(Bugsnag.GetRawClass(), clientConstructorId, args);
                }
            }
        }
Example #15
0
        public static IEnumerator GetDynamicArrayIEnumerator(DynamicArray dynamicArray)
        {
            Dynamic[]           dynamicInner = new Dynamic[dynamicArray.ArraySize];
            AndroidJavaObject[] bigArray     = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(dynamicArray.Array);

            int count = 0;

            for (int i = 0; i < bigArray.Length; i++)
            {
                AndroidJavaObject   tempJavaObject = bigArray[i];
                AndroidJavaObject[] InnerArray     = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(tempJavaObject.GetRawObject());

                for (int j = 0; j < InnerArray.Length; j++)
                {
                    AndroidJavaObject tempObj = InnerArray[j];
                    dynamicInner[count] = new Dynamic(tempObj.GetRawObject(), tempObj);
                    count++;
                }
                yield return(new WaitForSeconds(0.2f));
            }
            finalDynamic = dynamicInner;
        }
Example #16
0
        public static IEnumerator GetArrayWithQuerySyncIEnumerator(Query query, QueryKind queryKind)
        {
            if (javaUnityApplicasaLanguages == null)
            {
                javaUnityApplicasaLanguages = new AndroidJavaClass("com.applicasaunity.Unity.ApplicasaLanguages");
            }

            AndroidJavaObject[] bigArray = javaUnityApplicasaLanguages.CallStatic <AndroidJavaObject[]>("ApplicasaLanguagesGetArrayWithQuerySync", query.innerQueryJavaObject, (int)queryKind);

            Languages[] languagesInner = null;;
            for (int i = 0; i < bigArray.Length; i++)
            {
                AndroidJavaObject tempJavaObject = bigArray[i];

                AndroidJavaObject[] InnerArray    = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(tempJavaObject.GetRawObject());
                Languages[]         languagestemp = new Languages[InnerArray.Length];
                for (int j = 0; j < InnerArray.Length; j++)
                {
                    AndroidJavaObject tempObj = InnerArray[j];
                    languagestemp[j] = new Languages(tempObj.GetRawObject(), tempObj);
                }
                if (languagesInner == null)
                {
                    languagesInner = languagestemp;
                }
                else
                {
                    Languages[] firstOne = languagesInner;
                    languagesInner = new Languages[firstOne.Length + languagestemp.Length];
                    firstOne.CopyTo(languagesInner, 0);
                    languagestemp.CopyTo(languagesInner, firstOne.Length);
                }
                yield return(new WaitForSeconds(0.2f));
            }
            finalLanguages = languagesInner;
        }
Example #17
0
        public static Dynamic[] GetDynamicArray(DynamicArray dynamicArray)
        {
            Dynamic[]           dynamicInner = new Dynamic[dynamicArray.ArraySize];
            AndroidJavaObject[] bigArray     = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(dynamicArray.Array);

            int count = 0;

            for (int i = 0; i < bigArray.Length; i++)
            {
                AndroidJavaObject   tempJavaObject = bigArray[i];
                AndroidJavaObject[] InnerArray     = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(tempJavaObject.GetRawObject());

                for (int j = 0; j < InnerArray.Length; j++)
                {
                    AndroidJavaObject tempObj = InnerArray[j];
                    dynamicInner[count] = new Dynamic(tempObj.GetRawObject(), tempObj);
                    count++;
                }
            }
            return(dynamicInner);
        }
Example #18
0
        public static IEnumerator GetLanguagesArrayIEnumerator(LanguagesArray languagesArray)
        {
            Languages[]         languagesInner = new Languages[languagesArray.ArraySize];
            AndroidJavaObject[] bigArray       = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(languagesArray.Array);

            int count = 0;

            for (int i = 0; i < bigArray.Length; i++)
            {
                AndroidJavaObject   tempJavaObject = bigArray[i];
                AndroidJavaObject[] InnerArray     = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(tempJavaObject.GetRawObject());

                for (int j = 0; j < InnerArray.Length; j++)
                {
                    AndroidJavaObject tempObj = InnerArray[j];
                    languagesInner[count] = new Languages(tempObj.GetRawObject(), tempObj);
                    count++;
                }
                yield return(new WaitForSeconds(0.2f));
            }
            finalLanguages = languagesInner;
        }
Example #19
0
    public byte[] loadExternalFileData(string fileName)
    {
        using (var javaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
        {
            AndroidJavaObject activity     = null;
            AndroidJavaObject stream       = null;
            AndroidJavaObject assetManager = null;
            try
            {
                //取得应用的Activity
                activity = javaClass.GetStatic <AndroidJavaObject>("currentActivity");

                //从Activity取得AssetManager实例
                assetManager = activity.Call <AndroidJavaObject>("getAssets");

                //打开文件流
                stream = assetManager.Call <AndroidJavaObject>("open", fileName);
                //获取文件长度
                var availableBytes = stream.Call <int>("available");

                byte[] bytes = null;
                if (availableBytes > 0)
                {
                    //取得InputStream.read的MethodID
                    var clsPtr      = AndroidJNI.FindClass("java.io.InputStream");
                    var METHOD_read = AndroidJNIHelper.GetMethodID(clsPtr, "read", "([B)I");

                    //申请一个Java ByteArray对象句柄
                    var byteArray = AndroidJNI.NewByteArray(availableBytes);
                    //调用方法
                    int readCount = AndroidJNI.CallIntMethod(stream.GetRawObject(), METHOD_read, new[] { new jvalue()
                                                                                                         {
                                                                                                             l = byteArray
                                                                                                         } });
                    //从Java ByteArray中得到C# byte数组
                    bytes = AndroidJNI.FromByteArray(byteArray);
                    //删除Java ByteArray对象句柄
                    AndroidJNI.DeleteLocalRef(byteArray);
                }

                //关闭文件流
                if (stream != null)
                {
                    stream.Call("close");
                    stream.Dispose();
                }
                if (assetManager != null)
                {
                    assetManager.Dispose();
                }
                if (activity != null)
                {
                    activity.Dispose();
                }
                //返回结果
                return(bytes);
            }
            catch (System.Exception ex)
            {
                //关闭文件流
                if (stream != null)
                {
                    stream.Call("close");
                    stream.Dispose();
                }
                if (assetManager != null)
                {
                    assetManager.Dispose();
                }
                if (activity != null)
                {
                    activity.Dispose();
                }

                GameDebug.LogError("loadExternalFileData error: " + ex.Message);
            }
        }

        return(null);
    }
Example #20
0
        public static Languages[] GetLanguagesArray(LanguagesArray languagesArray)
        {
            Languages[]         languagesInner = new Languages[languagesArray.ArraySize];
            AndroidJavaObject[] bigArray       = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(languagesArray.Array);

            int count = 0;

            for (int i = 0; i < bigArray.Length; i++)
            {
                AndroidJavaObject   tempJavaObject = bigArray[i];
                AndroidJavaObject[] InnerArray     = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(tempJavaObject.GetRawObject());

                for (int j = 0; j < InnerArray.Length; j++)
                {
                    AndroidJavaObject tempObj = InnerArray[j];
                    languagesInner[count] = new Languages(tempObj.GetRawObject(), tempObj);
                    count++;
                }
            }
            return(languagesInner);
        }
Example #21
0
        public static IEnumerator GetChatArrayIEnumerator(ChatArray chatArray)
        {
            Chat[] chatInner             = new Chat[chatArray.ArraySize];
            AndroidJavaObject[] bigArray = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(chatArray.Array);

            int count = 0;

            for (int i = 0; i < bigArray.Length; i++)
            {
                AndroidJavaObject   tempJavaObject = bigArray[i];
                AndroidJavaObject[] InnerArray     = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(tempJavaObject.GetRawObject());

                for (int j = 0; j < InnerArray.Length; j++)
                {
                    AndroidJavaObject tempObj = InnerArray[j];
                    chatInner[count] = new Chat(tempObj.GetRawObject(), tempObj);
                    count++;
                }
                yield return(new WaitForSeconds(0.2f));
            }
            finalChat = chatInner;
        }
Example #22
0
 private static bool isInstanceOf(AndroidJavaObject jniItem, string classJniStr)
 {
     System.IntPtr cls = AndroidJNI.FindClass(classJniStr);
     return(AndroidJNI.IsInstanceOf(jniItem.GetRawObject(), cls));
 }
Example #23
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

#if !UNITY_ANDROID || UNITY_EDITOR
        if (!ovrIsInitialized)
        {
            OVR_Initialize();
            OVRPluginEvent.Issue(RenderEventType.Initialize);

            ovrIsInitialized = true;
        }

        var netVersion = new System.Version(Ovr.Hmd.OVR_VERSION_STRING);
        var ovrVersion = new System.Version(Ovr.Hmd.GetVersionString());
        if (netVersion > ovrVersion)
        {
            Debug.LogWarning("Using an older version of LibOVR.");
        }
#endif

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;
        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if UNITY_ANDROID && !UNITY_EDITOR
        // don't allow the application to run if orientation is not landscape left.
        if (Screen.orientation != ScreenOrientation.LandscapeLeft)
        {
            Debug.LogError("********************************************************************************\n");
            Debug.LogError("***** Default screen orientation must be set to landscape left for VR.\n" +
                           "***** Stopping application.\n");
            Debug.LogError("********************************************************************************\n");

            Debug.Break();
            Application.Quit();
        }

        // don't enable gyro, it is not used and triggers expensive display calls
        if (Input.gyro.enabled)
        {
            Debug.LogError("*** Auto-disabling Gyroscope ***");
            Input.gyro.enabled = false;
        }

        // NOTE: On Adreno Lollipop, it is an error to have antiAliasing set on the
        // main window surface with front buffer rendering enabled. The view will
        // render black.
        // On Adreno KitKat, some tiling control modes will cause the view to render
        // black.
        if (QualitySettings.antiAliasing > 1)
        {
            Debug.LogError("*** Antialiasing must be disabled for Gear VR ***");
        }

        // we sync in the TimeWarp, so we don't want unity
        // syncing elsewhere
        QualitySettings.vSyncCount = 0;

        // try to render at 60fps
        Application.targetFrameRate = 60;
        // don't allow the app to run in the background
        Application.runInBackground = false;
        // Disable screen dimming
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        if (!androidJavaInit)
        {
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            activity            = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            javaVrActivityClass = new AndroidJavaClass("com.oculusvr.vrlib.VrActivity");
            // Prepare for the RenderThreadInit()
            SetInitVariables(activity.GetRawObject(), javaVrActivityClass.GetRawClass());

#if !INHIBIT_ENTITLEMENT_CHECK
            AndroidJavaObject entitlementChecker = new AndroidJavaObject("com.oculus.svclib.OVREntitlementChecker");
            entitlementChecker.CallStatic("doAutomatedCheck", activity);
#else
            Debug.Log("Inhibiting Entitlement Check!");
#endif

            androidJavaInit = true;
        }

        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();

        InitVolumeController();
#else
        SetEditorPlay(Application.isEditor);
#endif

        prevEyeTextureAntiAliasing = OVRManager.instance.eyeTextureAntiAliasing;
        prevEyeTextureDepth        = OVRManager.instance.eyeTextureDepth;
        prevEyeTextureFormat       = OVRManager.instance.eyeTextureFormat;
        prevNativeTextureScale     = OVRManager.instance.nativeTextureScale;
        prevVirtualTextureScale    = OVRManager.instance.virtualTextureScale;
        prevMonoscopic             = OVRManager.instance.monoscopic;
        prevHdr = OVRManager.instance.hdr;

        if (display == null)
        {
            display = new OVRDisplay();
        }
        if (tracker == null)
        {
            tracker = new OVRTracker();
        }

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }

#if !UNITY_ANDROID || UNITY_EDITOR
        // Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps().
        if (timeWarp)
        {
            bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9");
            QualitySettings.vSyncCount = useUnityVSync ? 1 : 0;
        }
#endif

#if (UNITY_STANDALONE_WIN && (UNITY_4_6 || UNITY_4_5))
        bool unity_4_6   = false;
        bool unity_4_5_2 = false;
        bool unity_4_5_3 = false;
        bool unity_4_5_4 = false;
        bool unity_4_5_5 = false;

#if (UNITY_4_6)
        unity_4_6 = true;
#elif (UNITY_4_5_2)
        unity_4_5_2 = true;
#elif (UNITY_4_5_3)
        unity_4_5_3 = true;
#elif (UNITY_4_5_4)
        unity_4_5_4 = true;
#elif (UNITY_4_5_5)
        unity_4_5_5 = true;
#endif

        // Detect correct Unity releases which contain the fix for D3D11 exclusive mode.
        string version = Application.unityVersion;
        int    releaseNumber;
        bool   releaseNumberFound = Int32.TryParse(Regex.Match(version, @"\d+$").Value, out releaseNumber);

        // Exclusive mode was broken for D3D9 in Unity 4.5.2p2 - 4.5.4 and 4.6 builds prior to beta 21
        bool unsupportedExclusiveModeD3D9 = (unity_4_6 && version.Last(char.IsLetter) == 'b' && releaseNumberFound && releaseNumber < 21) ||
                                            (unity_4_5_2 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber >= 2) ||
                                            (unity_4_5_3) ||
                                            (unity_4_5_4);

        // Exclusive mode was broken for D3D11 in Unity 4.5.2p2 - 4.5.5p2 and 4.6 builds prior to f1
        bool unsupportedExclusiveModeD3D11 = (unity_4_6 && version.Last(char.IsLetter) == 'b') ||
                                             (unity_4_5_2 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber >= 2) ||
                                             (unity_4_5_3) ||
                                             (unity_4_5_4) ||
                                             (unity_4_5_5 && version.Last(char.IsLetter) == 'f') ||
                                             (unity_4_5_5 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber < 3);

        if (unsupportedExclusiveModeD3D9 && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9"))
        {
            MessageBox(0, "Direct3D 9 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }

        if (unsupportedExclusiveModeD3D11 && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"))
        {
            MessageBox(0, "Direct3D 11 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }
#endif
    }
Example #24
0
    private void Awake()
    {
        // Only allow one instance at runtime.
        if (instance != null)
        {
            enabled = false;
            DestroyImmediate(this);
            return;
        }

        instance = this;

        // Detect whether this platform is a supported platform
        RuntimePlatform currPlatform = Application.platform;

        isSupportedPlatform |= currPlatform == RuntimePlatform.Android;
        isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor;
        isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer;
        if (!isSupportedPlatform)
        {
            Debug.LogWarning("This platform is unsupported");
            return;
        }

#if !UNITY_ANDROID || UNITY_EDITOR
        if (!ovrIsInitialized)
        {
            // If unable to load the Oculus Runtime,
            if (!OVR_Initialize())
            {
                Debug.LogWarning("Unable initialize VR. Please make sure the runtime is installed and running and a VR display is attached.");

                // Runtime is not installed if ovr_Initialize() fails.
                isVRPresent = false;
                // Go monoscopic in response.
                monoscopic = true;
            }
            else
            {
                OVRPluginEvent.Issue(RenderEventType.Initialize);

                isVRPresent = true;

#if UNITY_EDITOR
                // Only allow VR in the editor in extended mode.
                uint caps = capiHmd.GetDesc().HmdCaps;
                uint mask = caps & (uint)HmdCaps.ExtendDesktop;

                isVRPresent = (mask != 0);

                if (!isVRPresent)
                {
                    Debug.LogWarning("VR direct mode rendering is not supported in the editor. Please use extended mode or build a stand-alone player.");
                }
#endif

                ovrIsInitialized = true;
            }
        }

        if (isVRPresent)
        {
            var            netVersion    = new System.Version(Ovr.Hmd.OVR_VERSION_STRING);
            System.Version ovrVersion    = new System.Version("0.0.0");
            var            versionString = Ovr.Hmd.GetVersionString();
            var            success       = false;
            try {
                ovrVersion = new System.Version(versionString);
                success    = true;
            } catch (Exception e) {
                Debug.Log("Failed to parse Oculus version string \"" + versionString + "\" with message \"" + e.Message + "\".");
            }
            if (!success || netVersion > ovrVersion)
            {
                Debug.LogWarning("Version check failed. Please make sure you are using Oculus runtime " +
                                 Ovr.Hmd.OVR_VERSION_STRING + " or newer.");
            }
        }

        SetEditorPlay(Application.isEditor);
#else // UNITY_ANDROID && !UNITY_EDITOR: Start of Android init.
        // Android integration does not dynamically load its runtime.
        isVRPresent = true;

        // log the unity version
        Debug.Log("Unity Version: " + Application.unityVersion);

        // don't allow the application to run if orientation is not landscape left.
        if (Screen.orientation != ScreenOrientation.LandscapeLeft)
        {
            Debug.LogError("********************************************************************************\n");
            Debug.LogError("***** Default screen orientation must be set to landscape left for VR.\n" +
                           "***** Stopping application.\n");
            Debug.LogError("********************************************************************************\n");

            Debug.Break();
            Application.Quit();
        }

        // don't enable gyro, it is not used and triggers expensive display calls
        if (Input.gyro.enabled)
        {
            Debug.LogError("*** Auto-disabling Gyroscope ***");
            Input.gyro.enabled = false;
        }

        // NOTE: On Adreno Lollipop, it is an error to have antiAliasing set on the
        // main window surface with front buffer rendering enabled. The view will
        // render black.
        // On Adreno KitKat, some tiling control modes will cause the view to render
        // black.
        if (QualitySettings.antiAliasing > 1)
        {
            Debug.LogError("*** Antialiasing must be disabled for Gear VR ***");
        }

        // we sync in the TimeWarp, so we don't want unity
        // syncing elsewhere
        QualitySettings.vSyncCount = 0;

        // try to render at 60fps
        Application.targetFrameRate = 60;
        // don't allow the app to run in the background
        Application.runInBackground = false;
        // Disable screen dimming
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        if (!androidJavaInit)
        {
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            activity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            // Prepare for the RenderThreadInit()
            SetInitVariables(activity.GetRawObject(), System.IntPtr.Zero);

#if USE_ENTITLEMENT_CHECK
            AndroidJavaObject entitlementChecker = new AndroidJavaObject("com.oculus.svclib.OVREntitlementChecker");
            entitlementChecker.CallStatic("doAutomatedCheck", activity);
#else
            Debug.Log("Inhibiting Entitlement Check!");
#endif

            androidJavaInit = true;
        }

        // We want to set up our touchpad messaging system
        OVRTouchpad.Create();

        InitVolumeController();

        // set an event delegate like this if you wish to handle events like "reorient".
        //SetVrApiEventDelegate( VrApiEventDefaultDelegate );
#endif // End of android init.

        prevEyeTextureAntiAliasing = OVRManager.instance.eyeTextureAntiAliasing;
        prevEyeTextureDepth        = OVRManager.instance.eyeTextureDepth;
        prevEyeTextureFormat       = OVRManager.instance.eyeTextureFormat;
        prevNativeTextureScale     = OVRManager.instance.nativeTextureScale;
        prevVirtualTextureScale    = OVRManager.instance.virtualTextureScale;
        prevMonoscopic             = OVRManager.instance.monoscopic;
        prevHdr = OVRManager.instance.hdr;

        if (tracker == null)
        {
            tracker = new OVRTracker();
        }
        if (display == null)
        {
            display = new OVRDisplay();
        }
        else
        {
            wasRecreated = true;
        }

        if (resetTrackerOnLoad)
        {
            display.RecenterPose();
        }

#if !UNITY_ANDROID || UNITY_EDITOR
        // Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps().
        if (timeWarp)
        {
            bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9");
            QualitySettings.vSyncCount = useUnityVSync ? 1 : 0;
        }
#endif

#if UNITY_STANDALONE_WIN
        if (!OVRUnityVersionChecker.hasD3D9ExclusiveModeSupport && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9"))
        {
            MessageBox(0, "Direct3D 9 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }

        if (!OVRUnityVersionChecker.hasD3D11ExclusiveModeSupport && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11"))
        {
            MessageBox(0, "Direct3D 11 extended mode is not supported in this configuration. "
                       + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version."
                       , "VR Configuration Warning", 0);
        }
#endif
    }
 /// <summary>
 /// Returns whether <paramref name="androidJavaObject"/> is actually null,
 /// whether on C# or on Java level.
 /// </summary>
 /// <param name="androidJavaObject">The <see cref="AndroidJavaObject"/> to be checked against null.</param>
 /// <returns>true if <paramref name="androidJavaObject"/> is null, false otherwise.</returns>
 public static bool IsNull(this AndroidJavaObject androidJavaObject)
 {
     return(androidJavaObject == null ||
            androidJavaObject.GetRawObject() == IntPtr.Zero);
 }
Example #26
0
        public static ThirdPartyAction[] GetThirdPartyActionArray(ThirdPartyActionArray ThirdPartyActionsArray)
        {
            ThirdPartyAction[]  ThirdPartyActionsInner = new ThirdPartyAction[ThirdPartyActionsArray.ArraySize];
            AndroidJavaObject[] bigArray = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(ThirdPartyActionsArray.Array);

            int count = 0;

            for (int i = 0; i < bigArray.Length; i++)
            {
                AndroidJavaObject   tempJavaObject = bigArray[i];
                AndroidJavaObject[] InnerArray     = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(tempJavaObject.GetRawObject());

                for (int j = 0; j < InnerArray.Length; j++)
                {
                    AndroidJavaObject tempObj = InnerArray[j];
                    ThirdPartyActionsInner[count] = new ThirdPartyAction(tempObj.GetRawObject(), tempObj);
                    count++;
                }
            }
            return(ThirdPartyActionsInner);
        }
    //bool startcheck;


    void DoMyWindow(int windowID)
    {
        if (GUI.Button(new Rect(10, 30, 100, 60), "Login"))
        {
            Debug.Log("login 0");
            using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                Debug.Log("login 1");
                using (AndroidJavaObject curActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity")) {
                    Debug.Log("login 2");
                    if (bLogined)
                    {
                        return;
                    }
                    login(curActivity.GetRawObject(), "Login");
                }
            }
        }
        if (GUI.Button(new Rect(150, 30, 100, 60), "Logout"))
        {
            using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                using (AndroidJavaObject curActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity")) {
                    Debug.Log("logout");
                    if (!bLogined)
                    {
                        return;
                    }
                    logout(curActivity.GetRawObject(), "");
                }
            }
        }
        if (GUI.Button(new Rect(10, 110, 100, 60), "100Gold"))
        {
            using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                using (AndroidJavaObject curActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity")) {
                    if (!bLogined)
                    {
                        return;
                    }
                    Debug.Log("pay");
                    pay(curActivity.GetRawObject(), "Main Camera", 100, "金币", 1, "购买金币", CP_PAY_SYNC_URL, "PayResult");
                }
            }
        }
        if (GUI.Button(new Rect(150, 110, 100, 60), "200Gold"))
        {
            using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                using (AndroidJavaObject curActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity")) {
                    if (!bLogined)
                    {
                        return;
                    }

                    pay(curActivity.GetRawObject(), "Main Camera", 200, "金币", 1, "购买金币", CP_PAY_SYNC_URL, "PayResult");
                    //Debug.Log ("extend");
                    //SFJSONObject temp =new SFJSONObject();
                    //temp.put("callbackcount","2");
                    //temp.put("callback1","callback1");
                    //temp.put("callback2","callback2");
                    //string ss = temp.toInlineString();
                    //SFJSONObject temp1 =new SFJSONObject();
                    //temp1.put("callbackmap",ss);
                    //temp1.put("extendcallback","extendCallback");
                    //string ll = temp1.toString();
                    //SFJSONObject shareinfo = new SFJSONObject();
                    //shareinfo.put("desc", "1sdk.cn");
                    //shareinfo.put("title", "易接");
                    //shareinfo.put("picture", "");
                    //shareinfo.put("icon", "");
                    //shareinfo.put("uibg", "");
                    //string qq = shareinfo.toInlineString();
                    //SFJSONObject data1 = new SFJSONObject();
                    //data1.put("type", "shareinfo");
                    //data1.put("param", qq);
                    //extend (curActivity.GetRawObject(),"data", "Main Camera", ll);
                }
            }
        }
        if (GUI.Button(new Rect(10, 190, 100, 60), "payDialog"))
        {
            using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                using (AndroidJavaObject curActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity")) {
                    if (!bLogined)
                    {
                        return;
                    }
                    Application.LoadLevel("payment");
                }
            }
        }
        if (GUI.Button(new Rect(150, 190, 100, 60), "ChargeDialog"))
        {
            using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                using (AndroidJavaObject curActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity")) {
                    if (!bLogined)
                    {
                        return;
                    }
                    Application.LoadLevel("chargement");
                }
            }
        }

        if (GUI.Button(new Rect(10, 270, 240, 60), "Pay Extend"))
        {
            using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                using (AndroidJavaObject curActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity")) {
                    if (!bLogined)
                    {
                        return;
                    }
                    Application.LoadLevel("extendpayment");
                }
            }
        }

        if (GUI.Button(new Rect(10, 350, 240, 60), "Exit"))
        {
            using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                using (AndroidJavaObject curActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity")) {
                    exit(curActivity.GetRawObject(), "Main Camera", "ExitResult");
                }
            }
        }

        if (GUI.Button(new Rect(10, 430, 240, 60), "setData"))
        {
            using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                using (AndroidJavaObject curActivity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity")) {
                    Application.LoadLevel("setdata");
                }
            }
        }
    }
Example #28
0
        public static IEnumerator GetArrayWithQuerySyncIEnumerator(Query query, QueryKind queryKind)
        {
            if (javaUnityApplicasaDynamic == null)
            {
                javaUnityApplicasaDynamic = new AndroidJavaClass("com.applicasaunity.Unity.ApplicasaDynamic");
            }

            AndroidJavaObject[] bigArray = javaUnityApplicasaDynamic.CallStatic <AndroidJavaObject[]>("ApplicasaDynamicGetArrayWithQuerySync", query.innerQueryJavaObject, (int)queryKind);

            Dynamic[] dynamicInner = null;;
            for (int i = 0; i < bigArray.Length; i++)
            {
                AndroidJavaObject tempJavaObject = bigArray[i];

                AndroidJavaObject[] InnerArray  = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(tempJavaObject.GetRawObject());
                Dynamic[]           dynamictemp = new Dynamic[InnerArray.Length];
                for (int j = 0; j < InnerArray.Length; j++)
                {
                    AndroidJavaObject tempObj = InnerArray[j];
                    dynamictemp[j] = new Dynamic(tempObj.GetRawObject(), tempObj);
                }
                if (dynamicInner == null)
                {
                    dynamicInner = dynamictemp;
                }
                else
                {
                    Dynamic[] firstOne = dynamicInner;
                    dynamicInner = new Dynamic[firstOne.Length + dynamictemp.Length];
                    firstOne.CopyTo(dynamicInner, 0);
                    dynamictemp.CopyTo(dynamicInner, firstOne.Length);
                }
                yield return(new WaitForSeconds(0.2f));
            }
            finalDynamic = dynamicInner;
        }
Example #29
0
    public static bool InitializeAtom(CriAtomConfig config)
    {
        /* CRI Atomライブラリの初期化 */
        if (CriAtomPlugin.IsLibraryInitialized() == false)
        {
            /* 初期化処理の実行 */
            CriAtomPlugin.SetConfigParameters(
                (int)Math.Max(config.maxVirtualVoices, CriAtomPlugin.GetRequiredMaxVirtualVoices(config)),
                config.maxVoiceLimitGroups,
                config.maxCategories,
                config.maxSequenceEventsPerFrame,
                config.maxBeatSyncCallbacksPerFrame,
                config.standardVoicePoolConfig.memoryVoices,
                config.standardVoicePoolConfig.streamingVoices,
                config.hcaMxVoicePoolConfig.memoryVoices,
                config.hcaMxVoicePoolConfig.streamingVoices,
                config.outputSamplingRate,
                config.asrOutputChannels,
                config.usesInGamePreview,
                config.serverFrequency,
                config.maxParameterBlocks,
                config.categoriesPerPlayback,
                config.maxBuses,
                config.vrMode);

            CriAtomPlugin.SetConfigAdditionalParameters_PC(
                config.pcBufferingTime
                );

            CriAtomPlugin.SetConfigAdditionalParameters_IOS(
                (uint)Math.Max(config.iosBufferingTime, 16),
                config.iosOverrideIPodMusic
                );
            /* Android 固有の初期化パラメータを登録 */
            {
                /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */
                if (config.androidBufferingTime == 0)
                {
                    config.androidBufferingTime = (int)(4 * 1000.0 / config.serverFrequency);
                }
                if (config.androidStartBufferingTime == 0)
                {
                    config.androidStartBufferingTime = (int)(3 * 1000.0 / config.serverFrequency);
                }
                IntPtr android_context = IntPtr.Zero;
#if !UNITY_EDITOR && UNITY_ANDROID
                if (config.androidUsesAndroidFastMixer)
                {
                    AndroidJavaClass  jc       = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
                    AndroidJavaObject activity = jc.GetStatic <AndroidJavaObject>("currentActivity");
                    android_context = activity.GetRawObject();
                }
                CriAtomEx.androidDefaultSoundRendererType = config.androidForceToUseAsrForDefaultPlayback ?
                                                            CriAtomEx.SoundRendererType.Asr : CriAtomEx.SoundRendererType.Default;
#endif
                CriAtomPlugin.SetConfigAdditionalParameters_ANDROID(
                    config.androidLowLatencyStandardVoicePoolConfig.memoryVoices,
                    config.androidLowLatencyStandardVoicePoolConfig.streamingVoices,
                    config.androidBufferingTime,
                    config.androidStartBufferingTime,
                    android_context);
            }

            CriAtomPlugin.InitializeLibrary();

            if (config.useRandomSeedWithTime == true)
            {
                /* 時刻を乱数種に設定 */
                CriAtomEx.SetRandomSeed((uint)System.DateTime.Now.Ticks);
            }

            /* ACFファイル指定時は登録 */
            if (config.acfFileName.Length != 0)
            {
                string acfPath = config.acfFileName;
                if (CriWare.IsStreamingAssetsPath(acfPath))
                {
                    acfPath = Path.Combine(CriWare.streamingAssetsPath, acfPath);
                }

                CriAtomEx.RegisterAcf(null, acfPath);
            }
            return(true);
        }
        else
        {
            return(false);
        }
    }
        public static IEnumerator GetVirtualGoodCategoryArrayIEnumerator(VirtualGoodCategoryArray virtualGoodCategoryArray)
        {
            VirtualGoodCategory[] virtualGoodCategoryInner = new VirtualGoodCategory[virtualGoodCategoryArray.ArraySize];
            AndroidJavaObject[]   bigArray = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(virtualGoodCategoryArray.Array);

            int count = 0;

            for (int i = 0; i < bigArray.Length; i++)
            {
                AndroidJavaObject   tempJavaObject = bigArray[i];
                AndroidJavaObject[] InnerArray     = AndroidJNIHelper.ConvertFromJNIArray <AndroidJavaObject[]>(tempJavaObject.GetRawObject());

                for (int j = 0; j < InnerArray.Length; j++)
                {
                    AndroidJavaObject tempObj = InnerArray[j];
                    virtualGoodCategoryInner[count] = new VirtualGoodCategory(tempObj.GetRawObject(), tempObj);
                    count++;
                }
                yield return(new WaitForSeconds(0.2f));
            }
            finalVirtualGoodCategory = virtualGoodCategoryInner;
        }