/// <summary> /// look for an Interactable if not assigned /// </summary> protected virtual void OnEnable() { if (Interactable == null) { switch (InteractableSearchScope) { case SearchScopes.Self: Interactable = GetComponent <Interactable>(); break; case SearchScopes.Parent: Interactable = GetComponentInParent <Interactable>(); break; case SearchScopes.Children: Interactable = GetComponentInChildren <Interactable>(); break; default: break; } } if (Interactable != null) { Interactable.AddHandler(this); } }
/// <summary> /// Add an interactable and add it as a handler /// </summary> public void AddInteractable(Interactable interactable) { if (Interactable != null) { Interactable.RemoveHandler(this); } Interactable = interactable; Interactable.AddHandler(this); }