예제 #1
0
 public void Add(Interact3dItem item)
 {
     EnsureUi(item);
     if (!items.Contains(item))
     {
         items.Add(item);
     }
     UpdateItems();
 }
예제 #2
0
            private void OnTriggerExit(Collider other)
            {
                Interact3dItem item = other.GetComponentInChildren <Interact3dItem>();

                if (item && !item.internalState.alwaysOn)
                {
                    ui.Remove(item);
                }
            }
예제 #3
0
            private void OnTriggerEnter(Collider other)
            {
                Interact3dItem item = other.GetComponentInChildren <Interact3dItem>();

                if (item)
                {
                    ui.Add(item);
                }
            }
예제 #4
0
 public void EnsureUi(Interact3dItem item)
 {
     if (item.screenUi == null)
     {
         item.screenUi = Instantiate(prefab_interactButton).GetComponent <RectTransform>();
         item.screenUi.SetParent(uiArea);
         item.screenUi.transform.localScale = prefab_interactButton.transform.localScale * item.internalState.size;
         item.fontSize = item.fontSize * item.internalState.fontCoefficient;
         item.onInteractVisible?.Invoke();
     }
 }
예제 #5
0
 public void UpdateItems()
 {
     for (int i = 0; i < items.Count; ++i)
     {
         Interact3dItem item = items[i];
         if (item == null)
         {
             items.RemoveAt(i--); continue;
         }
         if (!UpdateItem(item))
         {
             --i;
         }
     }
 }
예제 #6
0
 public void Remove(Interact3dItem item)
 {
     if (item.internalState.alwaysOn)
     {
         return;
     }
     if (item.screenUi != null)
     {
         Destroy(item.screenUi.gameObject);
     }
     if (items.Remove(item))
     {
         item.onInteractHidden?.Invoke();
     }
     UpdateItems();
 }
예제 #7
0
 public bool UpdateItem(Interact3dItem item)
 {
     if (item.screenUi == null)
     {
         Remove(item);
         Add(item);
         return(false);
     }
     if (item.showing)
     {
         item.screenUi.gameObject.SetActive(true);
         Vector3 screenP = cam.WorldToScreenPoint(item.transform.position + item.internalState.worldOffset);
         item.screenUi.position = screenP;
     }
     else
     {
         item.screenUi.gameObject.SetActive(false);
     }
     return(true);
 }