public Window CreateWindow(GameObject prefab) { GameObject windowObject = Instantiate(prefab, Screen.transform, false); Window window = windowObject.GetComponent <Window>(); TaskbarButton taskbarButton = Taskbar.AddButton(); if (window && taskbarButton) { LinkWindowToTaskbar(window, taskbarButton); return(window); } Destroy(windowObject); Taskbar.RemoveButton(taskbarButton); return(null); }