Search Unity

Official [Blog Post Discussion] Clarifying API usage requirements via improved messaging

Discussion in 'Scripting' started by Unity_Javier, Aug 30, 2022.

  1. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    190
    Hi everyone,

    We're excited to share our team's latest blog post with you:

    Clarifying API usage requirements via improved messaging

    Questions, comments and suggestions are all welcome. We're looking forward to hearing from you!
     
    karl_jones and UnityMrAndyPuppy like this.
  2. mahdi_jeddi

    mahdi_jeddi

    Joined:
    Jul 18, 2016
    Posts:
    246
    In worst case scenario for issues caused by this, you could add a compatibility option in project settings to let the calls go through, so that people know they need to fix them, but doesn't completely break their code. At some point you could remove this option to force everyone to fix their code.
     
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    The error messages should really say something about why the API can't be used at such a time! It's always very frustrating when you do something that you think should work, and the engine just goes "no you can't". A simple "that data is currently being changed so using the call will lead to inconsistent results" at the end of the error message will go a long way to alleviate annoyance.


    Also, whenever you add a warning/error like this, make sure that it's actually sensible. I still keep getting upset that this:
    Code (csharp):
    1. void OnValidate() {
    2.     gameObject.tag = "Something";
    3. }
    Causes this:
    upload_2022-9-14_17-8-5.png