Search Unity

Bug Prefab reference sometimes disappears when playing and always when loading a scene.

Discussion in 'Editor & General Support' started by Skyewee, Jan 29, 2023.

  1. Skyewee

    Skyewee

    Joined:
    Jul 28, 2020
    Posts:
    15
    Code (CSharp):
    1. [HideInInspector] public Projectile projectilePrefab;
    This is the line I have in my Scriptable Object class.

    I assign it in a custom inspector, where I make sure to set the SO dirty and all.
    Most of the time when I hit play on the game, the references stay, but on scene loads they always disappear.

    Using Unity 2021.3.15f
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,934
    I would first open the scriptable object in a text editor to make sure the values are properly being serialised out. If they aren't, that points to your issue being the custom editor.
     
  3. Skyewee

    Skyewee

    Joined:
    Jul 28, 2020
    Posts:
    15
    I've narrowed the cause down to loading save files with a saving asset that I use, just gotta ask the creator of it about it I guess :p