A Few Beginner Questions

  • How do I convert a GO to an Entity with references to other converted GO’s Entities in a different hierarchy?
  • How do I find Entities with a specific component and without a specific buffer?
  1. I know you can do that with subscenes.
  2. You can use this in a ComponentSystem:
    query = GetEntityQuery(typeof(MyComponent), ComponentType.Exclude<MyBuffer>())
  1. I don’t know what I’m doing wrong. Here’s the hierarchy:
  • Graph Subscene

  • Node

  • Node (1)

  • Edge

I keep getting this warning: “GetPrimaryEntity(GameObject ‘Node’) was not included in the conversion and will be ignored.” When I look at the Edge entity, both node references are “index 0 version 0”. I’ve tried multiple versions including 2019.3.0f1 and I keep getting the missing reference issue.

All entities have an authoring component:

using System.Collections.Generic;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;

namespace Thrive.ECS.Graphs
{
    [RequiresEntityConversion]
    public class Edge_Authoring : MonoBehaviour, IDeclareReferencedPrefabs, IConvertGameObjectToEntity
    {
        public GameObject nodeA;
        public float3 controlA;
        public float3 controlB;
        public GameObject nodeB;


        // Referenced prefabs have to be declared so that the conversion system knows about them ahead of time
        public void DeclareReferencedPrefabs(List<GameObject> referencedPrefabs)
        {
            referencedPrefabs.Add(nodeA);
            referencedPrefabs.Add(nodeB);
        }


        public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
        {
            var edge = new Edge
            {
                nodeA = conversionSystem.GetPrimaryEntity(nodeA),
                controlA = controlA,
                controlB = controlB,
                nodeB = conversionSystem.GetPrimaryEntity(nodeB)
            };
            dstManager.AddComponentData(entity, edge);
        }
    }
}
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;

namespace Thrive.ECS.Graphs
{
    [RequiresEntityConversion]
    public class Node_Authoring : MonoBehaviour, IConvertGameObjectToEntity
    {
        public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
        {
            var node = new Node{};
            dstManager.AddComponentData(entity, node);
        }
    }
}

I’d remove the IDeclareRefencedPrefabs implementation in your EdgeAuthoring script. You only need that for GameObjects not already in your scene.

I’ve removed the interface, but the problem persists.