1
0
mirror of https://github.com/xiaopeng12138/MaiDXR.git synced 2024-12-24 06:04:50 +01:00
MaiDXR/Assets/uWindowCapture/Runtime/UwcAltTabWindowTextureManager.cs

33 lines
780 B
C#
Raw Normal View History

2022-01-05 19:44:30 +01:00
using UnityEngine;
namespace uWindowCapture
{
public class UwcAltTabWindowTextureManager : UwcWindowTextureManager
{
void Start()
{
UwcManager.onWindowAdded.AddListener(OnWindowAdded);
UwcManager.onWindowRemoved.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.isAltTabWindow || window.isBackground) return;
window.RequestCapture();
AddWindowTexture(window);
}
void OnWindowRemoved(UwcWindow window)
{
RemoveWindowTexture(window);
}
}
}