Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Automatically creates, updates, and draws custom Editor Preferences in the Settings window. Supports bool, float, int, string, as well as enums (int-backed) and color.

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta
Notifications You must be signed in to change notification settings

AppalachiaInteractive/com.appalachia.unity3d.editor.preferences.easy

Repository files navigation

Easy Editor Preferences for Unity3D

com.appalachia.unity3d.editor.preferences.easy

license commits build

Created by Appalachia Interactive

Automatically creates, updates, and draws custom Editor Preferences in the Settings window. Supports bool, float, int, string, as well as enums (int-backed) and color.

If you're looking for an even fancier attribute-based solution, check out com.appalachia.unity3d.editor.preferences here.

Examples

The following UI (used in com.appalachia.unity3d.editor.preferences) is generated by the abbreviated code that follows it. Notice the post-fix label on the PreferenceMark field, and the Refresh Button on the PreferencePath field. Very fancy.

The UI

image

The Code

    internal static class AppalachiaMetaPreferences
    {
        private const string _basePath = "Preferences/Appalachia/Preferences";
        private static readonly string _baseKey = nameof(AppalachiaMetaPreferences);

        public static StringEditorPref PreferencePath { get; } = new StringEditorPref(
            _basePath,
            $"{_baseKey}/{nameof(PreferencePath)}",
            "Preference Path",
            "Preferences/My Preferences",
            actionButton: SettingsService.NotifySettingsProviderChanged,
            actionLabel: "Refresh"
        );

        public static BoolEditorPref ShowPreferenceMarker { get; } = new BoolEditorPref(
            _basePath,
            $"{_baseKey}/{nameof(ShowPreferenceMarker)}",
            "Show Preference Mark In Inspector",
            true
        );

        public static EnumEditorPref<PreferenceMarkerCharacter> PreferenceMark { get; } =
            new EnumEditorPref<PreferenceMarkerCharacter>(
                _basePath,
                $"{_baseKey}/{nameof(PreferenceMark)}",
                "Preference Mark",
                PreferenceMarkerCharacter.GreekCapitalXi,
                enableIf: () => ShowPreferenceMarker,
                postfixer: GetMarkerCharacter
            );
        
        public static ColorEditorPref PreferenceMarkColor { get; } =
            new ColorEditorPref(
                _basePath,
                $"{_baseKey}/{nameof(PreferenceMarkColor)}",
                "Preference Mark Color",
                new Color(0.99f, 0.75f, 0.03f, 1.0f),
                enableIf: () => ShowPreferenceMarker
            );
        ...
        ...

        public static string GetMarkerCharacter(PreferenceMarkerCharacter character)
        {
            return character switch
            {
                PreferenceMarkerCharacter.GreekCapitalHeta => "Ͱ",
                PreferenceMarkerCharacter.GreekSmallHeta => "ͱ",
                ....
            };
        }
    }
 

Legal and Licensing

For legal and licensing information please see LEGAL.md.

About

Automatically creates, updates, and draws custom Editor Preferences in the Settings window. Supports bool, float, int, string, as well as enums (int-backed) and color.

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Packages

No packages published

Languages