#LineRenderer

1 messages · Page 1 of 1 (latest)

pseudo ermine
#

How do I spawn a linerenderer and interact with it using dots (ECS)?

I tried to add a LineRenderer into the dots sub-scene but it would not render, I had to add it to the normal scene, and I'm not sure how I can spawn it from for example the authoring scripts.

Would highly appreciate any kind of help

rugged yoke
#

I have this system and components to link GameObjects to Entities:

[UpdateInGroup(typeof(SimulationSystemGroup), OrderLast = true)]
[RequireMatchingQueriesForUpdate]
public partial struct LinkToGameObjectSystem : ISystem {
    public void OnUpdate(ref SystemState state) {
        List<(Request, Entity)> results = new();
        foreach (var (request, entity) in SystemAPI.Query<Request>()
                                                   .WithNone<Link>()
                                                   .WithEntityAccess()) {
            results.Add((request, entity));
        }

        foreach ((Request request, Entity entity) in results) {
            state.EntityManager.AddComponentObject(entity, new Link {
                gameObject = UnityEngine.Object.Instantiate(request.prefab)
            });
        }
    }

    public class Request : IComponentData {
        public GameObject prefab;
    }

    public class Link : IComponentData, IDisposable {
        public GameObject gameObject;

        public void Dispose() {
            if (gameObject != null)
                UnityEngine.Object.Destroy(gameObject);
        }
    }
}

Then you will be able to access the LineRenderer through the Link component