static public T LoadPanel <T>(string p = "Panels/") where T : MonoBehaviour { var type = typeof(T); string path = p + type.Name; GameObject obj = null; if (!obj) { obj = GK.TryLoadGameObject(path); } if (!obj) { Debug.LogError("Error load UI panle " + type.Name); return(null); } var c = obj.GetComponent <T>(); if (!c) { Debug.LogError("Error GetComponent from UI Panel " + type.Name); return(null); } GK.SetParent(c.gameObject, instance.panelGroup.gameObject, false); return(c); }
// Create UI node. static public GameObject CreateNode(string name, GameObject parent, string layerName) { GameObject go = new GameObject(name); GK.SetParent(go, parent, false); go.layer = GK.LayerId(layerName); return(go); }
public GameObject GetOrAddGroup(string name) { var o = GK.FindChild(gameObject, name, true, false); if (!o) { o = new GameObject(name); GK.SetParent(o, gameObject, false); o.layer = GK.LayerId("UI"); } return(o); }
public void Load() { GameObject go = GKEditor.LoadGameObject(path, true); sceneObj = go; GK.SetParent(go, UIController.instance.GetOrAddGroup("UIRoot"), false); var tran = go.GetComponent <RectTransform>(); if (null != tran) { tran.localPosition = Vector3.zero; tran.sizeDelta = Vector2.zero; } Selection.activeGameObject = go; }