ComponentList Components { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Components property provides access to the list of components attached to the GameObject that this Component is part of. This property is sealed, meaning it cannot be overridden in derived classes.

Usage

Use the Components property to iterate over or manipulate the components attached to the same GameObject as the current component. This can be useful for accessing other components to modify their properties or call their methods.

Example

// Example of accessing the Components property
public class ExampleComponent : Component
{
    public void PrintComponentNames()
    {
        foreach (var component in Components)
        {
            Log.Info(component.GetType().Name);
        }
    }
}