private bool InspectRoot(string name, Type type, ref object data, VisualizerBase visualizer, IMark mark) { using (GUITools.HorizontalScope()) { bool changed = visualizer.InspectSelf(this, name, ref data, type); if (type != null && type.IsClass) { if (data != null) { if (GUILayout.Button("-", GUILayout.Width(20))) { data = null; changed = true; } } else { if (GUILayout.Button("+", GUILayout.Width(20))) { data = CreateClassInstance(type, visualizer, mark); changed = true; } } } return(changed); } }
private static void DrawSearchInput(DictionaryGUIState state, Inspector.Options options) { if (state.searchInput == null) { state.searchInput = new SearchInputState(); } if (state.Size() < options.showSearchAtSize) { ClearSearchInput(state); return; } var now = DateTime.Now; SearchInputState input = state.searchInput; using (GUITools.Indent()) { using (GUITools.HorizontalScope()) { var newInput = GUITools.TextField("Search: ", input.text ?? ""); if (newInput != input.text) { input.text = newInput; input.lastTextChange = now; if (input.inputStart.Ticks == 0) { input.inputStart = now; } } else { if (Math.Abs((now - input.lastTextChange).TotalSeconds) > 0.5) { input.inputStart = new DateTime(); } } if (input.text != input.filter && ( input.inputStart.Ticks == 0 || Math.Abs((now - input.lastFilterChange).TotalSeconds) > 1 && Math.Abs((now - input.inputStart).TotalSeconds) > 1 )) { input.changed = true; input.filter = input.text; input.lastFilterChange = DateTime.Now; } else { input.changed = false; } } } }
public bool InspectInternal(string name, string path, object data, Type type = null, IMark mark = null, Action <object> OnValueChanged = null) { if (data != null) { type = data.GetType(); } GUITools.SetLabelWidth(options.labelWidth); VisualizerBase visualizer = GetVisualizer(type, mark); bool changed = false; object changedData = data; if (visualizer != null) { string fieldinfo = name; var postfix = visualizer.GetLabelPostfix(this, data, type); if (postfix != null) { fieldinfo += postfix; } if (visualizer.HasChildren()) { // Note: to avoid infinite expand that may cause by alwaysShowChildren, // If parentAlwaysShowChild, then current node ignores alwaysShowChildren. var parentAlwaysShowChild = parentIsAlwaysShow.Count > 0 && parentIsAlwaysShow.Peek(); bool alwaysShowChildren = !parentAlwaysShowChild && visualizer.AlwaysShowChildren(); if (!alwaysShowChildren) { using (GUITools.HorizontalScope()) { var width = options.labelWidth - options.indentOffset * GUITools.GetIndentLevel(); using (GUITools.HorizontalScope(width)) { isFoldout[path] = GUITools.Foldout(isFoldout.ContainsKey(path) && isFoldout[path], fieldinfo); } changed |= InspectRoot(name, type, ref changedData, visualizer, mark); } } else { changed |= InspectRoot(name, type, ref changedData, visualizer, mark); } if (changedData != null && (alwaysShowChildren || isFoldout[path])) { try { parentIsAlwaysShow.Push(alwaysShowChildren); using (GUITools.Indent()) changed |= visualizer.InspectChildren(this, path, ref changedData, type); } finally { parentIsAlwaysShow.Pop(); } } } else { changed |= InspectRoot(fieldinfo, type, ref changedData, visualizer, mark); } } if (changed && OnValueChanged != null) { OnValueChanged(changedData); } return(changed); }