Esempio n. 1
0
        void Awake()
        {
            if (gameObject.name == "Browser2D_SOOJLE")
            {
                // Height = 1720;
            }

            _mainEngine = new BrowserEngine();

            if (RandomMemoryFile)
            {
                Guid memid = Guid.NewGuid();
                MemoryFile = memid.ToString();
            }
            if (RandomPort)
            {
                System.Random r = new System.Random();
                Port = 8000 + r.Next(1000);
            }

            _mainEngine.InitPlugin(Width, Height, MemoryFile, Port, InitialURL, EnableWebRTC);
            //run initialization
            if (JSInitializationCode.Trim() != "")
            {
                _mainEngine.RunJSOnce(JSInitializationCode);
            }
        }
Esempio n. 2
0
        void Awake()
        {
            _mainEngine = new BrowserEngine();

            if (RandomMemoryFile)
            {
                Guid memid = Guid.NewGuid();
                MemoryFile = memid.ToString();
            }

            _mainEngine.InitPlugin(Width, Height, MemoryFile, InitialURL, EnableWebRTC, EnableGPU);
            //run initialization
            if (JSInitializationCode.Trim() != "")
            {
                _mainEngine.RunJSOnce(JSInitializationCode);
            }
        }
        private void Start()
        {
            _mainEngine = new BrowserEngine {
                dynamicRequestHandler = gameObject.GetComponent <IDynamicRequestHandler>()
            };

            if (RandomMemoryFile)
            {
                var memid = Guid.NewGuid();
                MemoryFile = memid.ToString();
            }


            //run initialization
            if (JSInitializationCode.Trim() != "")
            {
                _mainEngine.RunJSOnce(JSInitializationCode);
            }

            if (UIEnabled)
            {
                InitPrefabLinks();
                if (mainUIPanel != null)
                {
                    mainUIPanel.InitPrefabLinks();
                }
            }

            if (MainCamera == null)
            {
                MainCamera = Camera.main;
                if (MainCamera == null)
                {
                    Debug.LogError("Error: can't find main camera");
                }
            }



            if (UIEnabled && mainUIPanel != null)
            {
                mainUIPanel.MainCanvas.worldCamera = MainCamera;
                mainUIPanel.KeepUIVisible          = KeepUIVisible;
                if (!KeepUIVisible)
                {
                    mainUIPanel.Hide();
                }
            }

            //attach dialogs and querys
            _mainEngine.OnJavaScriptDialog     += _mainEngine_OnJavaScriptDialog;
            _mainEngine.OnJavaScriptQuery      += _mainEngine_OnJavaScriptQuery;
            _mainEngine.OnPageLoaded           += _mainEngine_OnPageLoaded;
            _mainEngine.OnTextureObjectUpdated += OnTextureObjectUpdated;
            _mainEngine.StreamingResourceName   = StreamingResourceName;


            if (DialogEnabled && DialogCanvas != null)
            {
                DialogCanvas.worldCamera = MainCamera;
                DialogCanvas.gameObject.SetActive(false);
            }
            var initCoroutine = _mainEngine.InitPlugin(Width, Height, MemoryFile, InitialURL, EnableWebRTC, EnableGPU);

            StartCoroutine(initCoroutine);
        }
        void Start()
        {
            Debug.Log("Browser2d start");
            if (AutoFitParent)
            {
                var pixsource = transform as RectTransform;
                var rect      = pixsource.rect;
                Width  = (int)rect.width;
                Height = (int)rect.height;
                Debug.LogFormat("Browser2d resize to {0}x{1}", Width, Height);
            }
            _mainEngine = new BrowserEngine();

            if (RandomMemoryFile)
            {
                Guid memid = Guid.NewGuid();
                MemoryFile = memid.ToString();
            }


            //run initialization
            if (JSInitializationCode.Trim() != "")
            {
                _mainEngine.RunJSOnce(JSInitializationCode);
            }

            if (UIEnabled)
            {
                InitPrefabLinks();
                if (mainUIPanel != null)
                {
                    mainUIPanel.InitPrefabLinks();
                }
            }

            var parentcanvas = GetComponentInParent <Canvas>();

            if (parentcanvas != null)
            {
                _mainCamera = parentcanvas.worldCamera; //get camera assigned to parent canvas
            }
            if (_mainCamera == null)                    //try to get default but this completely wrong
            {
                _mainCamera = GameObject.Find("Main Camera").GetComponent <Camera>();
            }

            if (mainUIPanel != null)
            {
                mainUIPanel.KeepUIVisible = KeepUIVisible;
                if (!KeepUIVisible)
                {
                    mainUIPanel.Hide();
                }
            }

            //attach dialogs and querys
            _mainEngine.OnJavaScriptDialog     += _mainEngine_OnJavaScriptDialog;
            _mainEngine.OnJavaScriptQuery      += _mainEngine_OnJavaScriptQuery;
            _mainEngine.OnPageLoaded           += _mainEngine_OnPageLoaded;
            _mainEngine.OnTextureObjectUpdated += OnTextureObjectUpdated;

            if (DialogPanel != null)
            {
                DialogPanel.SetActive(false);
            }
            IEnumerator initCoroutine = _mainEngine.InitPlugin(Width, Height, MemoryFile, InitialURL, EnableWebRTC, EnableGPU);

            StartCoroutine(initCoroutine);
        }
Esempio n. 5
0
        void Start()
        {
            _mainEngine = new BrowserEngine();

            if (RandomMemoryFile)
            {
                Guid memid = Guid.NewGuid();
                MemoryFile = memid.ToString();
            }



            StartCoroutine(_mainEngine.InitPlugin(Width, Height, MemoryFile, InitialURL, EnableWebRTC, EnableGPU));
            //run initialization
            if (JSInitializationCode.Trim() != "")
            {
                _mainEngine.RunJSOnce(JSInitializationCode);
            }

            //
            if (UIEnabled)
            {
                InitPrefabLinks();
                mainUIPanel.InitPrefabLinks();
            }

            if (MainCamera == null)
            {
                MainCamera = Camera.main;
                if (MainCamera == null)
                {
                    Debug.LogError("Error: can't find main camera");
                }
            }

            _mainMaterial = GetComponent <MeshRenderer>().material;
            _mainMaterial.SetTexture("_MainTex", _mainEngine.BrowserTexture);
            _mainMaterial.SetTextureScale("_MainTex", new Vector2(-1, 1));


            if (UIEnabled)
            {
                mainUIPanel.MainCanvas.worldCamera = MainCamera;
            }



            // _mainInput = MainUrlInput.GetComponent<Input>();
            if (UIEnabled)
            {
                mainUIPanel.KeepUIVisible = KeepUIVisible;
                if (!KeepUIVisible)
                {
                    mainUIPanel.Hide();
                }
            }

            //attach dialogs and querys
            _mainEngine.OnJavaScriptDialog += _mainEngine_OnJavaScriptDialog;
            _mainEngine.OnJavaScriptQuery  += _mainEngine_OnJavaScriptQuery;
            _mainEngine.OnPageLoaded       += _mainEngine_OnPageLoaded;

            if (DialogEnabled)
            {
                DialogCanvas.worldCamera = MainCamera;
                DialogCanvas.gameObject.SetActive(false);
            }
        }