Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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 Technologies

    Mar 7, 2018
    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


    Jul 18, 2016
    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


    Jan 24, 2013
    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: