Пример #1
0
        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);
                        }
                    }
                }
            }
        }
Пример #2
0
 public void deserializePanelRoot(XmlElement ele)
 {
     this.Field          = ele.GetAttribute("field");
     this.FilePath       = ele.GetAttribute("filePath");
     this.LuaRequirePath = ele.GetAttribute("luaRequirePath");
     if (string.IsNullOrEmpty(this.LuaRequirePath))
     {
         this.LuaRequirePath = this.FilePath.Replace(".lua", string.Empty).Replace("/", ".");
     }
     foreach (XmlElement xmlElement in ele.ChildNodes)
     {
         string text = xmlElement.GetAttribute("hierarchy");
         text = text.Replace(".", "/");
         Transform transform = base.transform.FindChild(text);
         if (!(transform == null))
         {
             UIGenFlag uIGenFlag = transform.GetComponent <UIGenFlag>();
             if (uIGenFlag == null)
             {
                 uIGenFlag = transform.gameObject.AddComponent <UIGenFlag>();
             }
             uIGenFlag.deserializeFlag(xmlElement);
         }
     }
 }
Пример #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);
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 反序列化记录数据
        /// </summary>
        /// <param name="doc"></param>
        public void deserializePanelRoot(XmlElement ele)
        {
            this.Field          = ele.GetAttribute("field");
            this.FilePath       = ele.GetAttribute("filePath");
            this.LuaRequirePath = ele.GetAttribute("luaRequirePath");
            if (string.IsNullOrEmpty(LuaRequirePath))
            {
                LuaRequirePath = this.FilePath.Replace(".lua", "").Replace("/", ".");
            }
//            this.Controller = ele.GetAttribute("ctrlName");

            foreach (XmlElement childEle in ele.ChildNodes)
            {
                string hierarchy = childEle.GetAttribute("hierarchy");
                hierarchy = hierarchy.Replace(".", "/");
                Transform trans = this.transform.Find(hierarchy);
                if (trans == null)
                {
                    continue;
                }

                UIGenFlag flag = trans.GetComponent <UIGenFlag>();
                if (flag == null)
                {
                    flag = trans.gameObject.AddComponent <UIGenFlag>();
                }
                flag.deserializeFlag(childEle);
            }
        }
Пример #5
0
        public override void OnInspectorGUI()
        {
            UIGenFlag genFlag = target as UIGenFlag;

            EditorGUIUtility.labelWidth = 120;
//            EditorGUILayout.PropertyField(serializedObject.FindProperty("Uri"));

            EditorGUILayout.PropertyField(serializedObject.FindProperty("Field"));

            SerializedProperty st = serializedObject.FindProperty("ScriptType");

            string[] typeStrArr  = genFlag.FindWidgetTypes().ToArray();
            int      selectIndex = 0;

            if (genFlag.ScriptType != null)
            {
                for (int i = 0; i < typeStrArr.Length; i++)
                {
                    if (typeStrArr[i] == genFlag.ScriptType)
                    {
                        selectIndex = i;
                    }
                }
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Script Type", GUILayout.Width(EditorGUIUtility.labelWidth));
            selectIndex    = EditorGUILayout.Popup(selectIndex, typeStrArr);
            st.stringValue = typeStrArr[selectIndex];
            EditorGUILayout.EndHorizontal();

            serializedObject.ApplyModifiedProperties();
        }
Пример #6
0
        private string formatExport(UIGenFlag genFlag)
        {
            StringBuilder buf = new StringBuilder();

            buf.AppendFormat("\t\t{{field=\"{0}\",path=\"{1}\",",
                             string.IsNullOrEmpty(genFlag.Field) ? genFlag.gameObject.name : genFlag.Field,
                             genFlag.relativeHierarchy);

            if (genFlag.ScriptType == typeof(UILabel).FullName)
            {
                buf.Append("src=LuaText");
            }
            else if (genFlag.ScriptType == typeof(UISprite).FullName)
            {
                buf.Append("src=LuaImage");
            }
            else if (genFlag.ScriptType == typeof(UIButton).FullName)
            {
                buf.Append("src=LuaButton, onClick = function (gObj)  --[===[todo click]===]  end ");
            }
            else if (genFlag.ScriptType == typeof(UIToggle).FullName)
            {
                buf.Append("src=LuaToggle , onChange = function (toggle) --[===[todo toggle.onchange]===] end");
            }
            else if (genFlag.ScriptType == typeof(UIPanel).FullName)
            {
                buf.Append("src=LuaPanel");
            }
            else if (genFlag.ScriptType == typeof(UIInput).FullName)
            {
                buf.Append("src=LuaInput, onChange = function (input) --[===[todo input change]===]  end , onSubmit = function (input) --[===[todo input onSubmit]===]  end");
            }
            else if (genFlag.ScriptType == typeof(UISlider).FullName)
            {
                buf.Append("src=LuaSlider, onValueChange = function (slider) --[===[todo change]===]  end ");
            }
            else if (genFlag.ScriptType == typeof(UIScrollBar).FullName)
            {
                buf.Append("src=LuaScrollBar, onValueChange = function (scrollBar) --[===[todo change]===]  end ");
            }
            else if (genFlag.ScriptType == typeof(UIWrapContent).FullName)
            {
                buf.Append("src=LuaWrapContent, onInitializeItem = function (go, wrapIndex, realIndex) --[===[todo change]===]  end ");
            }
            else
            {
                buf.AppendFormat("src=\"{0}\"", genFlag.ScriptType);
            }
            buf.Append("},");

            return(buf.ToString());
        }