GenericInstanceTypeAttribute.md

June 19, 2024 ยท View on GitHub

Friflo.Engine.ECS

Friflo.Engine.ECS

GenericInstanceTypeAttribute Class

The attribute is required to register specific type instances of generic component and tags types. See example in remarks.

public sealed class GenericInstanceTypeAttribute : System.Attribute

Inheritance System.Object ๐Ÿก’ System.Attribute ๐Ÿก’ GenericInstanceTypeAttribute

Remarks

The following example registers a specific generic component instance GenericComponent<int>.
The key used for JSON serialization is "comp-int".

[GenericInstanceType("comp-int", typeof(int))] 
public struct GenericComponent<T> : IComponent {
    public T Value;
}
Constructors
GenericInstanceTypeAttribute(string, Type, Type, Type)Register generic component / tag type with three generic parameters.
GenericInstanceTypeAttribute(string, Type, Type)Register generic component / tag type with two generic parameters.
GenericInstanceTypeAttribute(string, Type)Register generic component / tag type with one generic parameter.