private void Awake() { CloseButton.gameObject.SetActive(false); Canvas canvas = FindObjectOfType <Canvas>(); Rect canvasRect = (canvas.transform as RectTransform).rect; //canvas.pixelRect; if (Viewport.x > canvasRect.width) { Viewport.x = canvasRect.width * 0.9F; } if (Viewport.y > canvasRect.height) { Viewport.y = canvasRect.height * 0.9F; } xsollaBrowser = this.GetOrAddComponent <XsollaBrowser>(); xsollaBrowser.LogEvent += XsollaBrowser_LogEvent; xsollaBrowser.Launch(new LaunchBrowserOptions() { Width = (int)Viewport.x, Height = (int)Viewport.y, }); display = this.GetOrAddComponent <Display2DBehaviour>(); }
private void OnDestroy() { StopAllCoroutines(); BrowserClosedEvent?.Invoke(xsollaBrowser); if (mouse != null) { Destroy(mouse); mouse = null; } if (display != null) { Destroy(display); display = null; } if (keyboard != null) { keyboard.EscapePressed -= Keyboard_EscapePressed; Destroy(keyboard); keyboard = null; } if (xsollaBrowser != null) { Destroy(xsollaBrowser); xsollaBrowser = null; } }
private void Awake() { progressLocker = new object(); lastProgress = 0; xsollaBrowser = GetComponent <XsollaBrowser>(); xsollaBrowser.FetchingBrowserEvent += XsollaBrowser_FetchingBrowserEvent; StartCoroutine(PreloaderInstantiateCoroutine()); StartCoroutine(PreloaderDestroyCoroutine()); }
private void Awake() { BackButton.onClick.AddListener(OnBackButtonPressed); CloseButton.gameObject.SetActive(false); BackButton.gameObject.SetActive(false); var canvasTrn = GetComponentInParent <Canvas>().transform; var canvasRect = ((RectTransform)canvasTrn).rect; if (Viewport.x > canvasRect.width) { Viewport.x = canvasRect.width; } if (Viewport.y > canvasRect.height) { Viewport.y = canvasRect.height; } xsollaBrowser = this.GetOrAddComponent <XsollaBrowser>(); xsollaBrowser.LogEvent += Debug.Log; xsollaBrowser.Launch ( new LaunchBrowserOptions { Width = (int)Viewport.x, Height = (int)Viewport.y, }, new BrowserFetcherOptions { #if UNITY_STANDALONE && !UNITY_EDITOR Path = !XsollaSettings.PackInAppBrowserInBuild ? Application.persistentDataPath : String.Empty, #endif #if UNITY_EDITOR Path = Application.persistentDataPath, #endif #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN #if UNITY_64 Platform = Platform.Win64 #else Platform = Platform.Win32 #endif #endif #if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX Platform = Platform.MacOS #endif #if UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX Platform = Platform.Linux #endif }
private void CreateBrowser() { var canvas = FindObjectOfType <Canvas>(); if (canvas == null) { Debug.LogError("Can not find canvas! So can not draw 2D browser!"); return; } BrowserObject = Instantiate(BrowserPrefab, canvas.transform); SinglePageBrowser = BrowserObject.GetComponentInChildren <SinglePageBrowser2D>(); XsollaBrowser = BrowserObject.GetComponentInChildren <XsollaBrowser>(); }
private void OpenInAppBrowser(string url) { if (_inAppBrowserObject == null) { Canvas canvas = FindObjectOfType <Canvas>(); if (canvas == null) { Debug.LogError("Can not find canvas! So can not draw 2D browser!"); return; } _inAppBrowserObject = Instantiate(inAppBrowserPrefab, canvas.transform); XsollaBrowser xsollaBrowser = _inAppBrowserObject.GetComponent <XsollaBrowser>(); xsollaBrowser.Navigate.To(url); } else { Debug.LogError("You try create browser instance, but it already created!"); } }