- Home /
Custom editor window for properties with object fields; how do you save?
I've been looking at other answers related but I don't feel that I've found the answer for my needs yet.
I'm trying to emulate what unity project settings do with my own custom project settings page.
So far I have an EditorWindow that acts as a project properties page. I need to retain the object link of _myAsset even if I close unity, run, or close the window. I'm just not sure the best way to store this information, even if my window were accessing some other global instance of the data. I've looked at editor preferences. Ideally this would work like the PlayerSettings built into Unity and have an asset on disk for version control. Any recommendations? Here is a simplified example:
public class MyWindow: EditorWindow
{
[MenuItem("MyWindowMenu/Setup")]
public static void ShowWindow()
{
EditorWindow.GetWindow(typeof(BuildConfiguration));
}
MyCustomAsset _myAsset = null;
void OnGUI()
{
_myAsset = (EditorGUILayout.ObjectField("My Custom Asset", _myAsset , typeof(MyCustomAsset) )) as MyCustomAsset;
}
}
Your answer
Follow this Question
Related Questions
How do I have an EditorWindow save it's data inbetween opening and closing Unity? C# 5 Answers
How to call functions in an editor window at runtime 0 Answers
Organizing Recursive EditorGUI elements 1 Answer
Create editor window with ScriptableObject.CreateInstance 4 Answers
Save EditorWindow preferences to class 0 Answers