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.
  2. Dismiss Notice

Bug ArgumentException: The Object you want to instantiate is null.

Discussion in 'NetCode for ECS' started by YuriyVotintsev, Nov 30, 2022.

  1. YuriyVotintsev

    YuriyVotintsev

    Joined:
    Jun 11, 2013
    Posts:
    91
    I am baking link to monobehaviour prefab in this component:

    Code (CSharp):
    1. public class Phantom : IComponentData
    2. {
    3.     public VRIKSource VRIKSourcePrefab;
    4. }
    5.  
    6. public class VRIKSource : MonoBehaviour {....}
    This is authoring class:

    Code (CSharp):
    1. public class PhantomAuthoring : MonoBehaviour
    2. {
    3.     public VRIKSource VRIKSource;
    4.  
    5.     class Baker : Baker<PhantomAuthoring>
    6.     {
    7.         public override void Bake(PhantomAuthoring authoring)
    8.         {
    9.             AddComponentObject(new Phantom() {VRIKSourcePrefab = authoring.VRIKSource});
    10.  
    11.             AddBuffer<PhantomCommandData>();
    12.             var buffer = AddBuffer<PhantomBone>();
    13.             buffer.Length = authoring.VRIKSource.Bones.Length;
    14.         }
    15.     }
    16. }
    Everything works ok in editor, but when i build dedicated server build I get ArgumentException: The Object you want to instantiate is null. On this line of code:

    Code (CSharp):
    1. foreach (var (phantom, phantomEntity) in SystemAPI.Query<Phantom>().WithNone<VRIKSolver>().WithEntityAccess())
    2. {
    3.     var vrikSource = Object.Instantiate(phantom.VRIKSourcePrefab);
    4.     ...
    5. }
    Where is my prefab in build?
     
  2. jonathan-hertz

    jonathan-hertz

    Unity Technologies

    Joined:
    Jan 15, 2020
    Posts:
    11
    We recently found a similar bug in the baking process, where some of the referenced values on MonoBehaviours would be stripped away during the baking process in a build. It sounds like the same issue, and it is on our radar to fix. I can't give you an ETA unfortunately.
     
    Occuros likes this.