Exemplo n.º 1
0
        /// <summary>
        /// Initializes integration API
        /// </summary>
        /// <returns>Initialized status</returns>
        public static bool Initialize()
        {
            if (!Initialized)
            {
                try
                {
                    AppKey = IntegrationSettings.AppKey;
                    if (!string.IsNullOrEmpty(AppKey))
                    {
                        if (PlatformMessages.InitializeMessages())
                        {
                            PlatformMessages.OnMessageReceived(HandlePlatformMessage);

                            new GameObject("ARVI.Integration.ResponseHandler", typeof(ResponseHandler));
                            new GameObject("ARVI.Integration.PlatformMessageHandler", typeof(PlatformMessageHandler));

                            if (!Application.runInBackground)
                            {
                                Debug.LogWarning("<b><color=red>Warning!</color></b> For ARVI SDK to work correctly, you must to set the option <b>\"Run In Background\"</b> in the project settings (Edit -> Project Settings -> Player -> Resolution and Presentation).");
                            }

                            Initialized = true;
                        }
                        else
                        {
                            throw new Exception(string.Format("{0} Error: {1}", Errors.PLATFORM_MESSAGES_NOT_INITIALIZED, PlatformMessages.GetErrorMessage()));
                        }
                    }
                    else
                    {
                        throw new Exception(Errors.EMPTY_APPKEY);
                    }
                }
                catch (DllNotFoundException)
                {
                    Debug.LogError(string.Format("{0} File {1}.dll not found in \"Plugins\" directory.", Errors.PLUGIN_NOT_FOUND, API.LIB_ARVI_DLL_NAME));
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex.Message);
                }
            }
            return(Initialized);
        }
 protected virtual void OnApplicationQuit()
 {
     PlatformMessages.FinalizeMessages();
 }
 protected virtual void Update()
 {
     PlatformMessages.Execute();
 }