Search Unity

Question and Problem

Discussion in 'Entity Component System' started by Irushian, Apr 26, 2018.

  1. Irushian

    Irushian

    Joined:
    Dec 13, 2015
    Posts:
    7
    As ECS is package based, would it be more a case of updating the package over which version of Unity to use and if this is not the case, which would be more feature complete, 2018.1 or 2018.2 beta?

    I've created a little test with spawning some entities and it all works fine, I see them on the screen and they move etc via a system to how I want them, however when I select the entity within the debugger I get the message about the value being null on the mesh parameter and then they vanish, and I can't for the life of me figure out my mistake.

    Code (csharp):
    1.  
    2. this.NodeArchetype = entityManager.CreateArchetype(
    3.       typeof( NodeComponent ),
    4.       typeof( Position ),
    5.       typeof( TransformMatrix )
    6. );
    7. Node_InstanceRenderer = GetLookFromPrototype( "NodeRenderPrototype" );
    8.  
    9. Entity NodeEntity = entityManager.CreateEntity( this.NodeArchetype );
    10. entityManager.SetComponentData( NodeEntity, new Position { Value = f3Position } );
    11. entityManager.SetComponentData( NodeEntity, new NodeComponent { SpawnTimer = iSpawnTimer, Cooldown = iSpawnTimer } );
    12. entityManager.AddSharedComponentData( NodeEntity, BootstrapGameObject.Node_InstanceRenderer );
    13.  
    Node_InstanceRenderer is just a static MeshInstanceRenderer that's populated the same as in the examples.
     
  2. Irushian

    Irushian

    Joined:
    Dec 13, 2015
    Posts:
    7
    For some reason when I comment out this system it'll work perfectly fine, I'm able to select an entity without issue however as soon as this system is active then it'll throw the mesh error. It appears to be the inject that causes it, even if there's no code inside the OnUpdate that uses it.

    There's obviously something that I'm not understanding but I'm hoping that someone will be able to enlighten me on this.

    Code (csharp):
    1.  
    2. public class SpawningSystem : ComponentSystem
    3. {
    4.    struct NodeGroup
    5.    {
    6.       public ComponentDataArray<Position> Positions;
    7.       public ComponentDataArray<NodeComponent> Nodes;
    8.       public int Length;
    9.    }
    10.    [Inject] private NodeGroup m_NodeGroup;
    11.  
    12.    protected override void OnUpdate()
    13.    {
    14.       return;
    15.    }
    16. }
    17.  
    Code (csharp):
    1.  
    2. ArgumentNullException: Value cannot be null.
    3. Parameter name: mesh
    4. UnityEngine.Graphics.DrawMeshInstanced (UnityEngine.Mesh mesh, System.Int32 submeshIndex, UnityEngine.Material material, UnityEngine.Matrix4x4[] matrices, System.Int32 count, UnityEngine.MaterialPropertyBlock properties, UnityEngine.Rendering.ShadowCastingMode castShadows, System.Boolean receiveShadows, System.Int32 layer, UnityEngine.Camera camera, UnityEngine.Rendering.LightProbeUsage lightProbeUsage, UnityEngine.LightProbeProxyVolume lightProbeProxyVolume) (at C:/buildslave/unity/build/Runtime/Export/Graphics.bindings.cs:341)
    5. UnityEngine.Graphics.DrawMeshInstanced (UnityEngine.Mesh mesh, System.Int32 submeshIndex, UnityEngine.Material material, UnityEngine.Matrix4x4[] matrices, System.Int32 count, UnityEngine.MaterialPropertyBlock properties, UnityEngine.Rendering.ShadowCastingMode castShadows, System.Boolean receiveShadows) (at C:/buildslave/unity/build/Runtime/Export/Graphics.bindings.cs:315)
    6. Unity.Rendering.MeshInstanceRendererSystem.OnUpdate () (at C:/ProgramData/Unity/cache/packages/staging-packages.unity.com/com.unity.entities@0.0.11/Unity.Rendering.Hybrid/MeshInstanceRendererSystem.cs:77)
    7. Unity.Entities.ComponentSystem.InternalUpdate () (at C:/ProgramData/Unity/cache/packages/staging-packages.unity.com/com.unity.entities@0.0.11/Unity.Entities/ComponentSystem.cs:247)
    8. Unity.Entities.ScriptBehaviourManager.Update () (at C:/ProgramData/Unity/cache/packages/staging-packages.unity.com/com.unity.entities@0.0.11/Unity.Entities/ScriptBehaviourManager.cs:82)
    9. Unity.Entities.ScriptBehaviourUpdateOrder+DummyDelagateWrapper.TriggerUpdate () (at C:/ProgramData/Unity/cache/packages/staging-packages.unity.com/com.unity.entities@0.0.11/Unity.Entities/ScriptBehaviourUpdateOrder.cs:59)
    10.  
     
  3. Irushian

    Irushian

    Joined:
    Dec 13, 2015
    Posts:
    7
    No one knows why it's happening?
     
  4. Irushian

    Irushian

    Joined:
    Dec 13, 2015
    Posts:
    7
    Just figured I'd post an update... I left it for a few days and now it's suddenly working. Not sure why this was the case as the only thing that has changed is that my machine had been restarted in this time. Shame I didn't get a single response though, but hopefully if any one else has this happen then this may help.
     
  5. henrikpAtUnity

    henrikpAtUnity

    Unity Technologies

    Joined:
    Jan 6, 2017
    Posts:
    37
    Regarding your question as to which version of Unity to use, we are currently supporting 2018.1 and 2018.2 equally. So they have the same features and you can chose the one that fits you.