hecomi / uWindowCapture

This allows you to use Windows Graphics Capture / PrintWindow / BitBlt in Windows to capture multiple windows individually and easily use them as Texture2D in Unity.
https://tips.hecomi.com/entry/2021/04/30/230322
MIT License
493 stars 79 forks source link

Can't change the value of Desktop Index, I'm trying to work with mutiple displays at the same time, Please help!! #62

Open Infinix31 opened 9 months ago

11305064-HenryWang commented 1 month ago

same here,please reply if you solve this issue.thanks!

11305064-HenryWang commented 1 month ago

using UnityEngine;

namespace uWindowCapture {

public class UwcDesktopTextureManager : UwcWindowTextureManager
{
    void Start()
    {
        UwcManager.onDesktopAdded.AddListener(OnWindowAdded);
        UwcManager.onDesktopRemoved.AddListener(OnWindowRemoved);
        foreach (var pair in UwcManager.windows)
        {
            OnWindowAdded(pair.Value);
        }
    }

    void OnWindowAdded(UwcWindow window)
    {
        if (window.parentWindow != null) return; // handled by UwcWindowTextureChildrenManager
        if (!window.isVisible || !window.isDesktop || window.isBackground) return;

        window.RequestCapture();
        AddWindowTexture(window);
    }

    void OnWindowRemoved(UwcWindow window)
    {
        RemoveWindowTexture(window);
    }
}

} solve this by replacing UwcAltTabWindowTextureManager to this in horizontallayout scene.