#How can i extend a component from custom defined interface ?

1 messages · Page 1 of 1 (latest)

languid torrent
#

Hello i want to extend a component from an interface that i defined like this:

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

public interface IGizmosComponent : IComponentData
{
    public void DrawGizmos();
}
using UnityEngine;
using System.Collections;
using Unity.Entities;
using Unity.Transforms;
using Unity.Mathematics;

public struct GizmosDrawCubeComponent : IGizmosComponent
{
    public float3 Position;
    public float3 Sizes;

    public void DrawGizmos()
    {
        Gizmos.DrawCube(new Vector3(this.Position.x, this.Position.y, this.Position.z), new Vector3(this.Sizes.x, this.Sizes.y, this.Sizes.z));
    }
}

But when i use this it throws an error
ArgumentException: Unknown Type:IGizmosComponent All ComponentType must be known at compile time. For generic components, each concrete type must be registered with [RegisterGenericComponentType].

#

I guess the issue is here

protected override void OnUpdate()
    {
        Entities.ForEach((Entity e, IGizmosComponent component) => {
            component.DrawGizmos();
        }).WithoutBurst().Run();
    }
#

but how can i query components that inherits from IGizmosComponent then ?

split panther
#

not possible in ECS

languid torrent
#

How can i use WithAny inside of Entities.ForEach

split panther
#

it's about to be obsolete in next big update

#

and it's also destroying your compilation times

languid torrent
#

Ohh

#

How can i make it then

#

Should i use EntityQuery.ToArray()

split panther
#

foreach (var (x,y,z) in SystemAPI.Query<X,Y,Z>(){}`

languid torrent
#

Is that works in SystemBase ?

split panther
#

yes