Search Unity

ScriptableObject: Singular SOs or Group data SOs?

Discussion in 'Scripting' started by SaltwaterAssembly, Apr 19, 2021.

  1. SaltwaterAssembly

    SaltwaterAssembly

    Joined:
    Mar 8, 2016
    Posts:
    95
    Hi,
    What's the benefit of having an SO for different, seperate variables (float, int) etc, rather than say one SO containing multiple variables for a particular item (e.g. a GameData SO that contains bool gameInProgress, bool gameOver etc?

    (I'm referring to the Unite 2017 talk where they had seperate SOs for variables in the project)
    Thanks
     
  2. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    1,066
    Haven't seen the talk but I guess one variable per SO allows you to create new variables just by creating new assets and without needing to touch any code, whereas the GameData SO requires you to add new fields via code?

    Depending on the target user, one or the other might make more sense. With single variable per SO, you can simply reference a variable by dragging in the asset whereas the GameData SO is easier to reference via code.
     
  3. SaltwaterAssembly

    SaltwaterAssembly

    Joined:
    Mar 8, 2016
    Posts:
    95
    Yes, just made me wonder how crazy it could get in a larger project having seperate SOs. Your folder/file & naming systems would have to be on point to keep on top of them all. And wondering how this affects profiling, too. Trying to see the benefits I guess.
     
  4. SaltwaterAssembly

    SaltwaterAssembly

    Joined:
    Mar 8, 2016
    Posts:
    95
    I guess too it could affect memory if you have one SO containing a whole bunch of variables - you're essentially loading all of that data when you are only accessing one? Or am I not understanding how SOs work in terms of memory?