private static bool InspectField(Inspector inspector, string path, ref object data, FieldInfo fieldInfo) { object value = fieldInfo.GetValue(data); bool changed = false; object newValue = null; if (fieldInfo.IsInitOnly || fieldInfo.IsLiteral) { inspector.Inspect(fieldInfo.Name, path + "." + fieldInfo.Name, value, fieldInfo.FieldType); } else { inspector.Inspect(fieldInfo.Name, path + "." + fieldInfo.Name, value, fieldInfo.FieldType, null, v => { changed = true; newValue = v; }); } if (changed) { fieldInfo.SetValue(data, newValue); } return(changed); }
public override bool InspectChildren(Inspector inspector, string path, ref object data, Type type) { var action = data as MulticastDelegate; if (action == null) { return(false); } string targetName = action.Target != null?string.Format("Target[{0}]", action.Target.GetType().Name) : "Target"; inspector.Inspect("Method", path + ".Method", action.Method); inspector.Inspect(targetName, path + ".Target", action.Target); var list = action.GetInvocationList(); for (int index = 0; index < list.Length; ++index) { var subAction = list[index]; if (subAction == action) { continue; } inspector.Inspect(index.ToString(), path + "." + index, subAction); } return(false); }
private static bool InspectField(Inspector inspector, string path, ref object data, FieldInfo fieldInfo, string prefix) { object value = fieldInfo.GetValue(data); FieldInfo info = fieldInfo; bool inwritable = info.IsInitOnly || info.IsLiteral; Type valueType = value != null?value.GetType() : info.FieldType; bool changed = false; object changedvalue = null; var mark = TypeTools.GetAttribute <IMark>(info); if (inwritable) { inspector.Inspect(prefix + fieldInfo.Name, path + "." + fieldInfo.Name, value, valueType, mark); } else { inspector.Inspect(prefix + fieldInfo.Name, path + "." + fieldInfo.Name, value, valueType, mark, v => { changed = true; changedvalue = v; }); } if (changed) { info.SetValue(data, changedvalue); } return(changed); }
public override bool InspectChildren(Inspector inspector, string path, ref object data, Type type) { bool changed = false; var go = data as GameObject; if (go != null) { foreach (Component comp in go.GetComponents <Component>()) { changed |= inspector.Inspect(comp.GetType().Name, path + "." + comp.GetType().Name, comp); } } foreach ( FieldInfo fieldInfo in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)) { changed |= InspectField(inspector, path, ref data, fieldInfo); } foreach ( PropertyInfo propertyInfo in type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { changed |= InspectProperty(inspector, path, ref data, propertyInfo); } return(changed); }
private static bool InspectElement(Inspector inspector, string path, object key, DictionaryGUIState state, Type dictValueType) { object value = state.Get(key); Type valueType = value != null?value.GetType() : dictValueType; string fullName = key != null?key.ToString() : "null"; return(inspector.Inspect(CutName(fullName), path + "." + fullName, value, valueType, null, v => { if (value != v) { state.Set(key, v); } })); }
public override bool InspectChildren(Inspector inspector, string path, ref object data, Type type) { var c = data as IEnumerable; if (c == null) { return(false); } var hashsetValueType = TypeTools.FindGenericParamType(type, typeof(HashSet <>), 0); int i = 0; bool changed = false; foreach (var value in c) { Type valueType = value != null?value.GetType() : hashsetValueType; changed |= inspector.Inspect(i.ToString(), path + "." + i, value, valueType); ++i; } return(changed); }
private static bool InspectProperty(Inspector inspector, string path, ref object data, PropertyInfo propertyInfo) { if (propertyInfo.CanRead && CanInspect(propertyInfo)) { object value; try { value = propertyInfo.GetValue(data, null); } catch (Exception) { return(false); } return(inspector.Inspect(propertyInfo.Name, path + "." + propertyInfo.Name, value)); } else { GUITools.LabelField(propertyInfo.Name, "unreadable"); return(false); } }
public override bool InspectChildren(Inspector inspector, string path, ref object data, Type type) { var curTable = data as LuaTable; if (curTable == null) { return(false); } var _tables = _SpawnDict(); var _funs = _SpawnDict(); var _others = _SpawnDict(); var enumerator = curTable.ToDictTable().GetEnumerator(); while (enumerator.MoveNext()) { var pair = enumerator.Current; if (pair.Value is LuaTable) { _tables.Add(pair.Key, pair.Value); } else if (pair.Value is LuaFunction) { _funs.Add(pair.Key, pair.Value); } else { _others.Add(pair.Key, pair.Value); } } enumerator.Dispose(); var e = _tables.GetEnumerator(); while (e.MoveNext()) { inspector.Inspect(e.Current.Key.ToString(), path + "." + e.Current.Key, e.Current.Value); } var metatable = curTable.GetMetaTable(); if (metatable != null) { inspector.Inspect(".metatable", path + "." + ".metatable", metatable); } e = _others.GetEnumerator(); while (e.MoveNext()) { var pair = e.Current; inspector.Inspect(pair.Key.ToString(), path + "." + pair.Key, pair.Value, null, null, (v) => _SetTableValue(curTable, pair.Key, v)); } e = _funs.GetEnumerator(); while (e.MoveNext()) { EditorGUILayout.LabelField(e.Current.Key.ToString(), "LuaFunction"); } _RecycleDict(_tables); _RecycleDict(_others); _RecycleDict(_funs); return(false); }