public void Draw() { float NavAreaHeight = 40.0f; if (_hostWindow.EnhancedMode) { GUILayout.BeginArea(new Rect(_hostWindow.position.width - MemConst.InspectorWidth, MemConst.TopBarHeight, MemConst.InspectorWidth, NavAreaHeight)); GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Space(3); GUI.enabled = Instance.TryGetPrev() != null; if (GUILayout.Button(new GUIContent("Back", _textureBack), GUILayout.MinWidth(100), GUILayout.MaxHeight(25))) { ThingInMemory prev = Instance.MovePrev(); if (prev != null) { _hostWindow.SelectThing(prev); } } GUI.enabled = Instance.TryGetNext() != null; if (GUILayout.Button(new GUIContent("Forward", _textureForward), GUILayout.MinWidth(100), GUILayout.MaxHeight(25))) { ThingInMemory next = Instance.MoveNext(); if (next != null) { _hostWindow.SelectThing(next); } } GUI.enabled = true; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndArea(); } float topSpace = MemConst.TopBarHeight + (_hostWindow.EnhancedMode ? NavAreaHeight : 0); GUILayout.BeginArea(new Rect(_hostWindow.position.width - MemConst.InspectorWidth, topSpace, MemConst.InspectorWidth, _hostWindow.position.height - topSpace)); _scrollPosition = GUILayout.BeginScrollView(_scrollPosition); if (_selectedThing == null) { GUILayout.Label("Select an object to see more info"); } else { var nativeObject = _selectedThing as NativeUnityEngineObject; if (nativeObject != null) { GUILayout.Label("NativeUnityEngineObject", EditorStyles.boldLabel); GUILayout.Space(5); EditorGUILayout.LabelField("Name", nativeObject.name); EditorGUILayout.LabelField("ClassName", nativeObject.className); EditorGUILayout.LabelField("ClassID", nativeObject.classID.ToString()); EditorGUILayout.LabelField("instanceID", nativeObject.instanceID.ToString()); EditorGUILayout.LabelField("isDontDestroyOnLoad", nativeObject.isDontDestroyOnLoad.ToString()); EditorGUILayout.LabelField("isPersistent", nativeObject.isPersistent.ToString()); EditorGUILayout.LabelField("isManager", nativeObject.isManager.ToString()); EditorGUILayout.LabelField("hideFlags", nativeObject.hideFlags.ToString()); EditorGUILayout.LabelField("hideFlags", nativeObject.size.ToString()); DrawSpecificTexture2D(nativeObject); } var managedObject = _selectedThing as ManagedObject; if (managedObject != null) { GUILayout.Label("ManagedObject"); EditorGUILayout.LabelField("Type", managedObject.typeDescription.name); EditorGUILayout.LabelField("Address", managedObject.address.ToString("X")); EditorGUILayout.LabelField("size", managedObject.size.ToString()); if (managedObject.typeDescription.name == "System.String") { EditorGUILayout.LabelField("value", StringTools.ReadString(_unpackedCrawl.managedHeap.Find(managedObject.address, _unpackedCrawl.virtualMachineInformation), _unpackedCrawl.virtualMachineInformation)); } DrawFields(managedObject); if (managedObject.typeDescription.isArray) { DrawArray(managedObject); } } if (_selectedThing is GCHandle) { GUILayout.Label("GCHandle"); EditorGUILayout.LabelField("size", _selectedThing.size.ToString()); } var staticFields = _selectedThing as StaticFields; if (staticFields != null) { GUILayout.Label("Static Fields"); GUILayout.Label("Of type: " + staticFields.typeDescription.name); GUILayout.Label("size: " + staticFields.size); DrawFields(staticFields.typeDescription, new BytesAndOffset() { bytes = staticFields.typeDescription.staticFieldBytes, offset = 0, pointerSize = _unpackedCrawl.virtualMachineInformation.pointerSize }, true); } if (managedObject == null) { GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("References:", labelWidth); GUILayout.BeginVertical(); DrawLinks(_selectedThing.references); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } GUILayout.Space(10); GUILayout.Label("Referenced by:"); DrawLinks(_selectedThing.referencedBy); GUILayout.Space(10); if (_shortestPath != null) { if (_shortestPath.Length > 1) { GUILayout.Label("ShortestPathToRoot"); DrawLinks(_shortestPath); } string reason; _shortestPathToRootFinder.IsRoot(_shortestPath.Last(), out reason); GUILayout.Label("This is a root because:"); GUILayout.TextArea(reason); } else { GUILayout.TextArea("No root is keeping this object alive. It will be collected next UnloadUnusedAssets() or scene load"); } } GUILayout.TextArea(GetSelectedDebugInfo(), GUILayout.MinHeight(300f)); GUILayout.EndScrollView(); GUILayout.EndArea(); }
public string DumpDetailInffo(ThingInMemory _selectedThing) { _shortestPath = _shortestPathToRootFinder.FindFor(_selectedThing); var str = new StringBuilder(); var nativeObject = _selectedThing as NativeUnityEngineObject; if (nativeObject != null) { str.AppendFormat("\t{0}\n", "NativeUnityEngineObject"); str.AppendFormat("\t\tName:{0}\n", nativeObject.name); str.AppendFormat("\t\tClassName:{0}\n", nativeObject.className); str.AppendFormat("\t\tClassID:{0}\n", nativeObject.classID.ToString()); str.AppendFormat("\t\tInstanceID:{0}\n", nativeObject.instanceID.ToString()); str.AppendFormat("\t\tIsDontDestroyOnLoad:{0}\n", nativeObject.isDontDestroyOnLoad.ToString()); str.AppendFormat("\t\tIsPersistent:{0}\n", nativeObject.isPersistent.ToString()); str.AppendFormat("\t\tIsManager:{0}\n", nativeObject.isManager.ToString()); str.AppendFormat("\t\tHideFlags:{0}\n", nativeObject.hideFlags.ToString()); str.AppendFormat("\t\tSize:{0}\n", nativeObject.size.ToString()); } var managedObject = _selectedThing as ManagedObject; if (managedObject != null) { str.AppendLine("\tManagedObject"); str.AppendFormat("\t\tType:{0}\n", managedObject.typeDescription.name); str.AppendFormat("\t\tAddress:{0}\n", managedObject.address.ToString("X")); str.AppendFormat("\t\tsize:{0}\n", managedObject.size.ToString()); if (managedObject.typeDescription.name == "System.String") { str.AppendFormat("\t\tvalue{0}\n", StringTools.ReadString(_unpackedCrawl.managedHeap.Find(managedObject.address, _unpackedCrawl.virtualMachineInformation), _unpackedCrawl.virtualMachineInformation)); } str.Append(DumpFields(managedObject)); //if (managedObject.typeDescription.isArray) //{ // DrawArray(managedObject); //} } if (_selectedThing is GCHandle) { str.AppendLine("\tGCHandle"); str.AppendFormat("\t\tsize{0}\n", _selectedThing.size.ToString()); } var staticFields = _selectedThing as StaticFields; if (staticFields != null) { str.AppendLine("\tStatic Fields"); str.AppendFormat("\t\tOf type: {0}\n", staticFields.typeDescription.name); str.AppendFormat("\t\tsize: {0}\n", staticFields.size); str.Append(DumpFields(staticFields.typeDescription, new BytesAndOffset() { bytes = staticFields.typeDescription.staticFieldBytes, offset = 0, pointerSize = _unpackedCrawl.virtualMachineInformation.pointerSize }, true)); } if (managedObject == null) { str.AppendLine("\t***References:"); str.Append(DumpLinks(_selectedThing.references)); } str.AppendLine("\t***Referenced by:"); str.Append(DumpLinks(_selectedThing.referencedBy)); GUILayout.Space(10); if (_shortestPath != null) { if (_shortestPath.Length > 1) { str.AppendLine("\t***ShortestPathToRoot"); str.Append(DumpLinks(_shortestPath)); } string reason; _shortestPathToRootFinder.IsRoot(_shortestPath.Last(), out reason); str.AppendLine("\tThis is a root because:" + reason); } else { str.AppendLine("\tNo root is keeping this object alive. It will be collected next UnloadUnusedAssets() or scene load"); } return(str.ToString()); }
internal void Draw() { GUILayout.BeginArea(new Rect(_hostWindow.position.width - width, _hostWindow.topMargin, width, _hostWindow.position.height - _hostWindow.topMargin)); _scrollPosition = GUILayout.BeginScrollView(_scrollPosition); GUILayout.BeginHorizontal(); GUI.enabled = _backSelected.Count > 1; if (GUILayout.Button(string.Format("Back ({0})", Math.Max(0, _backSelected.Count - 1)))) { _backSelected.Pop(); if (_nextSelected.Count == 0 || _backSelected.Peek() != _nextSelected.Peek()) { _nextSelected.Push(_backSelected.Peek()); } _hostWindow.SelectThing(_backSelected.Peek()); } GUI.enabled = true; GUI.enabled = _nextSelected.Count > 1; if (GUILayout.Button(string.Format("Next ({0})", Math.Max(0, _nextSelected.Count - 1)))) { _nextSelected.Pop(); _hostWindow.SelectThing(_nextSelected.Peek()); } GUI.enabled = true; GUILayout.EndHorizontal(); if (_unpackedCrawl != null) { GUILayout.Label(string.Format("Total memory: {0}", EditorUtility.FormatBytes(_unpackedCrawl.totalSize))); } if (_selectedThing == null) { GUILayout.Label("Select an object to see more info"); } else { NativeUnityEngineObject nativeObject = _selectedThing as NativeUnityEngineObject; if (nativeObject != null) { GUILayout.Label("NativeUnityEngineObject", EditorStyles.boldLabel); GUILayout.Space(5); EditorGUILayout.LabelField("Name", nativeObject.name); EditorGUILayout.LabelField("ClassName", nativeObject.className); EditorGUILayout.LabelField("Memory amount", EditorUtility.FormatBytes(_selectedThing.size)); EditorGUILayout.LabelField("instanceID", nativeObject.instanceID.ToString()); EditorGUILayout.LabelField("isDontDestroyOnLoad", nativeObject.isDontDestroyOnLoad.ToString()); EditorGUILayout.LabelField("isPersistent", nativeObject.isPersistent.ToString()); EditorGUILayout.LabelField("isManager", nativeObject.isManager.ToString()); EditorGUILayout.LabelField("hideFlags", nativeObject.hideFlags.ToString()); DrawSpecificTexture2D(nativeObject); } ManagedObject managedObject = _selectedThing as ManagedObject; if (managedObject != null) { GUILayout.Label("ManagedObject"); EditorGUILayout.LabelField("Type", managedObject.typeDescription.name); EditorGUILayout.LabelField("Address", managedObject.address.ToString("X")); EditorGUILayout.LabelField("size", managedObject.size.ToString()); if (managedObject.typeDescription.name == "System.String") { EditorGUILayout.LabelField("value", StringTools.ReadString(_unpackedCrawl.managedHeap.Find(managedObject.address, _unpackedCrawl.virtualMachineInformation), _unpackedCrawl.virtualMachineInformation)); } DrawFields(managedObject); if (managedObject.typeDescription.isArray) { DrawArray(managedObject); } } if (_selectedThing is GCHandle) { GUILayout.Label("GCHandle"); EditorGUILayout.LabelField("size", _selectedThing.size.ToString()); } StaticFields staticFields = _selectedThing as StaticFields; if (staticFields != null) { GUILayout.Label("Static Fields"); GUILayout.Label("Of type: " + staticFields.typeDescription.name); GUILayout.Label("size: " + staticFields.size); DrawFields(staticFields.typeDescription, new BytesAndOffset() { bytes = staticFields.typeDescription.staticFieldBytes, offset = 0, pointerSize = _unpackedCrawl.virtualMachineInformation.pointerSize }, true); } if (managedObject == null) { GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("References:", labelWidth); GUILayout.BeginVertical(); DrawLinks(_selectedThing.references); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } GUILayout.Space(10); GUILayout.Label("Referenced by:"); DrawLinks(_selectedThing.referencedBy); GUILayout.Space(10); if (_shortestPath != null) { if (_shortestPath.Length > 1) { GUILayout.Label("ShortestPathToRoot"); DrawLinks(_shortestPath); } string reason; _shortestPathToRootFinder.IsRoot(_shortestPath.Last(), out reason); GUILayout.Label("This is a root because:"); GUILayout.TextArea(reason); } else { GUILayout.TextArea("No root is keeping this object alive. It will be collected next UnloadUnusedAssets() or scene load"); } } GUILayout.EndScrollView(); GUILayout.EndArea(); }
public void Draw() { GUILayout.BeginArea(new Rect(_hostWindow.position.width - s_InspectorWidth, 25, s_InspectorWidth, _hostWindow.position.height - 25f)); _scrollPosition = GUILayout.BeginScrollView(_scrollPosition); if (_selectedThing == null) { GUILayout.Label("Select an object to see more info"); } else { var nativeObject = _selectedThing as NativeUnityEngineObject; if (nativeObject != null) { GUILayout.Label("NativeUnityEngineObject", EditorStyles.boldLabel); GUILayout.Space(5); EditorGUILayout.LabelField("Name", nativeObject.name); EditorGUILayout.LabelField("ClassName", nativeObject.className); EditorGUILayout.LabelField("ClassID", nativeObject.classID.ToString()); EditorGUILayout.LabelField("instanceID", nativeObject.instanceID.ToString()); EditorGUILayout.LabelField("isDontDestroyOnLoad", nativeObject.isDontDestroyOnLoad.ToString()); EditorGUILayout.LabelField("isPersistent", nativeObject.isPersistent.ToString()); EditorGUILayout.LabelField("isManager", nativeObject.isManager.ToString()); EditorGUILayout.LabelField("hideFlags", nativeObject.hideFlags.ToString()); EditorGUILayout.LabelField("hideFlags", nativeObject.size.ToString()); DrawSpecificTexture2D(nativeObject); } var managedObject = _selectedThing as ManagedObject; if (managedObject != null) { GUILayout.Label("ManagedObject"); EditorGUILayout.LabelField("Type", managedObject.typeDescription.name); EditorGUILayout.LabelField("Address", managedObject.address.ToString("X")); EditorGUILayout.LabelField("size", managedObject.size.ToString()); if (managedObject.typeDescription.name == "System.String") { EditorGUILayout.LabelField("value", StringTools.ReadString(_unpackedCrawl.managedHeap.Find(managedObject.address, _unpackedCrawl.virtualMachineInformation), _unpackedCrawl.virtualMachineInformation)); } DrawFields(managedObject); if (managedObject.typeDescription.isArray) { DrawArray(managedObject); } } if (_selectedThing is GCHandle) { GUILayout.Label("GCHandle"); EditorGUILayout.LabelField("size", _selectedThing.size.ToString()); } var staticFields = _selectedThing as StaticFields; if (staticFields != null) { GUILayout.Label("Static Fields"); GUILayout.Label("Of type: " + staticFields.typeDescription.name); GUILayout.Label("size: " + staticFields.size); DrawFields(staticFields.typeDescription, new BytesAndOffset() { bytes = staticFields.typeDescription.staticFieldBytes, offset = 0, pointerSize = _unpackedCrawl.virtualMachineInformation.pointerSize }, true); } if (managedObject == null) { GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("References:", labelWidth); GUILayout.BeginVertical(); DrawLinks(_selectedThing.references); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } GUILayout.Space(10); GUILayout.Label("Referenced by:"); DrawLinks(_selectedThing.referencedBy); GUILayout.Space(10); if (_shortestPath != null) { if (_shortestPath.Length > 1) { GUILayout.Label("ShortestPathToRoot"); DrawLinks(_shortestPath); } string reason; _shortestPathToRootFinder.IsRoot(_shortestPath.Last(), out reason); GUILayout.Label("This is a root because:"); GUILayout.TextArea(reason); } else { GUILayout.TextArea("No root is keeping this object alive. It will be collected next UnloadUnusedAssets() or scene load"); } } GUILayout.EndScrollView(); GUILayout.EndArea(); }
public void Draw() { SearchAreaHeight = SearchBarHeight + SearchResultHeight; GUILayout.BeginArea(new Rect(_hostWindow.position.width - s_InspectorWidth, _hostWindow.TopButtonsVerticalSpaces, s_InspectorWidth, SearchAreaHeight)); GUILayout.BeginHorizontal(GUILayout.Height(SearchBarHeight)); string enteredString = GUILayout.TextField(_searchString, 100, GUI.skin.FindStyle("ToolbarSeachTextField"), GUILayout.MinWidth(300)); if (enteredString != _searchString) { _searchResults = _hostWindow.FindThingsByName(enteredString); _searchString = enteredString; } if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSeachCancelButton"))) { // Remove focus if cleared _searchString = ""; GUI.FocusControl(null); _searchResults = null; _searchResultSelected = -1; } GUILayout.EndHorizontal(); if (_searchResults != null && _searchResults.Length > 0) { int selected = 0; selected = EditorGUILayout.Popup( string.Format("Result(s): {0}", _searchResults.Length), _searchResultSelected, _searchResults, GUILayout.Height(SearchResultHeight)); if (_searchResultSelected != selected && selected >= 0) { string fullname = _searchResults[selected]; int index = fullname.IndexOf("/"); if (index != -1) { fullname = fullname.Substring(fullname.IndexOf("/") + 1); } var thing = _hostWindow.FindThingInMemoryByExactName(fullname); if (thing != null) { _hostWindow.SelectThing(thing); _searchResultSelected = selected; } else { Debug.LogErrorFormat("not found in memory: {0}", _searchResults[selected]); } } } GUILayout.EndArea(); float topSpace = _hostWindow.TopButtonsVerticalSpaces + SearchAreaHeight; GUILayout.BeginArea(new Rect(_hostWindow.position.width - s_InspectorWidth, topSpace, s_InspectorWidth, _hostWindow.position.height - topSpace)); _scrollPosition = GUILayout.BeginScrollView(_scrollPosition); if (_selectedThing == null) { GUILayout.Label("Select an object to see more info"); } else { var nativeObject = _selectedThing as NativeUnityEngineObject; if (nativeObject != null) { GUILayout.Label("NativeUnityEngineObject", EditorStyles.boldLabel); GUILayout.Space(5); EditorGUILayout.LabelField("Name", nativeObject.name); EditorGUILayout.LabelField("ClassName", nativeObject.className); EditorGUILayout.LabelField("ClassID", nativeObject.classID.ToString()); EditorGUILayout.LabelField("instanceID", nativeObject.instanceID.ToString()); EditorGUILayout.LabelField("isDontDestroyOnLoad", nativeObject.isDontDestroyOnLoad.ToString()); EditorGUILayout.LabelField("isPersistent", nativeObject.isPersistent.ToString()); EditorGUILayout.LabelField("isManager", nativeObject.isManager.ToString()); EditorGUILayout.LabelField("hideFlags", nativeObject.hideFlags.ToString()); EditorGUILayout.LabelField("hideFlags", nativeObject.size.ToString()); DrawSpecificTexture2D(nativeObject); } var managedObject = _selectedThing as ManagedObject; if (managedObject != null) { GUILayout.Label("ManagedObject"); EditorGUILayout.LabelField("Type", managedObject.typeDescription.name); EditorGUILayout.LabelField("Address", managedObject.address.ToString("X")); EditorGUILayout.LabelField("size", managedObject.size.ToString()); if (managedObject.typeDescription.name == "System.String") { EditorGUILayout.LabelField("value", StringTools.ReadString(_unpackedCrawl.managedHeap.Find(managedObject.address, _unpackedCrawl.virtualMachineInformation), _unpackedCrawl.virtualMachineInformation)); } DrawFields(managedObject); if (managedObject.typeDescription.isArray) { DrawArray(managedObject); } } if (_selectedThing is GCHandle) { GUILayout.Label("GCHandle"); EditorGUILayout.LabelField("size", _selectedThing.size.ToString()); } var staticFields = _selectedThing as StaticFields; if (staticFields != null) { GUILayout.Label("Static Fields"); GUILayout.Label("Of type: " + staticFields.typeDescription.name); GUILayout.Label("size: " + staticFields.size); DrawFields(staticFields.typeDescription, new BytesAndOffset() { bytes = staticFields.typeDescription.staticFieldBytes, offset = 0, pointerSize = _unpackedCrawl.virtualMachineInformation.pointerSize }, true); } if (managedObject == null) { GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("References:", labelWidth); GUILayout.BeginVertical(); DrawLinks(_selectedThing.references); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } GUILayout.Space(10); GUILayout.Label("Referenced by:"); DrawLinks(_selectedThing.referencedBy); GUILayout.Space(10); if (_shortestPath != null) { if (_shortestPath.Length > 1) { GUILayout.Label("ShortestPathToRoot"); DrawLinks(_shortestPath); } string reason; _shortestPathToRootFinder.IsRoot(_shortestPath.Last(), out reason); GUILayout.Label("This is a root because:"); GUILayout.TextArea(reason); } else { GUILayout.TextArea("No root is keeping this object alive. It will be collected next UnloadUnusedAssets() or scene load"); } } GUILayout.TextArea(GetSelectedDebugInfo(), GUILayout.MinHeight(100f)); GUILayout.EndScrollView(); GUILayout.EndArea(); }