#LineRenderer
1 messages · Page 1 of 1 (latest)
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