상속: ScriptableObject
예제 #1
0
        public static void GlobalInitialization()
        {
#if UNITY_EDITOR
            Log.setLogFunc((LogLevel, msg) =>
            {
                switch (LogLevel)
                {
                case LogLevel.Error:
                    Debug.LogError(msg);
                    break;

                case LogLevel.Warning:
                    Debug.LogWarning(msg);
                    break;

                case LogLevel.Info:
                    Debug.Log(msg);
                    break;

                default:
                    break;
                }
            });
            System.AppDomain.CurrentDomain.DomainUnload += (sender, e) =>
            {
                Log.resetLogFunc();
            };
#endif

            Initialized = false;
            Scheduler   = new DelayedCallbackScheduler();
            var key = Settings.LicenseKey;
            System.AppDomain.CurrentDomain.DomainUnload += (sender, e) =>
            {
                if (Scheduler != null)
                {
                    Scheduler.Dispose();
                }
                settings = null;
            };
#if UNITY_ANDROID && !UNITY_EDITOR
            using (var unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
                using (var currentActivity = unityPlayerClass.GetStatic <AndroidJavaObject>("currentActivity"))
                    using (var easyarEngineClass = new AndroidJavaClass("cn.easyar.Engine"))
                    {
                        var activityclassloader = currentActivity.Call <AndroidJavaObject>("getClass").Call <AndroidJavaObject>("getClassLoader");
                        if (activityclassloader == null)
                        {
                            Debug.Log("ActivityClassLoader is null");
                        }
                        if (!easyarEngineClass.CallStatic <bool>("initialize", currentActivity, key))
                        {
                            Debug.LogError("EasyAR Sense Initialize Fail");
                            Initialized = false;
                            return;
                        }
                        else
                        {
                            Initialized = true;
                        }
                    }
#else
            if (!Engine.initialize(key.Trim()))
            {
                Debug.LogError("EasyAR Sense Initialize Fail");
                Initialized = false;
                return;
            }
            else
            {
                Initialized = true;
            }
#endif
            System.AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                Debug.Log("UnhandledException: " + e.ExceptionObject.ToString());
            };
        }
        public static void GlobalInitialization()
        {
            Debug.Log("EasyAR Sense Unity Plugin Version " + EasyARVersion.FullVersion);
#if UNITY_ANDROID && !UNITY_EDITOR
            if (Settings.ARCoreSupport)
            {
                try
                {
                    using (var systemClass = new AndroidJavaClass("java.lang.System"))
                    {
                        systemClass.CallStatic("loadLibrary", "arcore_sdk_c");
                    }
                }
                catch (AndroidJavaException)
                {
                    ARCoreLoadFailed = true;
                }
            }
#endif
            Initialized = false;
            Scheduler   = new DelayedCallbackScheduler();
#if UNITY_EDITOR
            Log.setLogFuncWithScheduler(Scheduler, (LogLevel, msg) =>
            {
                switch (LogLevel)
                {
                case LogLevel.Error:
                    Debug.LogError(msg);
                    break;

                case LogLevel.Warning:
                    Debug.LogWarning(msg);
                    break;

                case LogLevel.Info:
                    Debug.Log(msg);
                    break;

                default:
                    break;
                }
            });
#endif
            var key = Settings.LicenseKey;
            System.AppDomain.CurrentDomain.DomainUnload += (sender, e) =>
            {
#if UNITY_EDITOR
                Log.resetLogFunc();
#endif
                if (Scheduler != null)
                {
                    Scheduler.Dispose();
                }
                settings = null;
            };
#if UNITY_ANDROID && !UNITY_EDITOR
            using (var unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
                using (var currentActivity = unityPlayerClass.GetStatic <AndroidJavaObject>("currentActivity"))
                    using (var easyarEngineClass = new AndroidJavaClass("cn.easyar.Engine"))
                    {
                        var activityclassloader = currentActivity.Call <AndroidJavaObject>("getClass").Call <AndroidJavaObject>("getClassLoader");
                        if (activityclassloader == null)
                        {
                            Debug.Log("ActivityClassLoader is null");
                        }
                        easyarEngineClass.CallStatic("loadLibraries");
                        if (!easyarEngineClass.CallStatic <bool>("setupActivity", currentActivity))
                        {
                            Debug.LogError("EasyAR Sense Initialize Fail");
                            Initialized = false;
                            return;
                        }
                    }
#endif
            if (!Engine.initialize(key.Trim()))
            {
                Debug.LogError("EasyAR Sense Initialize Fail");
                Initialized = false;
                return;
            }
            else
            {
                Initialized = true;
            }
            System.AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                Debug.Log("UnhandledException: " + e.ExceptionObject.ToString());
            };
        }