GameObject in a ScriptableObject not included in build!

I have a ScriptableObject which has a List of classes that define behaviour for that SO, and in those classes there is a GameObject. The problem is when the project is built the SO has the GameObject value but when I try and instantiate it I get an exception because the object was not included in the build.
Is there a way to check that the object actually exists in the build before trying to instantiate it, or is there a way to tell Unity to include the GameObjects set in the List.
It works fine is the GameObjects are in a Resources folder but would be nice if I could check at Build time automatically and give a warning or something?

This observation sounds counter to the dependency tree approach Unity always uses flawlessly so it sounds like database corruption or something.

Did you try a reimport all?

As Kurt pointed out, Unity includes everything that’s referenced from any scene included in a build. So usually, that’s not an error you encounter.

Where exactly is your SO stored and how do you get a reference to it? You’re saying GameObject but as an asset that would be a prefab? It’s a regular Unity-serialized reference from the SO to the prefab?

Have you tried checking with AssetDatabase.GetDependencies or a dependency viewer that Unity sees the SO depending on the prefab?

When you say this, I assume you don’t mean a list of System.Type entries, correct?

That means it is specific instances of classes… all the same type? Some supertype? An interface?

And then are we talking about MonoBehaviour or ScriptableObject instances? Because either way, they MUST exist on disk before you reference them in any other asset.

It’s subtle and really really easy to get wrong…

Assets must be created and exist on disk before any other asset can persistently refer to them:

https://discussions.unity.com/t/846212