private void OnGUI()
        {
            EditorGUILayout.Space();

            _templateName     = EditorGUILayout.TextField("Template Name", _templateName);
            _isEditorTemplate = EditorGUILayout.Toggle("Used for Editor Scripts", _isEditorTemplate);

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Create"))
            {
                var scriptBuilderWindow = TemplateSettingsEditorWindow.ShowWindow();

                scriptBuilderWindow.AddTemplate(_templateName, _isEditorTemplate);

                ExitWindow();
            }

            if (GUILayout.Button("Cancel"))
            {
                ExitWindow();
            }

            EditorGUILayout.EndHorizontal();
        }
Esempio n. 2
0
 static ScriptBuilder()
 {
     if (SessionState.GetBool("SpeedScriptLoaded", false) == false)
     {
         SessionState.SetBool("SpeedScriptLoaded", true);
         TemplateSettingsEditorWindow.RefreshCustomTemplates();
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Looks for a Template in the external UserData Folder and creates a script from it.
        /// </summary>
        public static void CreateScriptFromCustomTemplate(string templateName, string defaultScriptName)
        {
            string templatePath = Path.Combine(GlobalPaths.UserTemplatesFolderPath, $"{templateName}.cs.txt");

            try
            {
                ProjectWindowUtil.CreateScriptAssetFromTemplateFile(templatePath, $"{defaultScriptName}.cs");
            }
            catch
            {
                ScriptBuilder.LogWarning("Template not found! Reimporting Custom Templates...");
                TemplateSettingsEditorWindow.RefreshCustomTemplates();
            }
        }