コード例 #1
0
        private void StartCef()
        {
#if UNITY_EDITOR
            CefRuntime.Load(Path.Combine(Application.dataPath, "Plugins", "Cef", "Windows"));
#else
            CefRuntime.Load();
#endif


            var cefMainArgs = new CefMainArgs(new string[] { });
            var cefApp      = new OffscreenCEFClient.OffscreenCEFApp();

            // This is where the code path diverges for child processes.
            if (CefRuntime.ExecuteProcess(cefMainArgs, cefApp, IntPtr.Zero) != -1)
            {
                Debug.LogError("Could not start the secondary process.");
            }

            var cefSettings = new CefSettings
            {
                //ExternalMessagePump = true,
                MultiThreadedMessageLoop = false,
                SingleProcess            = true,
                LogSeverity = CefLogSeverity.Verbose,
                LogFile     = "cef.log",
                WindowlessRenderingEnabled = true,
                NoSandbox = true
            };

            // Start the browser process (a child process).
            CefRuntime.Initialize(cefMainArgs, cefSettings, cefApp, IntPtr.Zero);

            // Instruct CEF to not render to a window.
            CefWindowInfo cefWindowInfo = CefWindowInfo.Create();
            cefWindowInfo.SetAsWindowless(IntPtr.Zero, true);

            // Settings for the browser window itself (e.g. enable JavaScript?).
            CefBrowserSettings cefBrowserSettings = new CefBrowserSettings()
            {
            };

            Debug.Log("Start with window: " + this.windowWidth + ", " + this.windowHeight);

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

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