Question by
danielcooke96 · Feb 03, 2019 at 09:50 PM ·
editorsceneprefabseditorwindow
Open PrefabEditor from script
Does anyone know if the API has been updated to allow us to open the new PrefabEditor introduced in 2018.3 programatically?
I wish to create an EditorWindow to edit properties of my objects (along with their prefabs) in one unified place.
I've tried PrefabUtility with Preview Rooms
Scene roomPreview =
EditorSceneManager.NewPreviewScene();
PrefabUtility.LoadPrefabContentsIntoPreviewScene("Assets/Resources/Rooms/Starting
Room.prefab", roomPreview);
But it doesn't do anything
Comment
Answer by vkalaikkovan · Dec 02, 2019 at 01:44 PM
Please try the below lines to open the prefab in preview scene
Type t = typeof(UnityEditor.Experimental.SceneManagement.PrefabStageUtility);
MethodInfo mi = t.GetMethods(BindingFlags.NonPublic | BindingFlags.Public |BindingFlags.Static).Single(m => m.Name == "OpenPrefab" && m.GetParameters().Length == 1
&& m.GetParameters()[0].ParameterType == typeof(string) );
mi.Invoke(null, new object[] {"Prefab File path"});
Your answer
Follow this Question
Related Questions
How to create a curve editor? 0 Answers
How to change the text of EditorGUILayout.TextField 2 Answers
How do i fix my problem with minimizing/maximizing and just opening unity editor windows? 0 Answers
Is there an easy way to see which GameObjects Prefabs belong to in the editor? 1 Answer
Custom Editor Textarea cursor position 0 Answers