void DrawCreateWindow()
        {
            GUILayout.BeginVertical("Box", GUILayout.ExpandHeight(true));

            if (onCreationTemplate == null)
            {
                EditorGUILayout.LabelField("No template is being created");
            }
            else
            {
                onCreationTemplate.name = EditorGUILayout.TextField("Template Name :", onCreationTemplate.name);
                DrawSelectionList();

                if (GUILayout.Button(onCreationTemplate.editedTemplate == null ? "Create":"Save Changes"))
                {
                    if (EditorUtility.DisplayDialog("Add To Templates", "Do u wish to add this template to the building templates ?", "Yes", "No"))
                    {
                        TemplateUtility.GenerateTemplate(onCreationTemplate.name, building, onCreationTemplate.ReturnTemplates(), true);
                    }
                    else
                    {
                        TemplateUtility.GenerateTemplate(onCreationTemplate.name, building, onCreationTemplate.ReturnTemplates(), false);
                    }

                    if (onCreationTemplate.editedTemplate != null)
                    {
                        building.RemoveTemplate(onCreationTemplate.editedTemplate);
                    }
                    onCreationTemplate = null;
                    return;
                }
            }

            GUILayout.EndVertical();
        }
Exemple #2
0
        void DrawToolBox()
        {
            GUILayout.BeginHorizontal("Box", GUILayout.Height(20), GUILayout.ExpandHeight(true));
            EditorGUILayout.LabelField("Edit Templates");

            GUILayout.Space(10);

            if (GUILayout.Button(onCreationTemplate == null ? "Create A New Template" : "Delete In Creation Template"))
            {
                if (onCreationTemplate == null)
                {
                    onCreationTemplate = new TemplateCreationData(buildingEditor.script.transform);
                }
                else
                {
                    onCreationTemplate = null;
                }
            }
            if (GUILayout.Button("Add Existing Template"))
            {
                var selectionIndex = GetWindow <TemplateSelectionWindow>();
                selectionIndex.Init(building);
            }

            GUILayout.EndHorizontal();
        }
Exemple #3
0
        void DrawTemplatesView()
        {
            scrollView = GUILayout.BeginScrollView(scrollView, "Box", GUILayout.ExpandHeight(true), GUILayout.Width(300));
            Template template;

            EditorGUILayout.LabelField("Templates:");

            for (int i = 0; i < building.templates.Count; i++)
            {
                template = building.templates[i];

                if (template == null)
                {
                    building.templates.Remove(template);
                    return;
                }

                GUILayout.BeginHorizontal();
                if (GUILayout.Button(template.transform.name))
                {
                    onCreationTemplate = new TemplateCreationData(template, building.transform, template.name);
                }

                if (Event.current.control && string.IsNullOrEmpty(GUI.GetNameOfFocusedControl()))
                {
                    if (GUILayout.Button("X", GUILayout.Width(20)))
                    {
                        if (EditorUtility.DisplayDialog("Removing Template", "Are u sure you wish to remove " + template.name + " ?", "Yes", "No"))
                        {
                            building.RemoveTemplate(template);
                            onCreationTemplate = null;
                        }
                    }
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();
        }