61 lines
2.0 KiB
C#
61 lines
2.0 KiB
C#
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<CanvasGroup>().interactable = true;
|
|
gameObject.GetComponent<CanvasGroup>().alpha = 1f;
|
|
gameObject.GetComponent<RectTransform>().position = ScreenPoint + new Vector3(0, 5f, 0);
|
|
}
|
|
else
|
|
{
|
|
gameObject.GetComponent<CanvasGroup>().interactable = false;
|
|
gameObject.GetComponent<CanvasGroup>().alpha = 0f;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Popup(GameObject selectedNode)
|
|
{
|
|
target = selectedNode;
|
|
gameObject.GetComponent<RectTransform>().position = Camera.main.WorldToScreenPoint(target.transform.position) + new Vector3(0, 5f, 0);
|
|
gameObject.GetComponent<CanvasGroup>().interactable = true;
|
|
gameObject.GetComponent<CanvasGroup>().alpha = 1f;
|
|
//DropDown_AGVNodeType.value = (int)selectedNode.GetComponent<AGVNode>().nodeClass.type;
|
|
gameObject.SetActive(true);
|
|
}
|
|
|
|
public void Popdown()
|
|
{
|
|
target = null;
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|