Exemple #1
0
 void StartToUIList(string filepath)
 {
     this.serization = null;
     UIElementPool.Recover(uielement);
     this.serization = Deserialize(OperateFile.LoadFile(openfilepath));
     if (this.serization == null)
     {
         Debug.LogError(" Deserizaliztion fail "); Debug.LogError("序列化文件失败");
     }
     if (this.serization is IDictionary <string, object> )
     {
         DicToUIList("", null, this.serization as IDictionary <string, object>, true, 0);
     }
     else if (this.serization is List <object> )
     {
         ListToUIList("", null, this.serization as List <object>, true, 0);
     }
 }
Exemple #2
0
    void ListInsertUIList(string name, UIElement fatherobj, List <object> list, bool flag, int index)
    {
        int       nextindex   = index + 1;
        UIElement listelement = UIElementPool.Pop(name, flag, fatherobj, list, fatherobj.level + 1);

        uielement.Insert(index, listelement);
        for (int i = 0; i < list.Count; ++i)
        {
            if (list[i] is List <object> )
            {
                ListInsertUIList(i.ToString(), listelement, list[i] as List <object>, false, nextindex);
            }
            else if (list[i] is IDictionary <string, object> )
            {
                DicInsertUIList(i.ToString(), listelement, list[i] as IDictionary <string, object>, false, nextindex);
            }
            else
            {
                DotObjectInsertUIList(i.ToString(), listelement, list[i], nextindex);
            }
        }
    }
Exemple #3
0
    void ListToUIList(string name, UIElement fatherobj, List <object> list, bool flag, int level)
    {
        int       childlevel  = level + 1;
        UIElement listelement = UIElementPool.Pop(name, flag, fatherobj, list, level);

        uielement.Add(listelement);
        for (int i = 0; i < list.Count; ++i)
        {
            if (list[i] is List <object> )
            {
                ListToUIList(i.ToString(), listelement, list[i] as List <object>, false, childlevel);
            }
            else if (list[i] is IDictionary <string, object> )
            {
                DicToUIList(i.ToString(), listelement, list[i] as IDictionary <string, object>, false, childlevel);
            }
            else
            {
                DotObjectToUIList(i.ToString(), listelement, list[i], childlevel);
            }
        }
    }
Exemple #4
0
 void ReToUIList(object serization, object UIobj)
 {
     UIElementPool.Recover(uielement);
     if (serization is IDictionary <string, object> )
     {
         DicToUIList("", null, serization as IDictionary <string, object>, true, 0);
     }
     else if (this.serization is List <object> )
     {
         ListToUIList("", null, this.serization as List <object>, true, 0);
     }
     if (UIobj == null)
     {
         return;
     }
     for (int i = 0; i < uielement.Count; ++i)
     {
         if (uielement[i].obj == UIobj)
         {
             if (UIobj is List <object> || UIobj is IDictionary <string, object> )
             {
                 uielement[i].flag   = true;
                 uielement[i].extend = true;
             }
             else
             {
                 uielement[i].flag = true;
             }
             UIElement father = uielement[i].father;
             while (father != null)
             {
                 father.extend = true;
                 father.flag   = true;
                 father        = father.father;
             }
         }
     }
 }
Exemple #5
0
    void DicToUIList(string name, UIElement fatherobj, IDictionary <string, object> dic, bool flag, int level)
    {
        int       childlevel = level + 1;
        UIElement dictarget  = UIElementPool.Pop(name, flag, fatherobj, dic, level);

        uielement.Add(dictarget);

        foreach (var item in dic.Keys)
        {
            if (dic[item] is IDictionary <string, object> )
            {
                DicToUIList(item, dictarget, dic[item] as IDictionary <string, object>, false, childlevel);
            }
            else if (dic[item] is List <object> )
            {
                ListToUIList(item, dictarget, dic[item] as List <object>, false, childlevel);
            }
            else
            {
                DotObjectToUIList(item, dictarget, dic[item], childlevel);
            }
        }
    }
