165 lines
4.1 KiB
C#
165 lines
4.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class Panel : MonoBehaviour
|
|
{
|
|
public Button choseJuBenSettingBtn;
|
|
public Button emergencySettingBtn;
|
|
public Button peoplePublishBtn;
|
|
public Button materialReserveBtn;
|
|
public Button dateSelectionBtn;
|
|
public Button personnelmanagementBtn;
|
|
|
|
|
|
public Button setName;//设置人员
|
|
public Button setDuty;//设置职责
|
|
public Button setScene;//设置场景
|
|
|
|
public Text arrangeText;//整体安排
|
|
|
|
public string name, duty, scene;
|
|
|
|
public Button sureBtn;//确认信息按钮
|
|
public GameObject ManagerPanel;
|
|
|
|
public GraphicRaycaster raycaster; // 画布上的射线投射器
|
|
public EventSystem eventSystem; // 事件系统
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
GetData();
|
|
SetText();
|
|
}
|
|
|
|
|
|
|
|
//处理点击选择剧本按钮
|
|
public void ClickChoseJuBenSettingBtn()
|
|
{
|
|
|
|
}
|
|
|
|
//处理点击应急人员配置按钮
|
|
public void ClickEmergencySettingBtn()
|
|
{
|
|
|
|
}
|
|
|
|
//处理点击疏散人群公布按钮
|
|
public void ClickPeoplePublishBtn()
|
|
{
|
|
|
|
}
|
|
|
|
//处理点击应急物资储备按钮
|
|
public void ClickMaterialReserveBtn()
|
|
{
|
|
|
|
}
|
|
|
|
//处理点击选择演练日期按钮
|
|
public void ClickDateSelectionBtn()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//处理人员管理按钮
|
|
public void ClickPersonnelManagement()
|
|
{
|
|
Debug.Log("调用人员管理");
|
|
ManagerPanel.gameObject.SetActive(true);
|
|
}
|
|
|
|
//处理点击确认按钮
|
|
public void ClickSureBtn()
|
|
{
|
|
SceneManager.LoadScene("Schedule_a_walkthrough");
|
|
}
|
|
|
|
|
|
|
|
//获取鼠标点击位置的信息
|
|
public void GetData()
|
|
{
|
|
ManagerPanel managerPanel = new ManagerPanel();
|
|
|
|
// 当鼠标左键按下时进行检测
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
// 确保 raycaster 和 eventSystem 不为空
|
|
if (raycaster == null || eventSystem == null)
|
|
{
|
|
Debug.LogError("Raycaster 或 EventSystem 未正确分配,请在 Inspector 中进行分配。");
|
|
return;
|
|
}
|
|
|
|
// 创建 PointerEventData 来记录点击事件的数据
|
|
PointerEventData pointerData = new PointerEventData(eventSystem);
|
|
pointerData.position = Input.mousePosition;//获取鼠标点击的位置
|
|
|
|
// 用于存储射线检测的结果
|
|
List<RaycastResult> results = new List<RaycastResult>();
|
|
|
|
// 射线检测 UI
|
|
raycaster.Raycast(pointerData, results);
|
|
|
|
// 遍历射线检测的结果
|
|
foreach (RaycastResult result in results)
|
|
{
|
|
// 检测到点击了按钮
|
|
Button clickedButton = result.gameObject.GetComponent<Button>();
|
|
|
|
if (clickedButton != null)
|
|
{
|
|
Text buttonText = clickedButton.GetComponentInChildren<Text>();
|
|
if (buttonText != null && buttonText.tag == Tags.people)//这里可以获取标签为人员的信息
|
|
{
|
|
|
|
name = buttonText.text;
|
|
Debug.Log(name);
|
|
}
|
|
else if (buttonText != null && buttonText.tag == Tags.scene)//这里可以获取标签为场景的信息
|
|
{
|
|
//PlateInfo plateInfo = new PlateInfo();
|
|
scene = buttonText.text;
|
|
//managerPanel.platesList.Add(plateInfo);
|
|
//plateInfo.plateinfoText = plateInfo.transform.GetComponent<Text>();
|
|
//plateInfo.plateinfoText.text = scene;
|
|
Debug.Log(scene);
|
|
}
|
|
else if (buttonText != null && buttonText.tag == Tags.duty)//这里可以获取标签为职责的信息
|
|
{
|
|
|
|
duty = buttonText.text;
|
|
Debug.Log(duty);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//设置安排文字
|
|
public void SetText()
|
|
{
|
|
arrangeText.text = "[" + name + "]担任[" + duty + "],位于[" + scene + "]";
|
|
}
|
|
|
|
|
|
|
|
}
|