Esempio n. 1
0
        public static void Initialize(string appId)
        {
            if (Application.isEditor)
            {
                var platform = new StandalonePlatform();
                IsPlatformInitialized = platform.InitializeInEditor();
            }
            else if (Application.platform == RuntimePlatform.Android)
            {
                var platform = new AndroidPlatform();
                IsPlatformInitialized = platform.Initialize(appId);
            }
            else if (Application.platform == RuntimePlatform.WindowsPlayer)
            {
                var platform = new WindowsPlatform();
                IsPlatformInitialized = platform.Initialize(appId);
            }
            else
            {
                throw new NotImplementedException("Oculus platform is not implemented on this platform yet.");
            }

            if (!IsPlatformInitialized)
            {
                throw new UnityException("Oculus Platform failed to initialize.");
            }
        }
Esempio n. 2
0
        public static void Initialize(string appId = null)
        {
            if (!UnityEngine.Application.isEditor)
            {
                if (String.IsNullOrEmpty(appId))
                {
                    if (String.IsNullOrEmpty(AppIDFromConfig))
                    {
                        throw new UnityException("Update your app id by selecting 'Oculus Platform' -> 'Edit Settings'");
                    }
                    appId = AppIDFromConfig;
                }
                else
                {
                    if (!String.IsNullOrEmpty(AppIDFromConfig))
                    {
                        Debug.LogWarning(string.Format("The 'Oculus App Id ({0})' field in 'Oculus Platform/Edit Settings' is clobbering appId ({1}) that you passed in to Platform.Core.Init.  You should only specify this in one place.  We recommend the menu location.", AppIDFromConfig, appId));
                    }
                }
            }

            if (UnityEngine.Application.isEditor)
            {
                var platform = new StandalonePlatform();
                IsPlatformInitialized = platform.InitializeInEditor();
            }
            else if (UnityEngine.Application.platform == RuntimePlatform.Android)
            {
                var platform = new AndroidPlatform();
                IsPlatformInitialized = platform.Initialize(appId);
            }
            else if (UnityEngine.Application.platform == RuntimePlatform.WindowsPlayer)
            {
                var platform = new WindowsPlatform();
                IsPlatformInitialized = platform.Initialize(appId);
            }
            else
            {
                throw new NotImplementedException("Oculus platform is not implemented on this platform yet.");
            }

            if (!IsPlatformInitialized)
            {
                throw new UnityException("Oculus Platform failed to initialize.");
            }

            if (LogMessages)
            {
                Debug.LogWarning("Oculus.Platform.Core.LogMessages is set to true. This will cause extra heap allocations, and should not be used outside of testing and debugging.");
            }

            // Create the GameObject that will run the callbacks
            (new GameObject("Oculus.Platform.CallbackRunner")).AddComponent <CallbackRunner>();
        }