Search Unity

Feedback SettingProvider poor exception description

Discussion in 'Scripting' started by Tony_Max, Sep 19, 2022.

  1. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    352
    While coding [SettingsProvider] and do some wrong stuff inside method signed with this attribute the only thing editor console telling me is always
    Cannot create Settings Provider for: GetSettingsProvider
    UnityEditor.SettingsWindow:OnEnable ()
    It is annoying to trying to figure out what went wrong in code, so please if it possible provide a more informative exception
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,856
    Are you doing any of the initialisation inside an anonymous method like in the example?

    Just a wild guess but that could confuse the stack trace.
     
  3. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    352
    I'm using UI Elements so yes, I do initialization inside method like in the docs example. I'm not expert about what can confuse stack trace, so maybe it is just impossible to have detailed stack trace, but still awkward
     
  4. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,856
    I'm no expert either but it's worth exploring.

    For example, in one of my personal tools that has a settings provider, it's initialised like so:
    Code (CSharp):
    1. [SettingsProvider]
    2. public static SettingsProvider GetCatalogueSettings()
    3. {
    4.    settingsProvider = new SettingsProvider("LizardBrainGames/Catalogue Settings", SettingsScope.Project)
    5.    {
    6.        activateHandler = CreateCatalogueSettings
    7.    };
    8.  
    9.    return settingsProvider;
    10. }
    11.  
    12. private static void CreateCatalogueSettings(string searchContext, VisualElement rootVisualElement)
    13. {
    14.     //make UI stuff
    15. }
    16.  
    And I've had errors reported normally should they occur.
     
    Tony_Max likes this.
  5. sebastienp_unity

    sebastienp_unity

    Unity Technologies

    Joined:
    Feb 16, 2018
    Posts:
    201
    Hi Tony_Max,

    Ensure that in your Console you have enabled stack trace logging:

    upload_2022-9-20_16-2-22.png

    This if you click on any exceptions in the console, you will get a more informative stack trace that might explain what went wrong.

    Cheers,

    Sebastien

     
    MelvMay and spiney199 like this.