private void OnSelectedUsable(Usable usable)
 {
     this.usable = usable;
     if (usableUI != null)
     {
         usableUI.Hide();                   // Hide previous selection.
     }
     usableUI = (usable != null) ? usable.GetComponentInChildren <AbstractUsableUI>() : null;
     if (usableUI != null)
     {
         usableUI.Show(GetUseMessage());
         HideControls();
     }
     else
     {
         var oldElements = elements;
         SetElementsForUsable(usable);
         if (oldElements != elements)
         {
             var newElements = elements;
             elements = oldElements;
             HideControls();
             elements = newElements;
         }
         ShowControls();
     }
     lastInRange = !IsUsableInRange();
     UpdateDisplay(!lastInRange);
 }
        private void SetElementsForUsable(Usable usable)
        {
            // Check tag-specific UI elements:
            for (int i = 0; i < tagSpecificElements.Count; i++)
            {
                var tagInfo = tagSpecificElements[i];
                if (usable != null && usable.CompareTag(tagInfo.tag))
                {
                    defaultUseMessage = tagInfo.defaultUseMessage;
                    elements          = tagInfo.UIElements;
                    return;
                }
            }

            // Check layer-specific UI elements:
            for (int i = 0; i < layerSpecificElements.Count; i++)
            {
                var layerInfo = layerSpecificElements[i];
                if (usable != null && ((1 << usable.gameObject.layer) & layerInfo.layerMask.value) != 0)
                {
                    defaultUseMessage = layerInfo.defaultUseMessage;
                    elements          = layerInfo.UIElements;
                    return;
                }
            }

            // Otherwise get default elements:
            defaultUseMessage = originalDefaultUseMessage;
            if (layerSpecificElements.Count > 0 || tagSpecificElements.Count > 0)
            {
                for (int i = 0; i < StandardUISelectorElements.instances.Count; i++)
                {
                    var instance   = StandardUISelectorElements.instances[i];
                    var isSpecific = (layerSpecificElements.Find(x => x.UIElements == instance) != null) ||
                                     (tagSpecificElements.Find(x => x.UIElements == instance) != null);
                    if (!isSpecific)
                    {
                        elements = instance;
                        return;
                    }
                }
            }
            elements = StandardUISelectorElements.instance;
        }
 private void Start()
 {
     if (StandardUISelectorElements.instances.Count == 0)
     {
         if (DialogueDebug.logWarnings)
         {
             Debug.LogWarning("Dialogue System: SelectorUseStandardUIElements can't find a StandardUISelectorElements component in the scene.", this);
         }
         enabled = false;
     }
     else
     {
         started = true;
         ConnectDelegates();
         foreach (var current in StandardUISelectorElements.instances)
         {
             elements = current;
             DeactivateControls();
         }
     }
 }
 private void OnDisable()
 {
     m_instances.Remove(this);
     instance = (m_instances.Count > 0) ? m_instances[0] : null;
 }
 private void Awake()
 {
     instance = this;
     m_instances.Add(this);
     animator = GetComponent <Animator>();
 }