public static string Serialize(StoreConfiguration store) { var dic = new Dictionary <string, object>() { { "androidStore", store.androidStore.ToString() } }; return(MiniJson.JsonEncode(dic)); }
/// <summary> /// Creates an instance of StandardPurchasingModule or retrieves the existing one, specifying a type of App store. /// </summary> /// <param name="androidStore"> The type of Android Store with which to create the instance. </param> /// <returns> The existing instance or the one just created. </returns> public static StandardPurchasingModule Instance(AppStore androidStore) { if (null == ModuleInstance) { var logger = UnityEngine.Debug.unityLogger; logger.Log("UnityIAP Version: " + k_PackageVersion); var gameObject = new GameObject("IAPUtil"); Object.DontDestroyOnLoad(gameObject); gameObject.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector; var util = gameObject.AddComponent <UnityUtil> (); var webUtil = gameObject.AddComponent <AsyncWebUtil>(); var textAsset = (Resources.Load("BillingMode") as TextAsset); StoreConfiguration config = null; if (null != textAsset) { config = StoreConfiguration.Deserialize(textAsset.text); } // No Android target specified at runtime, use the build time setting. if (androidStore == AppStore.NotSpecified) { // Default to Google Play if we don't have a build time store selection. androidStore = AppStore.GooglePlay; if (null != config) { var buildTimeStore = config.androidStore; if (buildTimeStore != AppStore.NotSpecified) { androidStore = buildTimeStore; } } } ModuleInstance = new StandardPurchasingModule( util, webUtil, logger, new NativeStoreProvider(), Application.platform, androidStore, false, Application.persistentDataPath); } return(ModuleInstance); }