コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        bool didChange;

        if (Time.time - lastUpdateTime < 1.0f / captureRateFps)
        {
            return;
        }
        else
        {
            lastUpdateTime = Time.time;
        }



        // Capture the desktop
        Texture2D desktopTexture = desktopCapture1.GetWindowTexture(out didChange);

        desktopObject.transform.localScale = new Vector3(desktopCapture1.desktopWidth * windowScale, 0.1f, desktopCapture1.desktopHeight * windowScale);
        if (didChange)
        {
            desktopObject.transform.GetComponent <Renderer>().material.mainTexture = desktopTexture;
        }

        // Gets information about position and icon of the cursor so you can render it onto the captured surfaces
        WindowCapture.UpdateCursorInfo();

        // Capture each window
        foreach (IntPtr key in windowsRendering.Keys)
        {
            WindowCapture window       = windowsRendering[key];
            GameObject    windowObject = windowObjects[key];

            if (windowObject == null)
            {
                continue;
            }

            Texture2D windowTexture = window.GetWindowTexture(out didChange);
            if (didChange)
            {
                windowObject.GetComponent <Renderer>().material.mainTexture = windowTexture;
            }
            windowObject.transform.localScale = new Vector3(window.windowWidth * windowScale, 0.1f, window.windowHeight * windowScale);
        }

        // Poll for new windows
        if (Time.time - lastPollWindowsTime < 1.0f / windowPollPerSecond)
        {
            return;
        }
        else
        {
            lastPollWindowsTime = Time.time;
            // calls OnAddWindow or OnRemoveWindow above if any windows have been added or removed
            captureManager.Poll();
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        bool didChange;

        /*
         * Texture2D chromiumTexture = chromiumCapture.GetChromiumTexture(out didChange);
         * if (didChange)
         * {
         * chromiumObject.GetComponent<Renderer>().material.mainTexture = chromiumTexture;
         * }
         * chromiumObject.transform.localScale = new Vector3(chromiumTexture.width * windowScale, 0.1f, chromiumTexture.height * windowScale);
         *
         *
         * if (Time.frameCount == 400)
         * {
         * chromiumCapture.SetUrl("http://reddit.com");
         * }
         *
         * if (Time.time - lastUpdateTime < 1.0f / captureRateFps)
         * {
         * return;
         * }
         * else
         * {
         * lastUpdateTime = Time.time;
         * }
         */


        // Capture the desktop
        Texture2D desktopTexture = desktopCapture1.GetWindowTexture(out didChange);

        desktopObject.transform.localScale = new Vector3(desktopCapture1.desktopWidth * windowScale, 0.1f, desktopCapture1.desktopHeight * windowScale);
        if (didChange)
        {
            desktopObject.transform.GetComponent <Renderer>().material.mainTexture = desktopTexture;
        }

        // Gets information about position and icon of the cursor so you can render it onto the captured surfaces
        WindowCapture.UpdateCursorInfo();

        Profiler.BeginSample("test");
        // Capture each window
        foreach (IntPtr key in windowsRendering.Keys)
        {
            Debug.Log("+");
            WindowCapture window       = windowsRendering[key];
            GameObject    windowObject = windowObjects[key];

            if (windowObject == null)
            {
                continue;
            }

            Texture2D windowTexture = window.GetWindowTexture(out didChange);
            if (didChange)
            {
                windowObject.GetComponent <Renderer>().material.mainTexture = windowTexture;
            }
            windowObject.transform.localScale = new Vector3(window.windowWidth * windowScale, 0.1f, window.windowHeight * windowScale);
        }
        Debug.Log("-");
        Profiler.EndSample();
        // Poll for new windows
        if (Time.time - lastPollWindowsTime < 1.0f / windowPollPerSecond)
        {
            return;
        }
        else
        {
            lastPollWindowsTime = Time.time;
            // calls OnAddWindow or OnRemoveWindow above if any windows have been added or removed
            captureManager.Poll();
        }
    }