コード例 #1
0
        private void StartCef()
        {
#if UNITY_EDITOR
            CefRuntime.Load("./Assets/Plugins/x86_64");
#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, 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);
        }
コード例 #2
0
 public OffscreenLoadHandler(OffscreenCEFClient client, bool hideScrollbars)
 {
     this.client         = client;
     this.hideScrollbars = hideScrollbars;
 }
コード例 #3
0
 public OffscreenRenderHandler(int windowWidth, int windowHeight, OffscreenCEFClient client)
 {
     this._windowWidth  = windowWidth;
     this._windowHeight = windowHeight;
     this.client        = client;
 }