Search Unity

Bug Loaded ScriptableObject is null but has value when using Fast enter play mode

Discussion in 'Addressables' started by WAYN_Games, May 13, 2021.

  1. WAYN_Games

    WAYN_Games

    Joined:
    Mar 16, 2019
    Posts:
    726
    Hello,

    I'm using scriptable object combined with addressable for my ability system.
    I have been strugulling with an peculiar issue when using the fast "enter play mode" option of the editor.

    I display some information about the ability on screen and some data is not displayed but others are.
    If i have the domain reload option ticked I have no issue but If I don't reload the domain on enter play mode I end up with a null reference on my scriptableobject while it has data.

    upload_2021-5-13_11-39-30.png

    In my code I do some null check on the ability to gard against null pointer but in that case even if the oject is considerd null, I do have all the expected values...

    Fast enter play mode without issue (which is no longer fast enter play mode in that configuration...)
    upload_2021-5-13_11-41-10.png

    upload_2021-5-13_11-43-13.png
     

    Attached Files:

  2. WAYN_Games

    WAYN_Games

    Joined:
    Mar 16, 2019
    Posts:
    726
    I have worked around it by making an ugly copy of the ability loaded through addressable to a new instance of the scriptable object.

    Code (CSharp):
    1. public static ScriptableAbility CopyOf(ScriptableAbility original)
    2.     {
    3.         ScriptableAbility copy = new ScriptableAbility();
    4.         copy.Id = original.Id;
    5.         copy.Icon = original.Icon;
    6.         copy.Name = original.Name;
    7.         copy.Range = original.Range;
    8.         copy.Spawnables = original.Spawnables;
    9.         copy.Timings = original.Timings;
    10.         copy.Costs = original.Costs;
    11.         copy.Effects = original.Effects;
    12.         return copy;
    13.     }
    1) it's ugly
    2) it adds maintenance cost
    3) it probably create more GC
     
  3. WAYN_Games

    WAYN_Games

    Joined:
    Mar 16, 2019
    Posts:
    726
    In fact, the "Fast enter play mode" does not reload the asset,if I change the icon for instance, it does not update until I reload the domain.
     
unityunity