コード例 #1
0
        override public void OnInspectorGUI()
        {
            serializedObject.Update();

            GUILayout.Space(AEditorValues.LARGE_OFFSET);

            _current.DefaultSettings.DrawInspector();
            SortAllMenuOrientation();

            if (_current.DefaultSettings.AttachUI)
            {
                AUITool.AttachRectTransform(_current.gameObject);
            }

            GUILayout.Space(AEditorValues.MIN_OFFSET);

            AEditorTool.DrawSeparator(AEditorTool.SeparationStyle.Default);

            GUILayout.Space(AEditorValues.LARGE_OFFSET);
            AEditorTool.DrawListButtons(_current.MenuList, "Add new menu", AddMenu, "Clear menu list", ClearMenuList);
            GUILayout.Space(AEditorValues.LARGE_OFFSET);

            _current.MenuList = _current.MenuList.Where(x => x != null).ToList();

            UpdateNames();

            for (int i = 0; i < _current.Count; i++)
            {
                DrawMenuView(_current[i], i);
            }

            _sortModule.SortInvoke(_current.MenuList);
            _current.UpdateActiveMenuState();

            AEditorTool.DrawSeparator(AEditorTool.SeparationStyle.Default);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Save menu names in enum " + BaseEngineConstants.MenuDataEnumForMenu);
            EditorGUILayout.EndHorizontal();

            AEditorTool.DrawListButtons(_current.MenuList, "Clear all names", ClearMenuData, "Apply menu names", SaveMenuData);

            this.SaveGuiChanges();
        }
コード例 #2
0
        private void DrawMenuView(Menu menu, int index)
        {
            AEditorTool.DrawSeparator(index == 0 ? AEditorTool.SeparationStyle.Default : AEditorTool.SeparationStyle.SmallLight);

            if (menu.DefaultSettings == null)
            {
                menu.DefaultSettings = _current.DefaultSettings;
            }

            float size = Screen.width / 2f - 32f;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Menu:", GUILayout.Width(size));
            EditorGUILayout.LabelField("Name:", GUILayout.Width(size));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            menu              = (Menu)EditorGUILayout.ObjectField(menu, typeof(Menu), true, GUILayout.Width(size));
            menu.name         = EditorGUILayout.TextField(menu.name, GUILayout.Width(size));
            menu.name         = new string(menu.name.Where(c => char.IsLetterOrDigit(c)).ToArray());
            _namesList[index] = menu.name;

            if (GUILayout.Button("-", GUILayout.Width(AEditorValues.MIN_SIZE)))
            {
                _current.MenuList.RemoveAt(index);
                DestroyImmediate(menu.gameObject);
                UpdateNames();
                return;
            }
            EditorGUILayout.EndHorizontal();

            if (GetNamesCount(menu.name) > 1)
            {
                this.DrawColorLabel(new Color(1f, 0.35f, 0.35f), string.Format("Already used menu with name {0}", menu.name));
            }

            GUILayout.Space(AEditorValues.OFFSET);

            const float ACTIVE_BUTTON_WIDTH = 35f;
            const float TOOGLE_WIDTH        = 40f;

            EditorGUILayout.BeginHorizontal();
            if (menu.gameObject.activeSelf)
            {
                this.DrawColorLabel(Color.green, "ON", GUILayout.Width(ACTIVE_BUTTON_WIDTH));
            }
            else
            {
                EditorGUILayout.LabelField("OFF", GUILayout.Width(ACTIVE_BUTTON_WIDTH));
            }

            if (EditorGUILayout.Toggle(menu.gameObject.activeSelf, GUILayout.Width(TOOGLE_WIDTH)))
            {
                _current.ActiveMenu = menu;
            }

            EditorGUILayout.LabelField(" ", GUILayout.Width(size - ACTIVE_BUTTON_WIDTH - TOOGLE_WIDTH));
            if (index != 0)
            {
                if (GUILayout.Button(_btnUpTex, GUILayout.Width(30)))
                {
                    _sortModule.ChangeSortState(SortMenuModule.ESortKind.Up, index);
                }
            }
            if (index < _current.Count - 1)
            {
                if (GUILayout.Button(_btnDownTex, GUILayout.Width(30)))
                {
                    _sortModule.ChangeSortState(SortMenuModule.ESortKind.Down, index);
                }
            }
            EditorGUILayout.EndHorizontal();

            if (menu.gameObject.layer != _current.gameObject.layer)
            {
                menu.gameObject.layer = _current.gameObject.layer;
            }

            GUILayout.Space(AEditorValues.LARGE_OFFSET);
            MenuEditor.DrawMenuView(menu);
            GUILayout.Space(AEditorValues.LARGE_OFFSET);
        }
