Exemple #1
0
	// Use this for initialization
	void Start () {
		#if COHERENT_UI_EVALUATION_UNITY3D
			StartActivator();
		#endif

		if (SystemInfo.graphicsDeviceVersion.StartsWith("Direct3D 11")
				|| SystemInfo.operatingSystem.Contains("Mac"))
		{
			DeviceSupportsSharedTextures = true;
		}

		if (m_UISystem == null)
		{
			m_SystemListener = (SystemListenerFactoryFunc != null)? SystemListenerFactoryFunc(this.OnSystemReady) : new SystemListener(this.OnSystemReady);
			if (FileHandlerFactoryFunc != null)
			{
				m_FileHandler = FileHandlerFactoryFunc();
			}
			#if !UNITY_ANDROID || UNITY_EDITOR

			if (m_FileHandler == null)
			{
				Debug.LogWarning("Unable to create file handler using factory function! Falling back to default handler.");
				m_FileHandler = new UnityFileHandler();
			}
			#endif

			#if UNITY_EDITOR || COHERENT_UNITY_STANDALONE || COHERENT_UNITY_UNSUPPORTED_PLATFORM
			ContextSettings settings = new ContextSettings()
			{
				EnableProxy = this.EnableProxy,
				AllowCookies = this.AllowCookies,
				CookiesResource = "file:///" + Application.persistentDataPath + '/' + this.CookiesResource,
				CachePath = Path.Combine(Application.temporaryCachePath, this.CachePath),
				HTML5LocalStoragePath = Path.Combine(Application.temporaryCachePath, this.HTML5LocalStoragePath),
				ForceDisablePluginFullscreen = this.ForceDisablePluginFullscreen,
				DisableWebSecurity = this.DisableWebSecurity,
				DebuggerPort = this.DebuggerPort,
			};
			#elif UNITY_IPHONE || UNITY_ANDROID
			ContextSettings settings = new ContextSettings() {
				iOS_UseURLCache = m_UseURLCache,
				iOS_URLMemoryCacheSize = (uint)m_MemoryCacheSize,
				iOS_URLDiskCacheSize = (uint)m_DiskCacheSize,
			};
			int sdkVersion = Coherent.UI.Mobile.Versioning.SDKVersion;
			#endif

			if (string.IsNullOrEmpty(Coherent.UI.License.COHERENT_KEY))
			{
				throw new System.ApplicationException("You must supply a license key to start Coherent UI! Follow the instructions in the manual for editing the License.cs file.");
			}

			m_UISystem = CoherentUILibrary.CreateViewContext(
				settings, m_SystemListener, m_FileHandler);
			if (m_UISystem == null)
			{
				throw new System.ApplicationException("Creating a ViewContext"
					+ " failed!");
			}
			Debug.Log ("Coherent UI system initialized..");
			#if UNITY_EDITOR || COHERENT_UNITY_STANDALONE
			CoherentUIViewRenderer.WakeRenderer(
				(byte)m_UISystem.GetContextId());
			#endif
		}
		m_StartTime = Time.realtimeSinceStartup;

		DontDestroyOnLoad(this.gameObject);
	}