private void findBuildComponent(GameObject gObj, List <UIGenFlag> childFlags)
        {
            UIGenFlag component = gObj.GetComponent <UIGenFlag>();

            if (component)
            {
                childFlags.Add(component);
            }
            foreach (Transform transform in gObj.transform)
            {
                UIPanelRoot component2 = transform.GetComponent <UIPanelRoot>();
                if (!component2)
                {
                    if (transform.childCount > 0)
                    {
                        this.findBuildComponent(transform.gameObject, childFlags);
                    }
                    else
                    {
                        component = transform.GetComponent <UIGenFlag>();
                        if (component)
                        {
                            childFlags.Add(component);
                        }
                    }
                }
            }
        }
        public void BuildPanel(XmlDocument doc, GameObject root)
        {
            this.initRelativeHierarchy(root);
            if (string.IsNullOrEmpty(this.FilePath))
            {
                Debug.LogError("请先配置PanelRoot导出的脚本文件路径! Hierarchy:" + this.relativePath);
                return;
            }
            UIPanelRoot[]      componentsInChildren = base.GetComponentsInChildren <UIPanelRoot>();
            List <UIPanelRoot> list = new List <UIPanelRoot>();

            UIPanelRoot[] array = componentsInChildren;
            for (int i = 0; i < array.Length; i++)
            {
                UIPanelRoot uIPanelRoot = array[i];
                if (!uIPanelRoot.gameObject.Equals(base.gameObject))
                {
                    list.Add(uIPanelRoot);
                    uIPanelRoot.BuildPanel(doc, root);
                }
            }
            List <UIGenFlag> list2 = new List <UIGenFlag>();

            this.findBuildComponent(base.gameObject, list2);
            string templetPath = (!(root == base.gameObject)) ? "Scripts/Editor/UITools/88-ToLua# Panel Script-SubPanel.lua.txt" : "Scripts/Editor/UITools/88-ToLua# Panel Script-Panel.lua.txt";

            this.writeScriptFile(list, list2, templetPath);
        }
Exemple #3
0
        private void findBuildComponent(GameObject gObj, List <UIGenFlag> childFlags)
        {
            UIGenFlag flag = gObj.GetComponent <UIGenFlag>();

            if (flag)
            {
                childFlags.Add(flag);
            }

            foreach (Transform childTrans in gObj.transform)
            {
                UIPanelRoot subRoot = childTrans.GetComponent <UIPanelRoot>();
                if (subRoot)
                {
                    continue;
                }

                if (childTrans.childCount > 0)
                {
                    findBuildComponent(childTrans.gameObject, childFlags);
                }
                else
                {
                    flag = childTrans.GetComponent <UIGenFlag>();
                    if (flag)
                    {
                        childFlags.Add(flag);
                    }
                }
            }
        }
Exemple #4
0
        public override void OnInspectorGUI()
        {
            UIPanelRoot root = target as UIPanelRoot;

            if (root == null)
            {
                return;
            }

            EditorGUIUtility.labelWidth = 120;
            Transform parentTrans = root.transform.parent;
            bool      isRoot      = false;

            if (parentTrans)
            {
                UIPanelRoot parentRoot = parentTrans.GetComponentInParent <UIPanelRoot>();
                if (parentRoot)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("Field"));
                }
                else
                {
//                    GUI.color = Color.yellow;
//                    EditorGUILayout.PropertyField(serializedObject.FindProperty("Controller"));
                    isRoot = true;
//                    GUI.color = Color.white;
                }
            }

            SerializedProperty requirePath = serializedObject.FindProperty("LuaRequirePath");

//            requirePath.stringValue = EditorGUILayout.TextField("LuaRequirePath" , requirePath.stringValue);
            if (!isRoot)
            {
                EditorGUILayout.PropertyField(requirePath);
            }

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("FilePath", GUILayout.Width(120)))
            {
                string selectFilePath = EditorUtility.SaveFilePanel("Select Folder", Path.Combine(Application.dataPath, root.FilePath),
                                                                    "RootViewName", "lua");
                root.FilePath = selectFilePath.Replace(Application.dataPath, "/").Replace("//", "");
                root.Field    = Path.GetFileNameWithoutExtension(selectFilePath);

                string requireLuaPath = root.FilePath.Replace("LuaFramework/Lua/", "");
                serializedObject.FindProperty("FilePath").stringValue = root.FilePath;
                serializedObject.FindProperty("Field").stringValue    = root.Field;
                requirePath.stringValue = requireLuaPath.Replace(".lua", "").Replace("/", ".");
            }
            GUILayout.TextArea(root.FilePath);
            EditorGUILayout.EndHorizontal();

            GUI.color = Color.green;
            if (isRoot && GUILayout.Button("Build"))
            {
                if (PrefabUtility.GetPrefabType(root.gameObject) != PrefabType.PrefabInstance)
                {
                    EditorUtility.DisplayDialog("提示", "请先存储UI为Prefab\n注意格式为(xxxPanel.prefab)", "OK");
                    return;
                }

                XmlDocument    doc = new XmlDocument();
                XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes");
                doc.AppendChild(dec);

                root.BuildPanel(doc, root.gameObject, true);

                string genDir = Path.Combine(Application.dataPath, ToolConst.GenLogFolder);
                if (!Directory.Exists(genDir))
                {
                    Directory.CreateDirectory(genDir);
                }

                string filePath = Path.Combine(genDir, root.name + ".xml");
                doc.Save(filePath);

                Debug.Log("<color=#2fd95b>Build Success !</color>");
                EditorUtility.DisplayDialog("恭喜", "Build Success !", "OK");
            }
            GUI.color = Color.white;

            serializedObject.ApplyModifiedProperties();
        }