コード例 #3
0
        void OnGUI()
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);

            Color defaultColor = GUI.color;

            GUILayout.Space(9);

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(38f);
            EditorGUILayout.LabelField("General audio settings", EditorStyles.boldLabel, GUILayout.Width(150f));
            DrawImage(_gearIcon, 20f, 20f, 10f, 0f);
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(12);

            _runtimeAudioSettings.Draw();
            _generalAudioSettings.DrawGUI();
            _fadingSettings.DrawGUI();

            GUILayout.Space(12);

            /*
             *          EditorGUILayout.BeginHorizontal ();
             *          EditorGUILayout.LabelField ("Fade time", GUILayout.Width (180));
             *          fadeTime = EditorGUILayout.FloatField (fadeTime, GUILayout.Width (120));
             *          if (fadeTime < 0)
             *                  fadeTime = 0;
             *          EditorGUILayout.EndHorizontal ();
             *          EditorGUILayout.BeginHorizontal ();
             *          EditorGUILayout.LabelField ("Use fade ON", GUILayout.Width (180));
             *          useFadeOn = EditorGUILayout.Toggle (useFadeOn, GUILayout.Width (120));
             *          EditorGUILayout.EndHorizontal ();
             *
             *          GUILayout.Space (12);
             */

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("New Audio Block", GUILayout.Width(250)))
            {
                AudioBlock newBlock = new AudioBlock();
                newBlock.name = GetUniqueBlockName();
                audioData.Add(newBlock.name, newBlock);
            }
            EditorGUILayout.EndHorizontal();

            string removeKey = "";

            if (audioData != null)
            {
                foreach (var item in audioData)
                {
                    GUILayout.Space(12);
                    AEditorTool.DrawSeparator(AEditorTool.SeparationStyle.BigDark);

                    var block = item.Value;

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Audio Block Name:");
                    if (GUILayout.Button("Remove", GUILayout.Width(60)))
                    {
                        removeKey = item.Key;
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    string name = block.name;
                    name = EditorGUILayout.TextField(name, GUILayout.MinWidth(100), GUILayout.MaxWidth(250));
                    if (audioData.ContainsKey(name) && audioData[name] != block)
                    {
                        name = GetUniqueBlockName(name);
                    }
                    block.name = name;
                    EditorGUILayout.EndHorizontal();

                    GUILayout.Space(12);

                    EditorGUILayout.BeginHorizontal();
                    GUI.color = Color.green;
                    EditorGUILayout.LabelField("Music:");
                    GUI.color = defaultColor;
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Delay between musics", GUILayout.Width(150));
                    block.music.delay = EditorGUILayout.FloatField(block.music.delay, GUILayout.Width(40));
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Not reply length", GUILayout.Width(150));
                    block.music.musicNotReplyCount = EditorGUILayout.IntField(block.music.musicNotReplyCount, GUILayout.Width(40));
                    if (block.music.musicNotReplyCount < 0)
                    {
                        block.music.musicNotReplyCount = 0;
                    }
                    EditorGUILayout.EndHorizontal();
                    GUILayout.Space(6);

                    DrawTrackList(block.music, true);
                    GUILayout.Space(6);

                    EditorGUILayout.BeginHorizontal();
                    GUI.color = Color.green;
                    EditorGUILayout.LabelField("Sound:");
                    GUI.color = defaultColor;
                    EditorGUILayout.EndHorizontal();

                    DrawTrackList(block.sound, false);
                }
            }

            if (removeKey != "")
            {
                audioData.Remove(removeKey);
            }

            GUILayout.Space(12);
            if (GUILayout.Button("Save"))
            {
                SaveConfiguration(true);
                SaveNamesInCode();
            }
            GUILayout.Space(20);
            EditorGUILayout.EndScrollView();
        }