public override void OnInspectorGUI() { GUILayout.Space(6f); EditorGUIUtility.LookLikeControls(120f); DictionaryGameObject utt = target as DictionaryGameObject; GUI.changed = false; string type = EditorGUILayout.TextField("Type", utt.type); if (GUI.changed) { NGUIEditorTools.RegisterUndo("Root", utt); utt.type = type; UnityEditor.EditorUtility.SetDirty(utt); } if (NGUIEditorTools.DrawHeader("Items")) { NGUIEditorTools.BeginContents(); DictionaryGameObject ut = target as DictionaryGameObject; Field1(ut, ut.Perfabs /*,ut.DicPerfabs*/); NGUIEditorTools.EndContents(); } }
/// <summary> /// Draw a list of fields for the specified list of delegates. /// </summary> public void Field1(Object undoObject, List <ItemGameObject> list /*,Dictionary<string,HlepPoint> dictionary*/) { bool targetPresent = false; bool isValid = false; DictionaryGameObject ut = undoObject as DictionaryGameObject; ItemGameObject tempdel; // Draw existing delegates for (int i = 0; i < list.Count;) { ItemGameObject del = list[i]; /*if (!dictionary.TryGetValue(del.ID,out tempdel)) * { * dictionary.Add(del.ID,del); * }*/ if (del == null || del.ID == "") { //dictionary.Remove(del.ID); list.RemoveAt(i); continue; } string ID = del.ID; Field1(undoObject, del); EditorGUILayout.Space(); if (ID != del.ID) { if (ut.CheckKey(del.ID) > 1) { del.ID = ID; } /*else * { * dictionary.Remove(ID); * dictionary.Add(del.ID,del); * }*/ } /*if(ID != del.ID) * { * if (dictionary.TryGetValue(del.ID,out tempdel)) * { * del.ID = ID; * } * else * { * dictionary.Remove(ID); * dictionary.Add(del.ID,del); * } * }*/ ++i; } // Draw a new delegate ItemGameObject newDel = new ItemGameObject(); Field1(undoObject, newDel); if (newDel.ID != "") { targetPresent = true; if (ut.CheckKey(newDel.ID) == 0) { list.Add(newDel); } /*if (!dictionary.TryGetValue(newDel.ID,out tempdel)) * { * dictionary.Add(newDel.ID,newDel); * }*/ } }