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 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 #3
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;
     }
 }