Batch.BatchPlugin.StartPlugin C# (CSharp) Method

StartPlugin() public method

Starts the plugin if not already started.
public StartPlugin ( Config config ) : void
config Config
return void
		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);
			}
		}