Skip to content

Instantly share code, notes, and snippets.

@CapitanLiteral
Last active June 24, 2020 12:38
Show Gist options
  • Save CapitanLiteral/2cab003929e754d67e756ea83076a887 to your computer and use it in GitHub Desktop.
Save CapitanLiteral/2cab003929e754d67e756ea83076a887 to your computer and use it in GitHub Desktop.
[MenuItem("Tools/Inspector rename &r")]
public static void InspectorSwitchName()
{
EditorWindow windowToBeLocked = EditorWindow.mouseOverWindow;
if (windowToBeLocked.GetType().ToString().Equals("UnityEditor.InspectorWindow"))
{
if (windowToBeLocked.title != "Inspector")
{
Texture tex = windowToBeLocked.titleContent.image;
windowToBeLocked.title = "Inspector";
windowToBeLocked.titleContent.image = tex;
}
else
{
Texture tex = windowToBeLocked.titleContent.image;
MethodInfo dynMethod = windowToBeLocked.GetType()
.GetMethod("GetInspectedObject", BindingFlags.NonPublic | BindingFlags.Instance);
var inspectedObject = dynMethod.Invoke(windowToBeLocked, null);
windowToBeLocked.title = ((GameObject) inspectedObject).name;
windowToBeLocked.titleContent.image = tex;
}
windowToBeLocked.Repaint();
}
}
@CapitanLiteral
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment