public static void Init() { root = Assets.Load("Prefabs/ui/ui_root"); Error.Verify(root != null); windows_container = root.GetChild("windows")?.transform; Error.Verify(windows_container != null); }
public static T Open<T>() where T : UIWindow { string prefab = GetPrefab(typeof(T)); var ui_window_go = Assets.Load(prefab, windows_container.transform); var window = ui_window_go.AddComponentOnce<T>(); if(window != null) windows.Add(window); return window as T; }
//TODO: Use assets pool for loading objects static UIWindow LoadWindowSync(string name) { var prefab = Assets.Load($"Prefabs/ui/windows/{name}", parent: windows_container.transform); var window = prefab.GetComponent<UIWindow>(); Error.Assert(window != null, $"Failed to load UI window ({name}). UIWindow component not found."); window.SetNameHash(Hash.CRC32(name)); return window; }
public void DefineHPBar(uint unit_id) { var unit = battleground.GetUnit(unit_id); if (unit == null) { return; } var bar_go = Assets.Load("Prefabs/ui/hp_bar", canvas_go.transform); var bar = bar_go.GetComponent <Scrollbar>(); Error.Assert(bar != null, "Cannot define hp bar: missing scrollbar component."); hp_bars.Add(unit_id, bar); }
public static void Init() { root = Assets.Load("UI/ui_root"); Error.Verify(root != null); loading_go = root.GetChild("loading"); loading_go.SetActive(false); windows_container = root.GetChild("windows"); camera = root.GetChild("camera").GetComponent<Camera>(); Error.Verify(camera != null); camera.GetComponent<AudioListener>().enabled = false; event_system = root.GetComponent<EventSystem>(); Error.Verify(event_system != null); event_system.pixelDragThreshold = EVENT_SYSTEM_DRAG_THRESHOLD; }