Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug Error on different Update method on ScriptableObjects

Discussion in 'Scripting' started by DarkRewar, Apr 10, 2024.

  1. DarkRewar

    DarkRewar

    Joined:
    Jan 19, 2015
    Posts:
    32
    Hello,

    I created a ScriptableObject which needs to be updated each frame like MonoBehaviour. That's why I made a component which contains a reference of my instantiated ScriptableObject, and then I call an update method on it.

    The problem is that my method is "TestSO.Update(float deltaTime)" and the console throws me that error :

    Script error (TestSO): Update() can not take parameters.

    I think this is a bug because ScriptableObjects can not be updated with the Update() method like MonoBehaviours are. And, even if I declare an Update() method, it is never called at runtime.

    I've got that error on any Unity version I could get (2021, 2022, and 6).
     
    CodeSmile likes this.
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,530
    I agree, this check should not extend to ScriptableObject scripts. I was just starting a new project with Unity 6 b13, so I confirmed the issue and sent a bug report: CASE IN-73338

    Besides renaming the method, Update() w/o parameters will also work since you can get Time.deltaTime from anywhere.
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,067
    CodeSmile likes this.
  4. Nad_B

    Nad_B

    Joined:
    Aug 1, 2021
    Posts:
    730
    Just rename it to Tick, it's kinda a standard in the gaming industry.
     
    Ryiah and Kurt-Dekker like this.
  5. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,498
    Adding
    On
    to an event is common too so you could just name it
    OnUpdate
    .
     
    spiney199, CodeSmile and Nad_B like this.