Last active
June 24, 2020 12:38
-
-
Save CapitanLiteral/2cab003929e754d67e756ea83076a887 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
[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(); | |
} | |
} |
Author
CapitanLiteral
commented
Jun 24, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment