Component getters
Last updated
Last updated
Takes automatically the target component in the object.
Supported property types
Object Reference
Exposed Reference
Managed Reference
Parameters
CreateOneIfEmpty
Can't be used on arrays and lists.
Code Example
using UltimateAttributesPack;
public class GetComponentInObjectExample : MonoBehaviour
{
// GetComponentInObject attribute can be used to automatically get the target component of the object and set the variable with it
[GetComponentInObject]
public BoxCollider boxColliderOfObject;
// You can set the param to true to create a new component in the object automatically if there is none
// --> [GetComponentInObject(true)]
}
Takes automatically the target component in the object's parent.
Supported property types
Object Reference
Exposed Reference
Managed Reference
Parameters
CreateOneIfEmpty
Can't be used on arrays and lists.
Code Example
using UltimateAttributesPack;
public class GetComponentInParentExample : MonoBehaviour
{
// GetComponentInParent attribute can be used to automatically get the target component of the object's parent and set the variable with it
[GetComponentInParent]
public BoxCollider boxColliderOfParent;
// You can set the param to true to create a new component in the object's parent automatically if there is none
// --> [GetComponentInParent(true)]
}
Takes automatically the target component in the object's root.
Supported property types
Object Reference
Exposed Reference
Managed Reference
Parameters
CreateOneIfEmpty
Can't be used on arrays and lists.
Code Example
using UltimateAttributesPack;
public class GetComponentInRootExample : MonoBehaviour
{
// GetComponentInRoot attribute can be used to automatically get the target component of the object's root and set the variable with it
[GetComponentInRoot]
public BoxCollider boxColliderOfRoot;
// You can set the param to true to create a new component in the object's root automatically if there is none
// --> [GetComponentInRoot(true)]
}