- Home /
Question by
metinevren · Feb 04, 2019 at 04:02 PM ·
prefabeditorwindow
Editor Window does not save prefab changes
I made a custom editor window. I drag my prefab to the object field. When I type in new value for "someVariable" in the IntField, it changes in the editor window but not saved to the prefab. I'm using 2018.3.4f1. Prefab system is changed but I don't know how update my code.
public class WavemachineEditorWindow : EditorWindow
{
private Wavemachine wavemachine;
void OnGUI()
{
wavemachine = (Wavemachine)EditorGUILayout.ObjectField(wavemachine, typeof(Wavemachine), false);
wavemachine.someVariable = EditorGUILayout.IntField("Some Variable", wavemachine.someVariable);
if (GUI.changed)
{
EditorUtility.SetDirty(wavemachine);
}
}
}
Comment
Have you tried using this? https://docs.unity3d.com/ScriptReference/PrefabUtility.html
Never actually used it myself but it looks like the right tool for the job.
Your answer
Follow this Question
Related Questions
Can't activate a prefab from an EditorWindow ? 0 Answers
reconnect programmatically instantiated prefab 1 Answer
Viewpport for Custom Editor 1 Answer
Open scene and load prefab 1 Answer