Scriptable Object keeps losing reference to prefab on entering play mode in Unity 2021.3.1 LTS
I'm having this weird problem that keeps recurring. I have a couple of scriptable objects, all of them working properly except one of them that randomly keeps losing reference to the prefab it had been given.
All of my scriptable objects were created in Unity 2020, but I have upgraded the project to 2021, and everything was working fine, until I made a new scriptable object and realized that it keeps randomly losing its prefab reference when I enter play mode. And I don't know why!
I tried applying the prefab and restarting unity, applying prefab and saving, creating a new scriptable object, but it keeps forgetting this one reference. I also tried it with a different prefab but it still caused the same problem. Keep in mind that all the other scriptable objects similar to this one are OK, and never lose reference. It's only this one.
When you reference the prefab, are you dragging and dropping it from the Project or Hierarchy view? Could you provide the code from "FireflySO" that defines the field you're holding the reference in?
Also, when the reference exists (before entering playmode) try clicking on the prefab reference in your Scriptable Object. Does it highlight any of your project folders?
Hi @synthc
My prefab is highlighted in the asset folder. Not from the scene. I confirmed it multiple times. The code that defines the field is this:
[TabGroup("Object Settings")]
[InfoBox("This is the gameobject prefab which is created when this firefly is equipped. The gameobject contains the firefly script that gives it functions.")]
public GameObject FireflyGameobject;
Your answer
Follow this Question
Related Questions
Rotation Flicker in 2d platformer gun 0 Answers
My character is animating perfectly but character is not moving when walk . 0 Answers
How to add my coin to parallax together with other gameObject? 0 Answers
Last Input not being properly stored 0 Answers
I have problem with using vs with unity 0 Answers