Search Unity

Getting scriptable object variables not working in mobile build (but works in editor)

Discussion in 'Visual Scripting' started by CameronDWills, Jul 21, 2021.

  1. CameronDWills

    CameronDWills

    Joined:
    Feb 26, 2021
    Posts:
    90
    I've attached a screenshot of my scriptable object, and two examples of warning messages that appear in the mobile console.

    I've added the scriptable object to my node types, and everything works fine when I test in the Unity editor. However when I build to mobile, it seems like the get nodes for title/description/image don't seem to be working. I added debug log messages and can confirm it's loading in the scriptable objects, but for some reason it's unable to get the data from them.

    Does anyone know what the issue could be? Any hints would be much appreciated
    Thank you
     

    Attached Files:

  2. CameronDWills

    CameronDWills

    Joined:
    Feb 26, 2021
    Posts:
    90
    I created a test scene which only contains a prefab that has a list of scriptable objects, and a flow graph that logs how many items are in the list, and prints the description of the first item. As you can see in the log, the list count worked fine, but when it came to print the description, it's as if the get item description node doesn't exist and it throws a missing arg error where the description should be.

    The scriptable objects are all located in the Resources folder of my project. Please adivse
     

    Attached Files:

  3. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,068
    Weird, one thing I'd try would be to decorate the scriptable object with [IncludeInSettings(true)] attribute. Then rebuild node library in Project Settings/Visual Scripting. And finally, try building again.
     
  4. CameronDWills

    CameronDWills

    Joined:
    Feb 26, 2021
    Posts:
    90
    Thank you for the reply, I just tested this out and I'm getting the same results :(

    I also tried creating an empty game object in the scene and attaching a new script

    public class TestItem : MonoBehaviour { Item myItem; }

    And then attached a SO to it, thinking maybe this would force it to be built in. That didn't work either
     
  5. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,068
    Which scripting backend are you on? Could be some kind of AOT issue. But then SOs shouldn't produce them. I'd report this to Unity as a bug.
     
  6. CameronDWills

    CameronDWills

    Joined:
    Feb 26, 2021
    Posts:
    90
    I figured it out (sort of)

    I created an entirely new scriptable object script, containing the exact same code just renamed and it worked. No idea why, maybe a bug in unity or my project that causes it not to build the original, but the duplicate under a new name worked.
     
  7. Kostishko

    Kostishko

    Joined:
    May 15, 2019
    Posts:
    2
    Hello, I have similar problem I think. Working fine on Editor, and doesn't work on device.
    But scripts working fine on device, exept all what made with lists (AoT, or other - doesn't matter).
    I took logs from amdroid, and get that exeption:

    Code (CSharp):
    1. 08-04 13:25:23.920  7766  7917 I Unity   : Product Name: GolfGame
    2. 08-04 13:25:26.257  7766  7917 W Unity   : Deserialization Failure Data
    3. 08-04 13:25:26.257  7766  7917 W Unity   :
    4. 08-04 13:25:26.257  7766  7917 W Unity   : Object References:
    5. 08-04 13:25:26.257  7766  7917 W Unity   : (None)
    6. 08-04 13:25:26.257  7766  7917 W Unity   :
    7. 08-04 13:25:26.257  7766  7917 W Unity   : JSON:
    8. 08-04 13:25:26.257  7766  7917 W Unity   : {
    9. 08-04 13:25:26.257  7766  7917 W Unity   :     "declarations": {
    10. 08-04 13:25:26.257  7766  7917 W Unity   :         "collection": {
    11. 08-04 13:25:26.257  7766  7917 W Unity   :             "$content": [
    12. 08-04 13:25:26.257  7766  7917 W Unity   :                 {
    13. 08-04 13:25:26.257  7766  7917 W Unity   :                     "name": "BallStrikeSaved",
    14. 08-04 13:25:26.257  7766  7917 W Unity   :                     "value": {
    15. 08-04 13:25:26.257  7766  7917 W Unity   :                         "$content": 0,
    16. 08-04 13:25:26.257  7766  7917 W Unity   :                         "$type": "System.Int32"
    17. 08-04 13:25:26.257  7766  7917 W Unity   :                     },
    18. 08-04 13:25:26.257  7766  7917 W Unity   :                     "$version": "A"
    19. 08-04 13:25:26.257  7766  7917 W Unity   :                 },
    20. 08-04 13:25:26.257  7766  7917 W Unity   :                 {
    21. 08-04 13:25:26.257  7766  7917 W Unity   :                     "name": "ScoreCountSaved",
    22. 08-04 13:25:26.257  7766  7917 W Unity   :                     "value": {
    23. 08-04 13:25:26.257  7766  7917 W Unity   :                         "$content": 0,
    24. 08-04 13:25:26.257  7766  7917 W Unity   :                         "$type": "System.Int32"
    25. 08-04 13:25:26.257  7766  7917 W Unity   :                     },
    26. 08-04 13:25:26.257  7766  7917 W Unity   :                     "$version": "A"
    27. 08-04 13:25:26.257  7766  7917 W Unity   :                 },
    28. 08-04 13:25:26.257  7766  7917 W Unity   :                 {
    29. 08-04 13:25:26.257  7766  7917 W Unity   :                     "name": "RecordsCountList",
    30. 08-04 13:25:26.257  7766  7917 W Unity   :                     "value": null,
    31. 08-04 13:25:26.257  7766  7917 W Unity   :                     "$version": "A"
    32. 08-04 13:25:26.257  7766  7917 W Unity   :                 },
    33. 08-04 13:25:26.257  7766  7917 W Unity   :                 {
    34. 08-04 13:25:26.257  7766  7917 W Unity   :                     "name": "RecordsList",
    35. 08-04 13:25:26.257  7766  7917 W Unity   :                     "value": {
    36. 08-04 13:25:26.257  7766  7917 W Unity   :                         "$content": [
    37. 08-04 13:25:26.257  7766  7917 W Unity   :                             0.0,
    38. 08-04 13:25:26.257  7766  7917 W Unity   :                             0.0,
    39. 08-04 13:25:26.257  7766  7917 W Unity   :
    40. 08-04 13:25:26.287  7766  7917 E Unity   : Failed to deserialize scriptable object.
    41. 08-04 13:25:26.287  7766  7917 E Unity   : System.Runtime.Serialization.SerializationException: Deserialization into 'Bolt.VariablesAsset' failed. ---> System.InvalidOperationException: Constructor of System.Collections.Generic.List`1[System.Single] threw an exception when creating an instance ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'System.Collections.Generic.List<System.Single>' threw an exception. ---> System.ExecutionEngineException: Attempting to call method 'System.Collections.Generic.List`1[[System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]::.cctor' for which no ahead of time (AOT) code was generated.