private void DisplayArray(object obj, ES2EditorType valueType, ES2Header header, string tag) { object[] array = obj as object[]; if (currentArrayFoldouts == null) { currentArrayFoldouts = new bool[array.Length]; } EditorGUILayout.IntField("Length", array.Length); EditorGUILayout.Space(); for (int i = 0; i < array.Length; i++) { if (currentArrayFoldouts[i] = EditorGUILayout.Foldout(currentArrayFoldouts[i], i.ToString())) { EditorGUI.indentLevel++; object guiFields = valueType.DisplayGUI(array[i]); EditorGUI.indentLevel--; if (guiFields == null) { EditorGUILayout.LabelField("This type cannot be viewed."); } else { array[i] = guiFields; } } } currentValue = array; }
private void DisplayList(object obj, ES2EditorType valueType, ES2Header header, string tag) { List <object> array = obj as List <object>; int count = array.Count; if (currentArrayFoldouts == null) { currentArrayFoldouts = new bool[count]; } EditorGUILayout.IntField("Length", count); EditorGUILayout.Space(); // If lengths are not equal, user has modified length field. /*if((Event.current.type == EventType.KeyUp) && (Event.current.keyCode == KeyCode.Return) && GUI.GetNameOfFocusedControl()=="arrayLength") * { * if(length > array.Length) * { * int difference = length-array.Length; * for(int i=0; i<difference; i++) * ArrayUtility.Add<object>(ref array, null); * } * else if(length < array.Length) * { * int difference = array.Length-length; * for(int i=0; i<difference; i++) * ArrayUtility.RemoveAt<object>(ref array, array.Length-difference); * } * * es2Data.loadedData[tag] = array; * }*/ for (int i = 0; i < count; i++) { if (currentArrayFoldouts[i] = EditorGUILayout.Foldout(currentArrayFoldouts[i], i.ToString())) { EditorGUI.indentLevel++; object guiFields = valueType.DisplayGUI(array[i]); EditorGUI.indentLevel--; if (guiFields == null) { EditorGUILayout.LabelField("This type cannot be viewed."); } else { array[i] = guiFields; } } } currentValue = array; }
private void DisplayObject(object value, ES2EditorType valueType, string tag) { object guiFields = valueType.DisplayGUI(value); if (guiFields == null) { EditorGUILayout.LabelField("This type cannot be viewed."); } else { currentValue = guiFields; } }
private void DisplayDictionary(object obj, ES2EditorType valueType, ES2Header header, string tag) { Dictionary <object, object> dict = obj as Dictionary <object, object>; int count = dict.Count; object[] keys = dict.Keys.ToArray(); if (currentArrayFoldouts == null) { currentArrayFoldouts = new bool[count]; } EditorGUILayout.IntField("Count", count); EditorGUILayout.Space(); // If lengths are not equal, user has modified length field. /*if((Event.current.type == EventType.KeyUp) && (Event.current.keyCode == KeyCode.Return) && GUI.GetNameOfFocusedControl()=="arrayLength") * { * if(length > array.Length) * { * int difference = length-array.Length; * for(int i=0; i<difference; i++) * ArrayUtility.Add<object>(ref array, null); * } * else if(length < array.Length) * { * int difference = array.Length-length; * for(int i=0; i<difference; i++) * ArrayUtility.RemoveAt<object>(ref array, array.Length-difference); * } * * es2Data.loadedData[tag] = array; * }*/ for (int i = 0; i < count; i++) { if (currentArrayFoldouts[i] = EditorGUILayout.Foldout(currentArrayFoldouts[i], i.ToString())) { EditorGUI.indentLevel++; EditorGUILayout.LabelField("Key", EditorStyles.boldLabel); EditorGUILayout.Space(); EditorGUI.indentLevel++; // Display Key object keyFields = ES2EditorType.Get(header.keyType).DisplayGUI(keys[i]); if (keyFields == null) { EditorGUILayout.LabelField("This type cannot be viewed."); } EditorGUI.indentLevel--; EditorGUILayout.LabelField("Value", EditorStyles.boldLabel); EditorGUILayout.Space(); EditorGUI.indentLevel++; // Display Value object valueFields = valueType.DisplayGUI(dict[keys[i]]); if (valueFields == null) { EditorGUILayout.LabelField("This type cannot be viewed."); } else { dict[keys[i]] = valueFields; currentValue = dict; } EditorGUI.indentLevel--; EditorGUI.indentLevel--; } } }