uWindowCapture icon indicating copy to clipboard operation
uWindowCapture copied to clipboard

uWindowCapture fails to work on Unity scene change.

Open theGaffe opened this issue 4 years ago • 2 comments

Hello, I've never written one of these GitHub issues, so hopefully what I'm doing is correct.

uWindowCapture fails its validation if I simply change Unity's scene while in Play. No matter what I do in the settings for the Uwc Window Texture, it does not change anything.

Here is a quick recording showcasing this. Here is the only code used, which just changes the scene:

void Update()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            SceneManager.LoadScene("WindowTest1");
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            SceneManager.LoadScene("WindowTest2");
        }
    }

As you can see, once a scene change has occurred, uWindowCapture simply stops working.

Let me know what can be done, I appreciate your time in reading this.

Using Unity version: 2021.1.4f1.2345.4

theGaffe avatar Jun 22 '21 21:06 theGaffe

After some more debugging I found the source of the issue. In the UwcManager.cs file you have:

void OnApplicationQuit()
    {
        Resources.UnloadUnusedAssets();
        Lib.Finalize();
    }

    void OnDisable()
    {
        Lib.SetLogFunc(null);
        Lib.SetErrorFunc(null);
    }

I added the lines from OnApplicationQuit() to OnDisable(), which activates during a scene change:

void OnDisable()
    {
        Lib.SetLogFunc(null);
        Lib.SetErrorFunc(null);
        Resources.UnloadUnusedAssets();
        Lib.Finalize();
    }

And now it works like I want. This is probably a hack that has other issues but at least I can get it working for my purposes for now.

theGaffe avatar Jun 22 '21 22:06 theGaffe

nice to meet you. This is an issue from a little while ago, but I'd like to comment. This content you wrote helped me. thank you very much.

AyumiANDO avatar Apr 26 '23 10:04 AyumiANDO