static void Initialize() { UIEditorWindow window = (UIEditorWindow)EditorWindow.GetWindow(typeof(UIEditorWindow), true, "UI"); UIEditorWindowData myInstance = (UIEditorWindowData )Resources.Load("editorWindowData") as UIEditorWindowData; if (myInstance == null) { Debug.Log("Creating new data file"); myInstance = CreateInstance <UIEditorWindowData>(); AssetDatabase.CreateAsset(myInstance, "Assets/Resources/editorWindowData.asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } window.data = myInstance; window.Init(); }
static void InitializeReset() { UIEditorWindow window = (UIEditorWindow)EditorWindow.GetWindow(typeof(UIEditorWindow), true, "UI"); UIEditorWindowData myInstance = (UIEditorWindowData )Resources.Load("editorWindowData") as UIEditorWindowData; window.data = myInstance; window.Init(); //Init the data window.ResetLines(); //Reset lines window.SaveData(); //Save the UIWindows window.Close(); //Close Debug.Log("Creating new data file"); myInstance = CreateInstance <UIEditorWindowData>(); AssetDatabase.CreateAsset(myInstance, "Assets/Resources/editorWindowData.asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); Initialize(); }