Description
The Components
property is a virtual member of the IComponentLister
interface, providing access to a ComponentList
associated with the implementing object. This property allows for the management and retrieval of components within a game object or scene context.
Usage
Implement the IComponentLister
interface in your class to gain access to the Components
property. This property can be used to iterate over, add, or remove components from the associated ComponentList
.
Example
public class MyGameObject : IComponentLister
{
public ComponentList Components { get; private set; }
public MyGameObject()
{
Components = new ComponentList();
}
public void AddComponent<T>() where T : Component, new()
{
Components.Add(new T());
}
public T GetComponent<T>() where T : Component
{
return Components.Get<T>();
}
}