Exemple #6
0
    void DicInsertUIList(string name, UIElement fatherobj, IDictionary <string, object> dic, bool flag, int index)
    {
        int       childlevel = fatherobj.level + 1;
        int       nextindex  = index + 1;
        UIElement dictarget  = UIElementPool.Pop(name, flag, fatherobj, dic, childlevel);

        uielement.Insert(index, dictarget);

        foreach (var item in dic.Keys)
        {
            if (dic[item] is IDictionary <string, object> )
            {
                DicInsertUIList(item, dictarget, dic[item] as IDictionary <string, object>, false, nextindex);
            }
            else if (dic[item] is List <object> )
            {
                ListInsertUIList(item, dictarget, dic[item] as List <object>, false, nextindex);
            }
            else
            {
                DotObjectInsertUIList(item, dictarget, dic[item], nextindex);
            }
        }
    }
Exemple #7
0
 void DrawToolBar()
 {
     if (GUI.Button(new Rect(0, 0, 50, 15), "Open"))
     {
         if (openfilepath == null)
         {
             openfilepath = EditorUtility.OpenFilePanel("Open Json", "", "json");
         }
         else
         {
             string[]      filename = openfilepath.Split('/');
             StringBuilder dirc     = new StringBuilder();
             for (int i = 0; i < filename.Length - 1; ++i)
             {
                 dirc.Append(filename[i]);
             }
             openfilepath = EditorUtility.OpenFilePanel("Open Json", dirc.ToString(), "json");
         }
         StartToUIList(openfilepath);
     }
     if (GUI.Button(new Rect(50, 0, 50, 15), "Save"))
     {
         if (savefilepath == null)
         {
             savefilepath = EditorUtility.SaveFilePanel("Save Json", "", ".json", "json");
         }
         else
         {
             string[]      filename = savefilepath.Split('/');
             StringBuilder dirc     = new StringBuilder();
             for (int i = 0; i < filename.Length - 1; ++i)
             {
                 dirc.Append(filename[i]);
             }
             savefilepath = EditorUtility.SaveFilePanel("Save Json", dirc.ToString(), filename[filename.Length - 1], "json");
         }
         OperateFile.CreateNewFile(savefilepath, Json.Serialize(this.serization));
     }
     if (GUI.Button(new Rect(100, 0, 100, 15), "SerizeNewType"))
     {
         try
         {
             this.serization = SecondDeserialize(Activator.CreateInstance(Types[selectType]));
             UIElementPool.Recover(uielement);
             ReToUIList(this.serization);
         }
         catch (Exception e)
         {
             Debug.LogError("Class Type Error  " + e);
             Debug.LogError(" 类型错误   " + e);
         }
     }
     typeName   = EditorGUI.TextField(new Rect(200f, 0f, 300f, 15f), "TypeName", typeName);
     selectType = EditorGUI.Popup(new Rect(500f, 0f, 300f, 15f), " SelectType", selectType, TypesFullName.ToArray());
     if (typeName == null || typeName == "")
     {
         return;
     }
     else if (lastSelectType != selectType)
     {
         typeName       = TypesFullName[selectType];
         lastSelectType = selectType;
         lastTypeName   = typeName;
         return;
     }
     else if (lastTypeName != typeName)
     {
         this.Types = Reflection.RetType(typeName);
         TypesFullName.Clear();
         for (int i = 0; i < Types.Count; ++i)
         {
             TypesFullName.Add(Types[i].FullName);
         }
         lastTypeName = typeName;
     }
 }
Exemple #8
0
 void DotObjectInsertUIList(string name, UIElement fatherobj, object obj, int index)
 {
     uielement.Insert(index, UIElementPool.Pop(name, false, fatherobj, obj, fatherobj.level + 1));
 }
Exemple #9
0
 void DotObjectToUIList(string name, UIElement fatherobj, object obj, int level)
 {
     uielement.Add(UIElementPool.Pop(name, false, fatherobj, obj, level));
 }