Tz2/Assets/Zion/Scripts/ERP/显示库存凭证清单/InventoryVoucherListCompone...

123 lines
4.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using DefaultNamespace.ProcessMode;
using MotionFramework;
using UnityEngine;
using UnityEngine.UI;
namespace Zion.Scripts.ERP.
{
/// <summary>
/// 显示库存凭证清单
/// </summary>
public class InventoryVoucherListComponent : MonoBehaviour
{
[SerializeField] private InputField factoryInputField; // 工厂输入框
[SerializeField] private InputField moveInputField; // 供货地点输入框
[SerializeField] private InputField starInputField; // 起始时间输入框
[SerializeField] private InputField endInputField; // 结束时间输入框
[SerializeField] private Button queryButton; // 提交按钮
[SerializeField] private GameObject plane1;
[SerializeField] private GameObject plane2;
[SerializeField] private CanvasGroup background;
private void Awake()
{
factoryInputField = this.transform.Find("工厂").GetComponent<InputField>();
moveInputField = this.transform.Find("移动类型").GetComponent<InputField>();
starInputField = this.transform.Find("过账日期前").GetComponent<InputField>();
endInputField = this.transform.Find("过账日期后").GetComponent<InputField>();
queryButton = this.transform.Find("确定").GetComponent<Button>();
background = this.transform.Find("背景").GetComponent<CanvasGroup>();
}
private void Start()
{
queryButton.onClick.AddListener(OnQueryButtonClicked);
}
private void OnQueryButtonClicked()
{
try
{
bool isb = MotionEngine.GetModule<ProcessManager>().HandleClick(
new List<string>()
{
factoryInputField.text,
moveInputField.text,
starInputField.text,
endInputField.text
});
Debug.Log(isb);
if (isb)
{
plane2.SetActive(true);
}
else
{
plane1.SetActive(true);
}
}
catch (Exception e)
{
Debug.Log(e.Message);
plane1.SetActive(true);
}
}
/// <summary>
/// 黑屏过渡
/// </summary>
private async Task FadeOutBackground()
{
float duration = 1f; // 渐变持续时间
float elapsedTime = 0f;
float startAlpha = 1f;
float endAlpha = 0f;
while (elapsedTime < duration)
{
float alpha = Mathf.Lerp(startAlpha, endAlpha, elapsedTime / duration);
background.alpha = alpha;
elapsedTime += Time.deltaTime;
await Task.Yield(); // 等待下一帧
}
background.alpha = endAlpha;
}
private void Update()
{
if (Input.GetMouseButtonDown(0)) // 检测鼠标左键点击
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // 从相机发射射线到鼠标点击位置
if (Physics.Raycast(ray, out hit)) // 检查射线是否击中物体
{
OnRaycastHit(hit.collider.gameObject); // 调用处理射线击中物体的方法
}
}
}
private void OnRaycastHit(GameObject hitObject)
{
// 这里可以添加射线击中物体后的逻辑
Debug.Log("射线击中物体: " + hitObject.name);
bool isb = MotionEngine.GetModule<ProcessManager>().HandleClick(
new List<string>()
{
hitObject.name
});
}
}
}