137 lines
2.7 KiB
C#
137 lines
2.7 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 setName;//设置人员
|
|
public Button setDuty;//设置职责
|
|
public Button setScene;//设置场景
|
|
|
|
public string name, duty, scene;
|
|
|
|
public Button sureBtn;//确认信息按钮
|
|
|
|
|
|
public GraphicRaycaster raycaster; // 画布上的射线投射器
|
|
public EventSystem eventSystem; // 事件系统
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
public void SetName()
|
|
{
|
|
|
|
}
|
|
|
|
public void SetDuty()
|
|
{
|
|
|
|
}
|
|
|
|
public void SetScene()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
//处理点击选择剧本按钮
|
|
public void ClickChoseJuBenSettingBtn()
|
|
{
|
|
|
|
}
|
|
|
|
//处理点击应急人员配置按钮
|
|
public void ClickEmergencySettingBtn()
|
|
{
|
|
|
|
}
|
|
|
|
//处理点击疏散人群公布按钮
|
|
public void ClickPeoplePublishBtn()
|
|
{
|
|
|
|
}
|
|
|
|
//处理点击应急物资储备按钮
|
|
public void ClickMaterialReserveBtn()
|
|
{
|
|
|
|
}
|
|
|
|
//处理点击选择演练日期按钮
|
|
public void ClickDateSelectionBtn()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//处理点击确认按钮
|
|
public void ClickSureBtn()
|
|
{
|
|
SceneManager.LoadScene("Schedule_a_walkthrough");
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
// 当鼠标左键按下时进行检测
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
// 创建PointerEventData来记录点击事件的数据
|
|
PointerEventData pointerData = new PointerEventData(eventSystem);
|
|
pointerData.position = Input.mousePosition;
|
|
|
|
// 用于存储射线检测的结果
|
|
List<RaycastResult> results = new List<RaycastResult>();
|
|
raycaster.Raycast(pointerData, results);
|
|
|
|
// 遍历射线检测的结果
|
|
foreach (RaycastResult result in results)
|
|
{
|
|
// 检测到点击了按钮
|
|
Button clickedButton = result.gameObject.GetComponent<Button>();
|
|
if (clickedButton != null)
|
|
{
|
|
// 获取按钮上Text组件的文本内容并赋值给目标Text组件
|
|
Text buttonText = clickedButton.GetComponentInChildren<Text>();
|
|
|
|
if (buttonText != null && clickedButton.tag == Tags.people)
|
|
{
|
|
name = buttonText.text;
|
|
Debug.Log(name);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|