Skip to main content

GetComponentAttribute

A class in Alta.Attributes, the global namespace.

Field attribute that fills the field with a component from the same object when the prefab is applied, probably in the editor (the caller isn't in this build). Base for the other GetComponent attributes.

Constructors​

MemberWhat it is
GetComponentAttribute()Creates a GetComponentAttribute from type.
GetComponentAttribute(Type type)Creates a GetComponentAttribute from type.

Fields​

1 private and internal field
MemberWhat it is
private static Logger loggerNLog logger for this class.

Properties​

MemberWhat it is
Type Type { get; set; }Component type to look for. Defaults to the field's type.
bool WarnOnNull { get; set; }Log an error when no component is found.

Methods​

MemberWhat it is
virtual Component GetComponent(Transform transform, Type type)Finds the component. Overridden by subclasses to search children, parents or the prefab root.
override bool HandleApply(Component component, FieldInfo field, GameObject prefab)Sets the field to the found component; returns true if it changed. Logs an error if none found and WarnOnNull is set.