Created
March 6, 2014 04:37
-
-
Save st0326s/9382756 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reflection; | |
using UnityEditor; | |
using UnityEngine; | |
[InitializeOnLoad] | |
public class HierarchyObjectSize | |
{ | |
static HierarchyObjectSize () | |
{ | |
EditorApplication.hierarchyWindowItemOnGUI += (instanceID,rect) => { | |
DisplaySize (instanceID, rect); | |
}; | |
} | |
static void DisplaySize (int instanceID, Rect rect) | |
{ | |
rect.x += rect.width - 50; | |
rect.width = 50; | |
GameObject go = (GameObject)EditorUtility.InstanceIDToObject (instanceID); | |
int bytes; | |
try | |
{ | |
bytes = Profiler.GetRuntimeMemorySize (go); | |
} | |
catch | |
{ | |
bytes = -1; | |
} | |
string text = EditorUtility.FormatBytes (bytes); | |
GUI.Label (rect, text); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment