示例#1
0
        /// <summary>
        /// Initializes the SOOMLA SDK.
        /// </summary>
        /// <param name="storeAssets">Your game's economy.</param>
        /// <exception cref="ExitGUIException">Thrown if soomlaSecret is missing or has not been changed.</exception>
        public static bool Initialize(IStoreAssets storeAssets)
        {
            StoreEvents.Initialize();
            if (string.IsNullOrEmpty(CoreSettings.SoomlaSecret))
            {
                SoomlaUtils.LogError(TAG, "MISSING SoomlaSecret !!! Stopping here !!");
                throw new ExitGUIException();
            }

            if (CoreSettings.SoomlaSecret == CoreSettings.ONLY_ONCE_DEFAULT)
            {
                SoomlaUtils.LogError(TAG, "You have to change SoomlaSecret !!! Stopping here !!");
                throw new ExitGUIException();
            }

            var storeEvents = GameObject.FindObjectOfType <StoreEvents> ();

            if (storeEvents == null)
            {
                SoomlaUtils.LogDebug(TAG, "StoreEvents Component not found in scene. We're continuing from here but you won't get many events.");
            }

            if (Initialized)
            {
                StoreEvents.Instance.onUnexpectedStoreError("{\"errorCode\": 0}", true);
                SoomlaUtils.LogError(TAG, "SoomlaStore is already initialized. You can't initialize it twice!");
                return(false);
            }

            SoomlaUtils.LogDebug(TAG, "SoomlaStore Initializing ...");

            StoreInfo.SetStoreAssets(storeAssets);

            instance._loadBillingService();

                        #if UNITY_IOS
            // On iOS we only refresh market items
            instance._refreshMarketItemsDetails();
#elif UNITY_ANDROID
            // On Android we refresh market items and restore transactions
            instance._refreshInventory();
#elif UNITY_WP8
            instance._refreshInventory();
#endif

            Initialized = true;
            StoreEvents.Instance.onSoomlaStoreInitialized("", true);

            return(true);
        }