- Home /
How can I access the object that the inspector is currently displaying?
User selects an item (in either project or hierarchy)
User locks the inspector
User selects a second item (in either project or hierarchy)
At first, the item being inspected is accessible by using Selection.activeObject. Once the inspector is locked and a second item is selected, then that reference is to the new object, and not the currently inspected object. I cannot figure out how to get the reference to the currently inspected item.
Obviously, this is for an editor only script, so full access to UnityEditor namespace is fine. I need to have both the object being inspected, and the object that is actually selected. The idea behind this is to do some auto assigning of variables between the two via the use of System.Reflection to automate some tasks for my team.
Hey, off the top of my head I think you can get the editor windows and query their type to get all the inspector windows - I remember doing something like this. Found a link that uses this method: link. Or, as a workaround, you could recreate the inspector's functionality in your tool to have full control over both objects. Hope that helps =D
Your answer
Follow this Question
Related Questions
Fold/unfold gameobject from code 4 Answers
Unexpected selection state in custom inspector? 1 Answer
Set the Inspector target in Playmode. 1 Answer
Set inspector lock by code? 2 Answers