コード例 #1
0
        // Use this for initialization
        void Start()
        {
            this.BrowserTexture = new Texture2D(this.windowSize.Width, this.windowSize.Height, TextureFormat.BGRA32, false);

            if (GetComponent <RawImage>() != null)
            {
                GetComponent <RawImage>().texture = BrowserTexture;
            }
            if (GetComponent <MeshRenderer>() != null)
            {
                GetComponent <MeshRenderer>().material.mainTexture = BrowserTexture;
            }

#if !UNITY_EDITOR
            // Instruct CEF to not render to a window.
            CefWindowInfo cefWindowInfo = CefWindowInfo.Create();
            cefWindowInfo.SetAsWindowless(IntPtr.Zero, false);

            // Settings for the browser window itself (e.g. enable JavaScript?).
            CefBrowserSettings cefBrowserSettings = new CefBrowserSettings()
            {
                BackgroundColor           = new CefColor(255, 60, 85, 115),
                JavaScript                = CefState.Enabled,
                JavaScriptAccessClipboard = CefState.Disabled,
                JavaScriptCloseWindows    = CefState.Disabled,
                JavaScriptDomPaste        = CefState.Disabled,
                JavaScriptOpenWindows     = CefState.Disabled,
                LocalStorage              = CefState.Disabled
            };

            // Initialize some of the custom interactions with the browser process.
            this.cefClient = new OffscreenCEFClient(this.windowSize, this.hideScrollbars);

            // Start up the browser instance.
            CefBrowserHost.CreateBrowser(cefWindowInfo, this.cefClient, cefBrowserSettings, string.IsNullOrEmpty(this.url) ? "http://www.google.com" : this.url);
#endif
            StartCoroutine(UpdateTexture());
            StartCoroutine(MessagePump());
        }
コード例 #2
0
 public OffscreenRenderHandler(int windowWidth, int windowHeight, OffscreenCEFClient client)
 {
     this._windowWidth  = windowWidth;
     this._windowHeight = windowHeight;
     this.client        = client;
 }
コード例 #3
0
 public OffscreenLoadHandler(OffscreenCEFClient client, bool hideScrollbars)
 {
     this.client         = client;
     this.hideScrollbars = hideScrollbars;
 }