示例#1
0
        private void OnGUI()
        {
            if (m_HighlightedConfiguration == null)
            {
                m_HighlightedConfiguration = GlobalDefines.Instance.CurrentConfiguration;
            }

            EditorGUILayout.BeginVertical();
            {
                // Top columns: config and define
                EditorGUILayout.BeginHorizontal();
                {
                    DisplayConfigurations();
                    DisplayDefines();
                }
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(40);

                // Lower buttons
                EditorGUILayout.BeginVertical();
                {
                    if (GUILayout.Button("Save and Switch"))
                    {
                        GlobalDefines.Instance.SwitchConfiguration(m_HighlightedConfiguration);
                        GlobalDefines.Instance.OutputDefineFiles();
                        GlobalDefines.Instance.SaveConfigurations();
                        ForceRecompile();
                        //Close();
                    }
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndVertical();
        }
示例#2
0
        private RequestedAction DisplayConfiguration(GlobalDefines.Configuration inConfiguration)
        {
            RequestedAction action = RequestedAction.None;

            EditorGUILayout.BeginHorizontal(GUILayout.Height(LINE_HEIGHT));
            {
                // Button to delete it
                if (GlobalDefines.Instance.Configurations.Count > 1)
                {
                    if (GUILayout.Button("X", GUILayout.Width(24)))
                    {
                        action = RequestedAction.Delete;
                    }
                }

                // Name of the configuration
                string newName = EditorGUILayout.TextField(inConfiguration.Name);
                if (!string.IsNullOrEmpty(newName))
                {
                    inConfiguration.Name = newName;
                }

                if (m_HighlightedConfiguration != inConfiguration)
                {
                    // Button to select it
                    if (GUILayout.Button("...", GUILayout.Width(48)))
                    {
                        action = RequestedAction.Select;
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            return(action);
        }
示例#3
0
        private void DisplayConfigurations()
        {
            EditorGUILayout.BeginVertical();
            {
                // Title of column
                EditorGUILayout.BeginHorizontal(GUILayout.Height(LINE_HEIGHT));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Configurations");
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();

                GlobalDefines.Configuration toSelect = null;
                m_ConfigsToDelete.Clear();

                // Each configuration
                List <GlobalDefines.Configuration> configurations = GlobalDefines.Instance.Configurations;
                for (int i = 0; i < configurations.Count; ++i)
                {
                    GlobalDefines.Configuration config = configurations[i];
                    RequestedAction             action = DisplayConfiguration(config);
                    if (action == RequestedAction.Delete && configurations.Count > 1)
                    {
                        m_ConfigsToDelete.Add(config);
                        if (config == m_HighlightedConfiguration)
                        {
                            if (i == configurations.Count - 1)
                            {
                                toSelect = configurations[i - 1];
                            }
                            else
                            {
                                toSelect = configurations[i + 1];
                            }
                        }
                    }
                    else if (action == RequestedAction.Select)
                    {
                        toSelect = config;
                    }
                }

                if (DisplayNewButton() == RequestedAction.Create)
                {
                    GlobalDefines.Configuration newConfiguration = m_HighlightedConfiguration.Clone();
                    newConfiguration.Name = "NEW_CONFIG";
                    GlobalDefines.Instance.Configurations.Add(newConfiguration);
                    toSelect = newConfiguration;
                }

                foreach (GlobalDefines.Configuration config in m_ConfigsToDelete)
                {
                    GlobalDefines.Instance.Configurations.Remove(config);
                }

                if (toSelect != null)
                {
                    m_HighlightedConfiguration = toSelect;
                }
            }
            EditorGUILayout.EndVertical();
        }