Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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

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

  1. PurplySkye

    PurplySkye

    Joined:
    Jul 28, 2020
    Posts:
    11
    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:
    3,920
    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. PurplySkye

    PurplySkye

    Joined:
    Jul 28, 2020
    Posts:
    11
    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