- Home /
How to have two inspectors of different types thats objects they are inspecting change
Hi! So I have a custom inspector for a custom serializable object for a game tool I am working on. This game tool has a variable for an animation clip. When an animation clip is selected I call this function:
[CustomEditor(typeof(myCustomObject))]
public class myObjectEditor :Editor{
private EditorWindow myAnimPreview;
public override void OnInspectorGUI(){
if (myCustomObject.myOldAnimationVariable!=myCustomObject.animationVariable){
if(myAnimPreview!=null){
ActiveEditorTrack.sharedTracker.isLocked=false;
myAnimPreview.Close();
}
myCustomObject.myOldAnimationVariable=myCustomObject.animationVariable;
InspectAnimation(myCustomObject.animationVariable);
}
}
public static void InspectAnimation(AnimationClip target){
var InspectorType = typeof(Editor).Assembly.GetType("UnityEditor.InspectorWindow");
myAnimPreview = ScriptableObject.CreateInstance(InspectorType) as EditorWindow;
myAnimPreview.titleContent = new GUIContent ("AnimationPreview");
var previousSelection = Selection.activeObject;
Selection.activeObject = target;
ActiveEditorTrack.sharedTracker.isLocked=true;
myAnimPreview.Show();
Selection.activeObject = previousSelection;
}
}
The above code is resulting in the window for the animation clip inspector popping up white, flickering, and locking up the editor whenever I switch to a second animation(set the animation variable then try to change it). I'm making a rather complex editor tool and I want to be able to use the animation clip preview. I know in order to have the animation clip inspector and the inspector for my custom object open at the same time I have to lock one of them before opening the second one, but I want to be able to change the animation clip that the animation clip inspector inspects. This is my first time trying to lock/unlock a inspector via code. Anyone know why this is locking up my editor?
Your answer
Follow this Question
Related Questions
Set the Rect of PopupWindowContent 1 Answer
Custom Editor like Package Manager 0 Answers
mouseposition and clicks in editor sceneview 0 Answers
How to get notification of moving a GameObject in the hierachy when editing the scene? 1 Answer
Custom Editor - Is there any way to detect whether the user is in Prefab editing mode? 1 Answer