private void Start() { Interactable interactable = gameObject.GetOrAddComponent <Interactable>(); HighlightDetection highlightDetection = gameObject.GetOrAddComponent <HighlightDetection>(); interactable.isInteractable = true; interactable.holdToInteract = false; interactable.itemRequired = false; interactable.interactionOption = InteractionOption.Custom; interactable.interactionBehaviour = this; interactable.detectionOption = DetectionOption.Custom; interactable.detectionBehaviour = highlightDetection; if (interactionDisablerToRegister != null) { if (interactionDisablerToRegister.interactables.IsNullOrEmpty()) { interactionDisablerToRegister.interactables = new List <UnityEngine.GameObject>(); } interactionDisablerToRegister.interactables.Add(gameObject); } else { Debug.LogError("No interactionDisabler given!", this); } }
public void Deactivate() { Interactable thisInteractable = GetComponent <Interactable>(); HighlightDetection thisHighlight = GetComponent <HighlightDetection>(); if (thisInteractable == null) { Debug.LogError("No Interactable attached!", this); } else { Destroy(thisInteractable); } if (thisHighlight == null) { Debug.LogError("No HighlightDetection attached!", this); } else { thisHighlight.enabled = false; Destroy(thisHighlight); } Destroy(this); }
public void DestroyHighlightScript() { HighlightDetection highlightDetection = GetComponent <HighlightDetection>(); if (highlightDetection != null) { Destroy(highlightDetection); } }