_xiaofang/xiaofang/Assets/Script/Scheduled_03/Panel.cs

165 lines
3.9 KiB
C#
Raw Normal View History

2024-11-25 16:33:54 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2024-11-25 17:16:41 +08:00
using UnityEngine.EventSystems;
2024-11-25 16:33:54 +08:00
using UnityEngine.SceneManagement;
using UnityEngine.UI;
2024-11-25 17:16:41 +08:00
2024-11-25 16:33:54 +08:00
public class Panel : MonoBehaviour
{
public Button choseJuBenSettingBtn;
public Button emergencySettingBtn;
public Button peoplePublishBtn;
public Button materialReserveBtn;
public Button dateSelectionBtn;
2024-11-26 15:36:02 +08:00
public Button personnelmanagementBtn;
2024-11-25 16:33:54 +08:00
2024-11-25 17:16:41 +08:00
public Button setName;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա
public Button setDuty;//<2F><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0>
public Button setScene;//<2F><><EFBFBD>ó<EFBFBD><C3B3><EFBFBD>
2024-11-25 16:33:54 +08:00
2024-11-26 15:36:02 +08:00
public Text arrangeText;//<2F><><EFBFBD><EFBFBD><E5B0B2>
2024-11-25 17:16:41 +08:00
public string name, duty, scene;
2024-11-25 16:33:54 +08:00
public Button sureBtn;//ȷ<><C8B7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ť
2024-11-26 15:36:02 +08:00
public GameObject ManagerPanel;
2024-11-25 16:33:54 +08:00
2024-11-25 17:16:41 +08:00
public GraphicRaycaster raycaster; // <20><><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD><EFBFBD>
public EventSystem eventSystem; // <20>¼<EFBFBD>ϵͳ
2024-11-25 16:33:54 +08:00
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
GetData();
2024-11-26 15:36:02 +08:00
SetText();
}
2024-11-25 17:16:41 +08:00
2024-11-25 16:33:54 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><E7B1BE>ť
public void ClickChoseJuBenSettingBtn()
{
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ð<EFBFBD>ť
public void ClickEmergencySettingBtn()
{
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɢ<EFBFBD><C9A2>Ⱥ<EFBFBD><C8BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
public void ClickPeoplePublishBtn()
{
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>ʴ<EFBFBD><CAB4><EFBFBD><EFBFBD><EFBFBD>ť
public void ClickMaterialReserveBtn()
{
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD>ť
public void ClickDateSelectionBtn()
{
2024-11-26 15:36:02 +08:00
2024-11-25 16:33:54 +08:00
}
2024-11-26 15:36:02 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
public void ClickPersonnelManagement()
{
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>");
ManagerPanel.gameObject.SetActive(true);
}
2024-11-25 16:33:54 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD>ϰ<EFBFBD>ť
public void ClickSureBtn()
{
SceneManager.LoadScene("Schedule_a_walkthrough");
}
2024-11-26 18:24:12 +08:00
public void ClickCloseBtn()
{
transform.gameObject.SetActive(false);
}
2024-11-25 16:33:54 +08:00
2024-11-25 17:58:45 +08:00
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>Ϣ
public void GetData()
2024-11-25 16:33:54 +08:00
{
2024-11-26 15:36:02 +08:00
ManagerPanel managerPanel = new ManagerPanel();
2024-11-25 17:16:41 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>м<EFBFBD><D0BC><EFBFBD>
if (Input.GetMouseButtonDown(0))
{
// ȷ<><C8B7> raycaster <20><> eventSystem <20><>Ϊ<EFBFBD><CEAA>
if (raycaster == null || eventSystem == null)
{
Debug.LogError("Raycaster <20><> EventSystem δ<><CEB4>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><E4A3AC><EFBFBD><EFBFBD> Inspector <20>н<EFBFBD><D0BD>з<EFBFBD><D0B7>䡣");
return;
}
// <20><><EFBFBD><EFBFBD> PointerEventData <20><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-11-25 17:16:41 +08:00
PointerEventData pointerData = new PointerEventData(eventSystem);
2024-11-25 17:58:45 +08:00
pointerData.position = Input.mousePosition;//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
2024-11-25 17:16:41 +08:00
// <20><><EFBFBD>ڴ洢<DAB4><E6B4A2><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>
List<RaycastResult> results = new List<RaycastResult>();
// <20><><EFBFBD>߼<EFBFBD><DFBC><EFBFBD> UI
2024-11-25 17:16:41 +08:00
raycaster.Raycast(pointerData, results);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>
foreach (RaycastResult result in results)
{
// <20><><EFBFBD><EFBFBD><E2B5BD><EFBFBD><EFBFBD><EFBFBD>˰<EFBFBD>ť
Button clickedButton = result.gameObject.GetComponent<Button>();
2024-11-25 17:16:41 +08:00
if (clickedButton != null)
{
Text buttonText = clickedButton.GetComponentInChildren<Text>();
2024-11-25 17:58:45 +08:00
if (buttonText != null && buttonText.tag == Tags.people)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD>ȡ<EFBFBD><C8A1>ǩΪ<C7A9><CEAA>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>Ϣ
2024-11-25 17:16:41 +08:00
{
2024-11-26 15:36:02 +08:00
2024-11-25 17:16:41 +08:00
name = buttonText.text;
Debug.Log(name);
}
2024-11-25 17:58:45 +08:00
else if (buttonText != null && buttonText.tag == Tags.scene)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD>ȡ<EFBFBD><C8A1>ǩΪ<C7A9><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
{
scene = buttonText.text;
Debug.Log(scene);
}
2024-11-25 17:58:45 +08:00
else if (buttonText != null && buttonText.tag == Tags.duty)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD>ȡ<EFBFBD><C8A1>ǩΪְ<CEAA><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
{
2024-11-26 15:36:02 +08:00
duty = buttonText.text;
Debug.Log(duty);
2024-11-25 17:16:41 +08:00
}
}
}
}
2024-11-25 16:33:54 +08:00
}
2024-11-26 15:36:02 +08:00
//<2F><><EFBFBD>ð<EFBFBD><C3B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public void SetText()
{
arrangeText.text = "[" + name + "]<5D><><EFBFBD><EFBFBD>[" + duty + "],λ<><CEBB>[" + scene + "]";
}
2024-11-25 16:33:54 +08:00
}