PreferenceItem is deprecated. Use [SettingsProvider] instead ...

PreferenceItem is deprecated. Use [SettingsProvider] instead
UnityEditor.SettingsWindow:OpenUserPreferences()

Would like this nugget to not annoy my console which I actually use for my own dev :wink:

1 Like

So use [SettingsProvider] instead?

I would, but itā€™s your code doing it, not mine. Happens every compile from something in 2018.3 / HDRP 3.0

3 Likes

Found something:

Do you use the post processing package?

Iā€™m getting the same error and Iā€™m not using the Post Processing package.

It started happening after I opened the Preferences window and now it happens constantly on code compile.

Yep, that sounds about right.

Seems to also happen with Pro Builder.

If youā€™re not using that either, could you please report a bug with the package manifest of the project, in which the error occurs, attached?

Just dock the new preferences and editor settings tab next to scene view, should do it each time its compiling from there on.

Canā€™t reproduce.

Settings has the issue as well: Win7 64bit - 2018.3.0b3

Hi LeonhardP,

we require examples how to use the [SettingsProvider] class for save/load stuff. The warning occur on several assets from the asset store now, because they use the preference settings to store Unity Editor Seettings.

We also use the [PreferenceItem()] for our editor variables extensively.

        [PreferenceItem("ConsolE")]
        public static void OnGUI() {}
        [PreferenceItem("Compiler")]
        public static void OnGUI() {}
        [PreferenceItem("Amplify Texture 2")]
        public static void OnGUI() {}
        [PreferenceItem("DTK Splines")]
        public static void OnGUI() {}
       etc etc....

#pragma warning disable xxx. does not work because there is not value given for :
Trying to register preference item: ā€œCompilerā€. [PreferenceItem] attribute is deprecated. Use [SettingsProvider] attribute instead.

Did you have a solution to suppress all these warning about [PreferenceItem]
This is really annoying!

The goal of the warning was to boost user awareness of the new [SettingsProvider] API. We will remove the warning and mark [PreferenceItem] as obsolete instead. It will be less ā€œin your faceā€.

1 Like

I canā€™t remember when it started but Iā€™m getting it with Cinemachine:

Trying to register preference item: ā€œCinemachineā€. [PreferenceItem] attribute is deprecated. Use [SettingsProvider] attribute instead.

SettingsProvider based on UnityEditor. Can you provide a simple example to create an SettingsProvider.asset and load and save some fields? That would be very handy. Thank you.

Search for [SettingsProvider] in this .cs file:
https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/Inspector/GraphicsSettingsInspector.cs

1 Like

Thank youā€¦
Seems an ungly task to exploreā€¦

Pasting how to migrate your old [PreferenceItem] code in the most barebone way just in case someone want to get rid of the warning quickly :

#if UNITY_2018_3_OR_NEWER
    private class MyPrefSettingsProvider : SettingsProvider
    {
        public MyPrefSettingsProvider(string path, SettingsScopes scopes = SettingsScopes.Any)
        : base(path, scopes)
        { }

        public override void OnGUI(string searchContext)
        {
            MyOldPrefCode();
        }
    }

    [SettingsProvider]
    static SettingsProvider MyNewPrefCode()
    {
        return new MyPrefSettingsProvider("Preferences/MyPref");
    }
#else
    [PreferenceItem("MyPref")]
#endif
    static void MyOldPrefCode()
    {
        EditorGUI.BeginChangeCheck();
        ....
    }
17 Likes

Hopefully Unity will update as well :smile:
Mine comes from ā€œUnityEditor.SettingsWindow:OnEnable()ā€

1 Like

Thanks, I used it on Zios Theme Editor: https://github.com/z3nth10n/unity-themes/commit/d2a3de9ab931e23e55ecd8eb7909cd706f28b585