public void OnPreferencesGUI()
        {
            unfolded = EditorGUILayout.Foldout(unfolded, new GUIContent(propertyName));
            if (!unfolded)
            {
                return;
            }
            templateCode.Value = EditorGUILayout.TextArea(templateCode.Value);

            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Load from file"))
                {
                    string filePath = EditorUtility.OpenFilePanelWithFilters("Load script template file for " + propertyName, ScriptTemplatePreferences.ScriptTemplateDefaultPath.Value, new[] { "FileType", "txt,cs" });
                    if (!filePath.Equals(string.Empty))
                    {
                        ScriptTemplatePreferences.SaveDefaultPathFromFilePath(filePath);
                        templateCode.Value = File.ReadAllText(filePath);
                        UpdateLineEnding();
                    }
                }

                if (GUILayout.Button("Save to file"))
                {
                    string filePath = EditorUtility.SaveFilePanel("Save script template", ScriptTemplatePreferences.ScriptTemplateDefaultPath.Value, propertyName + "Template", "txt");
                    if (!filePath.Equals(string.Empty))
                    {
                        ScriptTemplatePreferences.SaveDefaultPathFromFilePath(filePath);
                        UpdateLineEnding();
                        WriteToFile(templateCode.Value, filePath);
                        AssetDatabase.Refresh();
                    }
                }

                if (GUILayout.Button("Reset"))
                {
                    GUI.FocusControl(null);
                    templateCode.DeleteKey();
                }
            }

            EditorGUILayout.EndHorizontal();
        }
 public static void OnPreferencesGUI()
 {
     AssemblyProcessorPreferences.OnPreferencesGUI();
     ScriptTemplatePreferences.OnPreferencesGUI();
     GUILayout.FlexibleSpace();
 }
예제 #3
0
 public static void OnPreferencesGUI()
 {
     ScriptTemplatePreferences.OnPreferencesGUI();
     GUILayout.FlexibleSpace();
 }