コード例 #1
0
 private void DrawFields(ManagedObject managedObject)
 {
     if (managedObject.typeDescription.isArray)
     {
         return;
     }
     GUILayout.Space(10);
     GUILayout.Label("Fields:");
     DrawFields(managedObject.typeDescription, _unpackedCrawl.managedHeap.Find(managedObject.address, _unpackedCrawl.virtualMachineInformation));
 }
コード例 #2
0
ファイル: TreeMapView.cs プロジェクト: vinhphu3000/mg01
        private string DumpFields(ManagedObject managedObject)
        {
            var str = new StringBuilder();

            if (managedObject.typeDescription.isArray)
            {
                return("");
            }
            str.AppendLine("\t\tFields:");
            str.Append(DumpFields(managedObject.typeDescription, _unpackedCrawl.managedHeap.Find(managedObject.address, _unpackedCrawl.virtualMachineInformation)));
            return(str.ToString());
        }
コード例 #3
0
        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();
        }