public static void Backup(Action <MonoScript> onCreateScript) { if (_instance == null) { _instance = ScriptableObject.CreateInstance <AddScriptWindow>(); } _instance.CreateScriptDelegate = onCreateScript; if (AddScriptWindowBackup.Instance.addAsset) { var script = AssetDatabase.LoadAssetAtPath <MonoScript>(AddScriptWindowBackup.Instance.scriptPath); if (script.GetClass() == null) { return; } _instance.CreateScriptDelegate(script); AddScriptWindowBackup.Instance.Reset(); } }
public static void Show(Action <MonoScript> onCreateScript, Func <MonoScript, bool> onFilerScript, string templatePath) { if (_instance == null) { _instance = ScriptableObject.CreateInstance <AddScriptWindow>(); } EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUIStyle style = new GUIStyle(GUI.skin.button); style.fontSize = 12; style.fixedWidth = 230; style.fixedHeight = 23; var rect = GUILayoutUtility.GetLastRect(); var hasAssetToAdd = HasAssetToAdd(); EditorGUI.BeginDisabledGroup(hasAssetToAdd); if (GUILayout.Button("Add Behaviour", style)) { rect.y += 26f; rect.x += rect.width; rect.width = style.fixedWidth; _instance.Init(rect, onCreateScript, onFilerScript, templatePath); _instance.Repaint(); } EditorGUI.EndDisabledGroup(); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (hasAssetToAdd) { Backup(onCreateScript); } }