public object DrawAndGetNewValue(Type type, object value, DrawInfo draw, FieldInfo field) { EditorGUI.BeginDisabledGroup(!draw.Changeable); if (value == null) { ObjectDrawerHelper.ShowNull(draw.ShowName, type, ref value); } else { bool fold = ObjectDrawerHelper.GetAndAddFieldShow_Fold(draw.FieldName); fold = EditorGUILayout.Foldout(fold, draw.ShowName, true); ObjectDrawerHelper.SetAndAddFieldShow_Fold(draw.FieldName, fold); if (fold) { EditorGUILayout.BeginHorizontal(); ObjectDrawerHelper.Tab(); ObjectDrawerHelper.DrawObj(value, draw.NeedDelayed); EditorGUILayout.EndHorizontal(); } } EditorGUI.EndDisabledGroup(); return(value); }
public object DrawAndGetNewValue(Type type, object value, DrawInfo draw, FieldInfo field) { EditorGUI.BeginDisabledGroup(!draw.Changeable); if (value == null) { ObjectDrawerHelper.ShowNull(draw.ShowName, type, ref value); } else { var v = (IList)value; Type elementType = GetElementType(v); bool fold = ObjectDrawerHelper.GetAndAddFieldShow_Fold(draw.FieldName); fold = EditorGUILayout.Foldout(fold, draw.ShowName, true); ObjectDrawerHelper.SetAndAddFieldShow_Fold(draw.FieldName, fold); if (fold) { int count = v.Count; int len = count / 10 + 1; int count_T = v.Count; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("数量:", GUILayout.Width(60)); EditorGUILayout.LabelField(count.ToString()); EditorGUILayout.EndHorizontal(); for (int i = 0; i < v.Count; i++) { EditorGUILayout.BeginHorizontal(); ObjectDrawerHelper.Tab(); EditorGUILayout.LabelField("Element:", GUILayout.Width(60)); EditorGUILayout.BeginVertical(); string showName = $"{i}"; v[i] = ObjectDrawerHelper.DrawAndGetNewValue(elementType, v[i], new DrawInfo() { Changeable = draw.Changeable, NeedDelayed = draw.NeedDelayed, ShowName = showName, ShowNameWidth = len * 5 + 15, IsStatic = false, FieldName = field.Name + $"_{i}" }, field); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } } value = v; } EditorGUI.EndDisabledGroup(); return(value); }
public object DrawAndGetNewValue(Type type, object value, DrawInfo draw, FieldInfo field) { EditorGUI.BeginDisabledGroup(!draw.Changeable); if (value == null) { ObjectDrawerHelper.ShowNull(draw.ShowName, null, ref value); } else { var v = (Delegate)value; bool fold = ObjectDrawerHelper.GetAndAddFieldShow_Fold(draw.FieldName); fold = EditorGUILayout.Foldout(fold, draw.ShowName, true); ObjectDrawerHelper.SetAndAddFieldShow_Fold(draw.FieldName, fold); if (fold) { Delegate[] ds = v.GetInvocationList(); int len = ds.Length / 10 + 1; for (int i = 0; i < ds.Length; i++) { var d = ds[i]; EditorGUILayout.BeginHorizontal(); ObjectDrawerHelper.Tab(); EditorGUILayout.LabelField("Delegate:", GUILayout.Width(60)); EditorGUILayout.LabelField($"{i}", GUILayout.Width(len * 5 + 15)); EditorGUILayout.LabelField($"{d.Method.ReflectedType}.{d.Method.Name}"); EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("测试运行(如果该委托无参的话)")) { v.DynamicInvoke(); } } value = v; } EditorGUI.EndDisabledGroup(); return(value); }
public object DrawAndGetNewValue(Type type, object value, DrawInfo draw, FieldInfo field) { EditorGUI.BeginDisabledGroup(!draw.Changeable); if (value == null) { ObjectDrawerHelper.ShowNull(draw.ShowName, type, ref value); } else { var v = (Stack)value; bool fold = ObjectDrawerHelper.GetAndAddFieldShow_Fold(draw.FieldName); fold = EditorGUILayout.Foldout(fold, draw.ShowName, true); ObjectDrawerHelper.SetAndAddFieldShow_Fold(draw.FieldName, fold); if (fold) { int count = v.Count; int len = count / 10 + 1; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("数量:", GUILayout.Width(60)); EditorGUILayout.LabelField(count.ToString()); EditorGUILayout.EndHorizontal(); var array = v.ToArray(); for (int i = 0; i < array.Length; i++) { EditorGUILayout.BeginHorizontal(); ObjectDrawerHelper.Tab(); EditorGUILayout.LabelField("Element:", GUILayout.Width(60)); EditorGUILayout.BeginVertical(); string showName = $"{i}"; array[i] = ObjectDrawerHelper.DrawAndGetNewValue(array[i].GetType(), array[i], new DrawInfo() { Changeable = draw.Changeable, NeedDelayed = draw.NeedDelayed, ShowName = showName, ShowNameWidth = len * 5 + 15, IsStatic = false, FieldName = field.Name + $"_{i}" }, field); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } v.Clear(); for (int i = array.Length - 1; i >= 0; i--) { v.Push(array[i]); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(""); if (v.Count > 0) { if (GUILayout.Button("Pop", GUILayout.Width(40))) { v.Pop(); } } if (GUILayout.Button("Push", GUILayout.Width(40))) { v.Push(ObjectDrawerHelper.CreateInstance(selectIndex)); } selectIndex = EditorGUILayout.Popup(selectIndex, ObjectDrawerHelper.SelectTypeNames, GUILayout.Width(80)); EditorGUILayout.EndHorizontal(); } value = v; } EditorGUI.EndDisabledGroup(); return(value); }
public object DrawAndGetNewValue(Type type, object value, DrawInfo draw, FieldInfo field) { EditorGUI.BeginDisabledGroup(!draw.Changeable); if (value == null) { ObjectDrawerHelper.ShowNull(draw.ShowName, type, ref value); } else { var v = (ICollection)value; bool fold = ObjectDrawerHelper.GetAndAddFieldShow_Fold(draw.FieldName); fold = EditorGUILayout.Foldout(fold, draw.ShowName, true); ObjectDrawerHelper.SetAndAddFieldShow_Fold(draw.FieldName, fold); if (fold) { int count = v.Count; int len = count / 10 + 1; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("数量:", GUILayout.Width(60)); EditorGUILayout.LabelField(count.ToString()); EditorGUILayout.EndHorizontal(); object[] array = new object[v.Count]; v.CopyTo(array, 0); for (int i = 0; i < array.Length; i++) { EditorGUILayout.BeginHorizontal(); ObjectDrawerHelper.Tab(); EditorGUILayout.LabelField("Element:", GUILayout.Width(60)); EditorGUILayout.BeginVertical(); string showName = $"{i}"; array[i] = ObjectDrawerHelper.DrawAndGetNewValue(array[i].GetType(), array[i], new DrawInfo() { Changeable = draw.Changeable, NeedDelayed = draw.NeedDelayed, ShowName = showName, ShowNameWidth = len * 5 + 15, IsStatic = false, FieldName = field.Name + $"_{i}" }, field); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(""); if (v.Count > 0) { if (GUILayout.Button("Pop", GUILayout.Width(40))) { type.GetMethod("Pop").Invoke(value, null); } } if (GUILayout.Button("Push", GUILayout.Width(40))) { type.GetMethod("Push").Invoke(value, new object[1] { ObjectDrawerHelper.CreateInstance(type.GetGenericArguments()[0]) }); } EditorGUILayout.EndHorizontal(); } value = v; } EditorGUI.EndDisabledGroup(); return(value); }
public object DrawAndGetNewValue(Type type, object value, DrawInfo draw, FieldInfo field) { EditorGUI.BeginDisabledGroup(!draw.Changeable); if (value == null) { ObjectDrawerHelper.ShowNull(draw.ShowName, type, ref value); } else { var v = (IDictionary)value; bool fold = ObjectDrawerHelper.GetAndAddFieldShow_Fold(draw.FieldName); fold = EditorGUILayout.Foldout(fold, draw.ShowName, true); ObjectDrawerHelper.SetAndAddFieldShow_Fold(draw.FieldName, fold); if (fold) { int count = v.Count; int len = count / 10 + 1; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("数量:", GUILayout.Width(60)); EditorGUILayout.LabelField(count.ToString()); EditorGUILayout.EndHorizontal(); List <object> keys = new List <object>(); List <object> values = new List <object>(); keys.Clear(); foreach (var item in v.Keys) { keys.Add(item); } values.Clear(); foreach (var item in v.Values) { values.Add(item); } for (int i = 0; i < keys.Count; i++) { EditorGUILayout.BeginHorizontal(); ObjectDrawerHelper.Tab(); EditorGUILayout.LabelField("Element:", GUILayout.Width(60)); string showName = $"{i}"; EditorGUILayout.LabelField(showName, GUILayout.Width(len * 5 + 15)); EditorGUILayout.BeginVertical(); keys[i] = ObjectDrawerHelper.DrawAndGetNewValue(keys[i].GetType(), keys[i], new DrawInfo() { Changeable = draw.Changeable, NeedDelayed = draw.NeedDelayed, ShowName = "Key:", ShowNameWidth = 30, IsStatic = false, FieldName = field.Name + $"_{i}_Key" }, field); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); values[i] = ObjectDrawerHelper.DrawAndGetNewValue(values[i].GetType(), values[i], new DrawInfo() { Changeable = draw.Changeable, NeedDelayed = draw.NeedDelayed, ShowName = "Value:", ShowNameWidth = 40, IsStatic = false, FieldName = field.Name + $"_{i}_Value" }, field); EditorGUILayout.EndVertical(); if (!v.IsFixedSize) { if (GUILayout.Button("x", GUILayout.Width(20))) { keys.RemoveAt(i); values.RemoveAt(i); EditorGUILayout.EndHorizontal(); break; } } EditorGUILayout.EndHorizontal(); } v.Clear(); for (int i = 0; i < keys.Count; i++) { v.Add(keys[i], values[i]); } if (!v.IsFixedSize) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(""); if (GUILayout.Button("+", GUILayout.Width(20))) { AddOne(ref v); } EditorGUILayout.EndHorizontal(); } } value = v; } EditorGUI.EndDisabledGroup(); return(value); }