diff --git a/Assets/uWindowCapture/Examples/Window List/UwcWindowList.cs b/Assets/uWindowCapture/Examples/Window List/UwcWindowList.cs index c4f9778..0eec50a 100644 --- a/Assets/uWindowCapture/Examples/Window List/UwcWindowList.cs +++ b/Assets/uWindowCapture/Examples/Window List/UwcWindowList.cs @@ -35,6 +35,8 @@ void OnWindowAdded(UwcWindow window) window.RequestCaptureIcon(); window.RequestCapture(CapturePriority.Low); + + listItem.OnClick(); } void OnWindowRemoved(UwcWindow window) @@ -42,6 +44,7 @@ void OnWindowRemoved(UwcWindow window) UwcWindowListItem listItem; items_.TryGetValue(window.id, out listItem); if (listItem) { + listItem.RemoveWindow(); Destroy(listItem.gameObject); } } diff --git a/Assets/uWindowCapture/Examples/Window List/UwcWindowListItem.cs b/Assets/uWindowCapture/Examples/Window List/UwcWindowListItem.cs index 81f03ab..d283f0e 100644 --- a/Assets/uWindowCapture/Examples/Window List/UwcWindowListItem.cs +++ b/Assets/uWindowCapture/Examples/Window List/UwcWindowListItem.cs @@ -58,16 +58,27 @@ void Update() public void OnClick() { - var manager = list.windowTextureManager; if (windowTexture == null) { - windowTexture = manager.AddWindowTexture(window); - image_.color = selected; + AddWindow(); } else { - manager.RemoveWindowTexture(window); - windowTexture = null; - image_.color = notSelected; + RemoveWindow(); } } + + void AddWindow() + { + var manager = list.windowTextureManager; + windowTexture = manager.AddWindowTexture(window); + image_.color = selected; + } + + public void RemoveWindow() + { + var manager = list.windowTextureManager; + manager.RemoveWindowTexture(window); + windowTexture = null; + image_.color = notSelected; + } } } \ No newline at end of file