Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        // 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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
            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;
            }