//
        // EditorWindow methods
        //

        //------------------------------------------------------------------------------
        private void OnGUI()
        {
            GUIStyle headerStyle = new GUIStyle(EditorStyles.whiteLargeLabel);

            headerStyle.fixedHeight = EditorGUIUtility.singleLineHeight * 2.0f;

            EditorGUILayout.BeginVertical();

            String title = String.Format("Templates v{0} Settings", TemplateTool.Version.ToString("F1"));

            EditorGUILayout.LabelField(title, headerStyle);
            EditorGUILayout.Space();

            GUIContent eolLabelContent = new GUIContent("Normalize EOL", "Select which type of line ending you'd like generated files to use. If you don't know what this means it's safe to leave the default set.");

            EditorUtil.EolType eolType = (EditorUtil.EolType)EditorGUILayout.EnumPopup(eolLabelContent, TemplatePrefs.Eol);
            if (GUI.changed)
            {
                TemplatePrefs.Eol = eolType;
            }

            GUILayout.Space(40.0f);
            if (GUILayout.Button("CreateTemplate"))
            {
                TemplateTool.CreateTemplate();
            }
            if (GUILayout.Button("CreateMappingSet"))
            {
                TemplateTool.CreateMappingSet();
            }

            EditorGUILayout.EndVertical();
        }
Example #2
0
        //------------------------------------------------------------------------------
        private void ActionCreate()
        {
            if (m_generatedFileList.Count > 0)
            {
                TemplateTool.GenerateFiles(m_templateFilePath, m_userSuppliedNameText, m_targetPath);
            }

            Close();
        }
        //------------------------------------------------------------------------------
        private void SaveAndRefreshGUI()
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            GUIContent saveButtonContent = new GUIContent("Save & Refresh", "Saves all unsaved assets and refreshes the Xenotemplates menu. Refreshing is only required when the name of the template changes.");

            bool saveAndRefreshMenu = GUILayout.Button(saveButtonContent, EditorStyles.miniButton);

            if (saveAndRefreshMenu)
            {
                AssetDatabase.SaveAssets();
                TemplateTool.RefreshTemplates();
            }

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
        }
Example #4
0
        //
        // Private methods
        //


        //------------------------------------------------------------------------------
        private String CustomMappingDelegateMenu(String selectedValue, MonoScript script)
        {
            if (script == null)
            {
                return(String.Empty);
            }

            List <String> methods = TemplateTool.GetValidSubstitutionMethods(script);

            if (methods.Count == 0)
            {
                return(String.Empty);
            }

            int selectedIndex = Math.Max(0, methods.IndexOf(selectedValue));

            int newSelectedIndex = EditorGUILayout.Popup(selectedIndex, methods.ToArray());

            return(methods[newSelectedIndex]);
        }
Example #5
0
 public static void AutoMono()
 {
     TemplateTool.PromptUserForNameAuto();
 }
Example #6
0
 public static void ECSSystem()
 {
     TemplateTool.ShowTemplate("ECSSystem");
 }
Example #7
0
 public static void ECSComponetData()
 {
     TemplateTool.ShowTemplate("ECSComponetData");
 }
Example #8
0
 public static void MainUIView()
 {
     TemplateTool.ShowTemplate("MainUIView");
 }
Example #9
0
 public static void TDConfig()
 {
     TemplateTool.ShowTemplate("TDConfig");
 }
Example #10
0
        //
        // EditorWindow methods
        //

        //------------------------------------------------------------------------------
        private void OnGUI()
        {
            HandleKeyEvents();

            Rect contentRect = EditorGUILayout.BeginVertical();

            GUIStyle titleStyle = new GUIStyle(GUI.skin.label);

            titleStyle.fontStyle = FontStyle.Bold;
            titleStyle.alignment = TextAnchor.UpperCenter;
            GUILayout.Label("Template", titleStyle);

            GUI.SetNextControlName("NameTokenTextField");
            String newName = EditorGUILayout.TextField(m_userSuppliedNameText);
            String error   = String.Empty;

            if (newName != m_userSuppliedNameText || m_generatedFileList.Count == 0)
            {
                TemplateTool.GenerateFileNames(m_templateFilePath, newName, ref m_generatedFileList, ref error);
                m_userSuppliedNameText = newName;
            }

            EditorGUILayout.LabelField("Files to create", String.Format("{0}", m_generatedFileList.Count));

            if (m_generatedFileList.Count == 0)
            {
                if (!String.IsNullOrEmpty(error))
                {
                    EditorGUILayout.HelpBox(error, MessageType.Error);
                }
                else
                {
                    EditorGUILayout.HelpBox("Template malformed. No files will be created.", MessageType.Error);
                }
            }

            GUIStyle fileNameStyle = new GUIStyle(EditorStyles.label);

            fileNameStyle.alignment     = TextAnchor.LowerRight;
            fileNameStyle.contentOffset = new Vector2(-15.0f, 0.0f);

            foreach (String fileName in m_generatedFileList)
            {
                GUILayout.Label(fileName, fileNameStyle);
            }

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();

            bool cancelClicked = GUILayout.Button("Cancel", GUILayout.ExpandWidth(false));

            if (cancelClicked)
            {
                ActionCancel();
            }

            GUILayout.FlexibleSpace();

            if (m_generatedFileList.Count > 0)
            {
                bool proceedClicked = GUILayout.Button("Proceed", GUILayout.ExpandWidth(false));
                if (proceedClicked)
                {
                    ActionCreate();
                }
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            EditorGUILayout.EndVertical();

            GUIStyle helpStyle = new GUIStyle(EditorStyles.miniLabel);

            helpStyle.fontStyle = FontStyle.Italic;
            helpStyle.alignment = TextAnchor.LowerCenter;
            Rect helpLabelRect = contentRect;

            helpLabelRect.height = EditorGUIUtility.singleLineHeight;
            helpLabelRect.y      = contentRect.height - helpLabelRect.height;

            String helpString = "Esc. to cancel; Enter to create";

            if (m_generatedFileList.Count == 0)
            {
                helpString = "Esc. to cancel";
            }

            GUI.Label(helpLabelRect, helpString, helpStyle);



            if (m_setSize && Event.current.type == EventType.Repaint)
            {
                ResizeWindow(contentRect);
                m_setSize = false;
            }

            if (m_setFocus && Event.current.type == EventType.Repaint)
            {
                EditorGUI.FocusTextInControl("NameTokenTextField");
                m_setFocus = false;
            }
        }