private void InspectorWindow(int id) { try { GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { GUILayout.BeginHorizontal(GUI.skin.box, GUILayout.ExpandWidth(true)); { GUILayout.Label("Filter:", GUILayout.ExpandWidth(false)); GUI.SetNextControlName(SearchBoxName); _searchString = GUILayout.TextField(_searchString, GUILayout.ExpandWidth(true)); if (_focusSearchBox) { GUI.FocusWindow(id); GUI.FocusControl(SearchBoxName); _focusSearchBox = false; } GUILayout.Label("Find:", GUILayout.ExpandWidth(false)); foreach (var obj in new[] { new KeyValuePair <object, string>( EditorUtilities.GetInstanceClassScanner().OrderBy(x => x.Name()), "Instances"), new KeyValuePair <object, string>(EditorUtilities.GetComponentScanner().OrderBy(x => x.Name()), "Components"), new KeyValuePair <object, string>( EditorUtilities.GetMonoBehaviourScanner().OrderBy(x => x.Name()), "MonoBehaviours"), new KeyValuePair <object, string>(EditorUtilities.GetTransformScanner().OrderBy(x => x.Name()), "Transforms") // new KeyValuePair<object, string>(GetTypeScanner(_inspectorStack.Peek().GetType()).OrderBy(x=>x.Name()), _inspectorStack.Peek().GetType().ToString()+"s"), }) { if (obj.Key == null) { continue; } if (GUILayout.Button(obj.Value, GUILayout.ExpandWidth(false))) { InspectorClear(); InspectorPush(new InstanceStackEntry(obj.Key, obj.Value)); } } } GUILayout.EndHorizontal(); GUILayout.Space(6); GUILayout.BeginHorizontal(GUI.skin.box, GUILayout.Width(160)); { if (GUILayout.Button("Help")) { InspectorPush(InspectorHelpObject.Create()); } if (GUILayout.Button("Close")) { InspectorClear(); } } GUILayout.EndHorizontal(); } GUILayout.EndHorizontal(); _inspectorStackScrollPos = GUILayout.BeginScrollView(_inspectorStackScrollPos, true, false, GUI.skin.horizontalScrollbar, GUIStyle.none, GUIStyle.none, GUILayout.Height(46)); { GUILayout.BeginHorizontal(GUI.skin.box, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false)); foreach (var item in _inspectorStack.Reverse().ToArray()) { if (GUILayout.Button(item.Name, GUILayout.ExpandWidth(false))) { while (_inspectorStack.Peek() != item) { InspectorPop(); } return; } } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.BeginVertical(GUI.skin.box); { GUILayout.BeginHorizontal(); { GUILayout.Space(1); GUILayout.Label("Value/return type", GUI.skin.box, _inspectorTypeWidth); GUILayout.Space(2); GUILayout.Label("Member name", GUI.skin.box, _inspectorNameWidth); GUILayout.Space(1); GUILayout.Label("Value", GUI.skin.box, GUILayout.ExpandWidth(true)); } GUILayout.EndHorizontal(); DrawContentScrollView(); } GUILayout.EndVertical(); } GUILayout.EndVertical(); } catch (Exception ex) { RuntimeUnityEditorCore.Logger.Log(LogLevel.Error, "[Inspector] GUI crash: " + ex); InspectorClear(); } GUI.DragWindow(); }
private void InspectorWindow(int id) { try { GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { GUILayout.BeginHorizontal(GUI.skin.box, GUILayout.ExpandWidth(true)); { GUILayout.Label("Filter:", GUILayout.ExpandWidth(false)); GUI.SetNextControlName(SearchBoxName); SearchString = GUILayout.TextField(SearchString, GUILayout.ExpandWidth(true)); if (_focusSearchBox) { GUI.FocusWindow(id); GUI.FocusControl(SearchBoxName); _focusSearchBox = false; } GUILayout.Label("Find:", GUILayout.ExpandWidth(false)); foreach (var obj in new[] { new KeyValuePair <object, string>( EditorUtilities.GetInstanceClassScanner().OrderBy(x => x.Name()), "Instances"), new KeyValuePair <object, string>(EditorUtilities.GetComponentScanner().OrderBy(x => x.Name()), "Components"), new KeyValuePair <object, string>( EditorUtilities.GetMonoBehaviourScanner().OrderBy(x => x.Name()), "MonoBehaviours"), new KeyValuePair <object, string>(EditorUtilities.GetTransformScanner().OrderBy(x => x.Name()), "Transforms") // new KeyValuePair<object, string>(GetTypeScanner(CurrentTab.InspectorStack.Peek().GetType()).OrderBy(x=>x.Name()), CurrentTab.InspectorStack.Peek().GetType().ToString()+"s"), }) { if (obj.Key == null) { continue; } if (GUILayout.Button(obj.Value, GUILayout.ExpandWidth(false))) { Push(new InstanceStackEntry(obj.Key, obj.Value), true); } } } GUILayout.EndHorizontal(); GUILayout.Space(6); GUILayout.BeginHorizontal(GUI.skin.box, GUILayout.Width(160)); { if (GUILayout.Button("Help")) { Push(InspectorHelpObject.Create(), true); } if (GUILayout.Button("Close")) { Show = false; } } GUILayout.EndHorizontal(); } GUILayout.EndHorizontal(); var currentTab = GetCurrentTab(); var defaultGuiColor = GUI.color; if (_tabs.Count >= 2) { _tabScrollPos = GUILayout.BeginScrollView(_tabScrollPos, false, false, GUI.skin.horizontalScrollbar, GUIStyle.none, GUIStyle.none); //, GUILayout.Height(46) { GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false)); for (var index = 0; index < _tabs.Count; index++) { var tab = _tabs[index]; if (currentTab == tab) { GUI.color = Color.cyan; } if (GUILayout.Button($"Tab {index + 1}: {LimitStringLengthForPreview(tab?.CurrentStackItem?.Name, 18)}", GUILayout.ExpandWidth(false))) { if (IsContextClick()) { RemoveTab(tab); } else { _currentTab = tab; } GUI.color = defaultGuiColor; break; } GUI.color = defaultGuiColor; } GUILayout.FlexibleSpace(); GUI.color = new Color(1, 1, 1, 0.6f); if (GUILayout.Button("Close all")) { _tabs.Clear(); _currentTab = null; } GUI.color = defaultGuiColor; GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); } if (currentTab != null) { currentTab.InspectorStackScrollPos = GUILayout.BeginScrollView(currentTab.InspectorStackScrollPos, false, false, GUI.skin.horizontalScrollbar, GUIStyle.none, GUIStyle.none); //, GUILayout.Height(46) { GUILayout.BeginHorizontal(GUI.skin.box, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false)); var stackEntries = currentTab.InspectorStack.Reverse().ToArray(); for (var i = 0; i < stackEntries.Length; i++) { var item = stackEntries[i]; if (i + 1 == stackEntries.Length) { GUI.color = Color.cyan; } if (GUILayout.Button(LimitStringLengthForPreview(item.Name, 90), GUILayout.ExpandWidth(false))) { currentTab.PopUntil(item); GUI.color = defaultGuiColor; return; } if (i + 1 < stackEntries.Length) { GUILayout.Label(">", GUILayout.ExpandWidth(false)); } GUI.color = defaultGuiColor; } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.BeginVertical(GUI.skin.box); { GUILayout.BeginHorizontal(); { GUILayout.Space(1); GUILayout.Label("Value/return type", GUI.skin.box, _inspectorTypeWidth); GUILayout.Space(2); GUILayout.Label("Member name", GUI.skin.box, _inspectorNameWidth); GUILayout.Space(1); GUILayout.Label("Value", GUI.skin.box, GUILayout.ExpandWidth(true)); } GUILayout.EndHorizontal(); DrawContentScrollView(currentTab); } GUILayout.EndVertical(); } else { GUILayout.Label("Nothing to show. Click on objects in the scene browser to open them in a new tab."); GUILayout.Label("Tip: You can right click on a member inside inspector to open in a new tab, and on a tab to close it."); GUILayout.FlexibleSpace(); } } GUILayout.EndVertical(); } catch (Exception ex) { RuntimeUnityEditorCore.Logger.Log(LogLevel.Error, "[Inspector] GUI crash: " + ex); //CurrentTab?.Pop(); } GUI.DragWindow(); }