using Newtonsoft.Json; using System; using TMPro; using UnityEngine; using UnityEngine.UI; using XRLib; using XRLib.UI; namespace Studio.Test { public class AGVNodePopup : PanelBase { public Button Button_Plus; public Button Button_Minus; public TMP_Dropdown DropDown_AGVNodeType; public GameObject target; public override void AfterAwake() { gameObject.SetActive(false); } // Update is called once per frame void Update() { if (target) { var ScreenPoint = Camera.main.WorldToScreenPoint(target.transform.position); bool onScreen = ScreenPoint.x > 0f && ScreenPoint.x < Screen.width && ScreenPoint.y > 0f && ScreenPoint.y < Screen.height && ScreenPoint.z > 0f; if (onScreen) { gameObject.GetComponent().interactable = true; gameObject.GetComponent().alpha = 1f; gameObject.GetComponent().position = ScreenPoint + new Vector3(0, 5f, 0); } else { gameObject.GetComponent().interactable = false; gameObject.GetComponent().alpha = 0f; } } } public void Popup(GameObject selectedNode) { target = selectedNode; gameObject.GetComponent().position = Camera.main.WorldToScreenPoint(target.transform.position) + new Vector3(0, 5f, 0); gameObject.GetComponent().interactable = true; gameObject.GetComponent().alpha = 1f; //DropDown_AGVNodeType.value = (int)selectedNode.GetComponent().nodeClass.type; gameObject.SetActive(true); } public void Popdown() { target = null; gameObject.SetActive(false); } } }