GetComponentInParent / GetComponentInParentsAutomatically assign a component to a field, if the field value is null and the component is already attached to its parent GameObject(s). (First one found will be used)
Note:
- Like Unity's
GetComponentInParent, this will check the target object itself. GetComponentInParentwill only check the target & its direct parent.GetComponentInParentswill search all the way up to the root.
Parameters:
-
(Optional)
EXP config: config. SeeSaints XPath-like Syntaxsection for more information.Note: You can change the default behavior of these attributes using
Window/Saints/Create or Edit SaintsField Config -
(For
GetComponentInParentsonly)bool includeInactive = falseShould inactive GameObject be included?
trueto include inactive GameObject.Note: only
GetComponentInParentshas this parameter! -
Type compType = nullThe component type to sign. If null, it'll use the field type.
-
string groupBy = ""For error message grouping.
-
AllowMultiple: No
using SaintsField; [GetComponentInParent] public SpriteRenderer directParent; // equals [GetByXPath("//parent::")] [GetComponentInParent(typeof(SpriteRenderer))] public GameObject directParentDifferentType; // equals [GetByXPath("//parent::/[@GetComponent(SpriteRenderer)]")] [GetComponentInParent] public BoxCollider directNoSuch; [GetComponentInParents] public SpriteRenderer searchParent; // equals [GetByXPath("//ancestor::")] [GetComponentInParents(compType: typeof(SpriteRenderer))] public GameObject searchParentDifferentType; [GetComponentInParents] public BoxCollider searchNoSuch;
