Skip to content

Instantly share code, notes, and snippets.

@st0326s
Created March 6, 2014 04:37
Show Gist options
  • Save st0326s/9382756 to your computer and use it in GitHub Desktop.
Save st0326s/9382756 to your computer and use it in GitHub Desktop.
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