Search Unity

PreferenceItem is deprecated. Use [SettingsProvider] instead.

Discussion in 'Editor & General Support' started by 5argon, May 15, 2019.

  1. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,190
    I am still getting likes from my previous post I couldn't edit anymore. So here is an updated solution for future googler.

    Code (CSharp):
    1. #if UNITY_2018_3_OR_NEWER
    2.     [SettingsProvider]
    3.     static SettingsProvider YourNewPrefGUI()
    4.     {
    5.         //- If .Project it will appear in Project Settings instead
    6.         //- Even in Preferences window, it is possible to place it outside of Preferences tree.
    7.         return new SettingsProvider("Preferences/YourPrefName", SettingsScope.User)
    8.         {
    9.             //This is just the drawer. There are more to customize in the new provider system.
    10.             guiHandler = (searchContext) => YourOldPrefGUI(),
    11.         };
    12.     }
    13. #else
    14.     [PreferenceItem("YourPrefName")]
    15. #endif
    16.     static void YourOldPrefGUI() {
    17.         //...
    18.     }