예제 #1
0
        static void Init()
        {
            GameSettingsEditor window = (GameSettingsEditor)EditorWindow.GetWindow(typeof(GameSettingsEditor));

            window.titleContent = new GUIContent("RTS Game Settings");
            window.maxSize      = new Vector2(768f, 600f);
            window.minSize      = window.maxSize;
            window.Show();

            Load();
        }
예제 #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var storage = GameSettingsEditor.GetStorage();

            if (!storage)
            {
                EditorGUI.PropertyField(position, property, label, true);
                return;
            }

            var soundLibrary = storage.soundLibrary;

            if (!soundLibrary)
            {
                EditorGUI.PropertyField(position, property, label, true);
                return;
            }

            var soundPathes  = soundLibrary.GetSoundsPathes(soundLibrary.soundsCategories);
            var currentIndex = GetIndexOfCurrentSound(property.objectReferenceValue as AudioClip, soundPathes);

            if (currentIndex < 0)
            {
                currentIndex = 0;
            }

            // here we drawing an popup with list of all sounds, divided by categories. We need to little reduce width to add second field near this popup
            var popupPosition = position;

            popupPosition.width -= 96;

            currentIndex = EditorGUI.Popup(popupPosition, property.displayName, currentIndex, soundPathes.ToArray());
            property.objectReferenceValue = GetSoundByIndex(currentIndex, soundPathes, soundLibrary);

            // we also showing default object field property in right side of our popup
            var propertyPosition = position;

            propertyPosition.x     = popupPosition.width + 15;
            propertyPosition.width = 96;

            EditorGUI.PropertyField(propertyPosition, property, new GUIContent(""), true);
        }