コード例 #1
0
ファイル: BatchPlugin.cs プロジェクト: BatchLabs/unity-plugin
		private void setConfig(Config config)
		{
			try
			{
				JsonData data = new JsonData();
				if ( config.CanUseIDFA != null )
				{
					data["useIDFA"] = config.CanUseIDFA;
				}
				if ( config.CanUseAndroidID != null )
				{
					data["useAndroidID"] = config.CanUseAndroidID;
				}
				string apiKey = "";
				#if UNITY_ANDROID
				apiKey = config.AndroidAPIKey;
				#elif UNITY_IPHONE
				apiKey = config.IOSAPIKey;
				#endif
				data["APIKey"] = apiKey;
				bridge.Call("setConfig", JsonMapper.ToJson(data));
			}
			catch(Exception e)
			{
				Logger.Error(true, "setConfig", e);
			}
		}
コード例 #2
0
ファイル: BatchPlugin.cs プロジェクト: BatchLabs/unity-plugin
		/// <summary>
		/// Starts the plugin if not already started.
		/// </summary>
		public void StartPlugin(Config config)
		{
			if ( started )
			{
				return;
			}

			bool unsupportedPlatform = true;
			#if UNITY_ANDROID || UNITY_IPHONE
			if (!UnityEngine.Application.isEditor)
			{
				unsupportedPlatform = false;
			}
			#endif
			if (unsupportedPlatform)
			{
				return;
			}

			if (config == null)
			{
				Logger.Error(false, "StartPlugin", "Cannot start the plugin without a config.");
				return;
			}

			#if UNITY_ANDROID
			if(config.AndroidAPIKey == null)
			{
				Logger.Error(false, "StartPlugin", "Cannot start the plugin without an API key.");
				return;
			}
			#endif

			#if UNITY_IPHONE
			if(config.IOSAPIKey == null)
			{
				Logger.Error(false, "StartPlugin", "Cannot start the plugin without an API key.");
				return;
			}
			#endif

			try
			{
				setConfig(config);
				bridge.Call("unlock.setup", "");
				bridge.Call("start", "");
				started = true;
			}
			catch(Exception e)
			{
				Logger.Error(true, "StartPlugin", e);
			}
		}