예제 #1
0
        public static AndroidWindowData ReloadTemplate(int i)
        {
            string savedPref = EditorPrefs.GetString(keyPrefix + i);
            string name      = savedPref.Substring(0, savedPref.IndexOf('<'));;
            string xml       = savedPref.Substring(savedPref.IndexOf('<'));

            elements[i]            = AndroidWindowData.CreateInstance(new AndroidXmlEditor(xml));
            elements[i].name       = name;
            elements[i].isTemplate = true;
            return(elements [i]);
        }
예제 #2
0
        public static List <AndroidWindowData> GetTemplates()
        {
            elements = new List <AndroidWindowData> ();
            int i = 0;

            while (EditorPrefs.HasKey(keyPrefix + i))
            {
                string savedPref = EditorPrefs.GetString(keyPrefix + i);
                string name      = savedPref.Substring(0, savedPref.IndexOf('<'));;
                string xml       = savedPref.Substring(savedPref.IndexOf('<'));
                elements.Add(AndroidWindowData.CreateInstance(new AndroidXmlEditor(xml)));
                elements[i].name       = name;
                elements[i].isTemplate = true;
                i++;
            }
            return(elements);
        }
예제 #3
0
        void OnGUI()
        {
            if (data == null)
            {
                OnEnable();
            }
            Undo.RecordObject(data, "Manifest Window");
            GUI.color = Color.white;
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
            data.OnGUI();
            EditorGUILayout.Space();
            #region UpdateButton
            EditorGUILayout.BeginHorizontal();
            {
                if (data.dirty)
                {
                    GUI.color = Color.green;
                }
                else
                {
                    GUI.color = Color.grey;
                }
                if (GUILayout.Button("Apply Changes"))
                {
                    ApplyChanges();
                }
                if (data.dirty)
                {
                    GUI.color = Color.red;
                }
                else
                {
                    GUI.color = Color.grey;
                }
                if (GUILayout.Button("Clear Changes"))
                {
                    ReloadDocument();
                }
                GUI.color = Color.white;
            }
            EditorGUILayout.EndHorizontal();
            #endregion
            EditorGUILayout.Space();

            templateName = EditorGUILayout.TextField("Template name: ", templateName);
            if (GUILayout.Button("Save as Template"))
            {
                AndroidXmlEditor  templateEditor = new AndroidXmlEditor(data.ToString());
                AndroidWindowData newTemplate    = AndroidWindowData.CreateInstance(templateEditor);
                newTemplate.name = templateName;
                AndroidTemplateManager.SaveTemplate(newTemplate);
            }
            for (int i = 0; i < templateElements.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                {
                    templateElements[i].display = EditorGUILayout.Foldout(templateElements[i].display, templateElements[i].name + ":");
                    if (GUILayout.Button("Import", GUILayout.Width(50)))
                    {
                        data.Merge(templateElements[i]);
                        data.dirty = true;
                    }
                    if (GUILayout.Button("Delete", GUILayout.Width(50)))
                    {
                        AndroidTemplateManager.DeleteTemplate(templateElements[i--]);
                        EditorGUILayout.EndHorizontal();
                        continue;
                    }
                }
                EditorGUILayout.EndHorizontal();
                if (templateElements[i].display)
                {
                    BBGuiHelper.BeginIndent();
                    {
                        templateElements[i].OnGUI();
                        EditorGUILayout.BeginHorizontal();
                        {
                            if (templateElements[i].dirty)
                            {
                                GUI.color = Color.green;
                            }
                            else
                            {
                                GUI.color = Color.grey;
                            }
                            if (GUILayout.Button("Apply Changes"))
                            {
                                templateElements[i].ApplyChanges();
                            }
                            if (templateElements[i].dirty)
                            {
                                GUI.color = Color.red;
                            }
                            else
                            {
                                GUI.color = Color.grey;
                            }
                            if (GUILayout.Button("Clear Changes"))
                            {
                                AndroidTemplateManager.ReloadTemplate(i);
                            }
                            GUI.color = Color.white;
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    BBGuiHelper.EndIndent();
                }
            }

            EditorGUILayout.EndScrollView();
            //Repaint on Undo
            if (Event.current.type == EventType.ValidateCommand)
            {
                switch (Event.current.commandName)
                {
                case "UndoRedoPerformed":
                    this.Repaint();
                    break;
                }
            }
        }
예제 #4
0
 void OnEnable()
 {
     data             = AndroidWindowData.CreateInstance(new AndroidXmlEditor());
     templateElements = AndroidTemplateManager.GetTemplates();
 }