- Home /
Cannot close Preview Scene
Hi, I'm trying to make custom editor with gameObject preview. I've found OnPreviewGUI and OnInteractivePreviewGUI methods. They work fine, but after creating the Editor object like in the documentation:
test = EditorGUILayout.ObjectField("Test object", test, typeof(GameObject), true) as GameObject;
if (test != null)
{
if (testEditor == null)
testEditor = Editor.CreateEditor(test);
testEditor.OnPreviewGUI(GUILayoutUtility.GetRect(position.width, 200), EditorStyles.whiteLabel);
}
If I change or update the gameObject, preview doesn't updates. I've found out that if I create new Editor after every change, the preview updates, but it creates new Preview scene without destroying or unloading the previous one. Because of that if I call Debug.Log(EditorSceneManager.previewSceneCount);
the count of preview scenes increases after every change and quickly exceedes max count of 100 scenes.
Is there any way to unload preview scenes, or update PreviewGUI without creating the new one?
Screen shot of my custom editor window:
Your answer
Follow this Question
Related Questions
OnInteractivePreviewGUI multiple selection. Works but spams errors. 0 Answers
GetPropertyHeight infinite recursion on drawer 1 Answer
Can I name a game object's components (in the editor)? 2 Answers
What is the best way to draw icons in Unity's Hierarchy window? 1 Answer
Setting custom amount of space between elements in a custom inspector with EditorGUILayout ? 1 Answer