UI代码提交

This commit is contained in:
huyulong 2024-11-25 17:58:45 +08:00
parent b363e6a670
commit c42747c233
2 changed files with 7 additions and 19 deletions

View File

@ -40,20 +40,6 @@ public class Panel : MonoBehaviour
GetData(); GetData();
} }
public void SetName()
{
}
public void SetDuty()
{
}
public void SetScene()
{
}
//处理点击选择剧本按钮 //处理点击选择剧本按钮
@ -100,7 +86,7 @@ public class Panel : MonoBehaviour
//获取鼠标点击位置的信息
public void GetData() public void GetData()
{ {
// 当鼠标左键按下时进行检测 // 当鼠标左键按下时进行检测
@ -115,7 +101,7 @@ public class Panel : MonoBehaviour
// 创建 PointerEventData 来记录点击事件的数据 // 创建 PointerEventData 来记录点击事件的数据
PointerEventData pointerData = new PointerEventData(eventSystem); PointerEventData pointerData = new PointerEventData(eventSystem);
pointerData.position = Input.mousePosition; pointerData.position = Input.mousePosition;//获取鼠标点击的位置
// 用于存储射线检测的结果 // 用于存储射线检测的结果
List<RaycastResult> results = new List<RaycastResult>(); List<RaycastResult> results = new List<RaycastResult>();
@ -132,17 +118,17 @@ public class Panel : MonoBehaviour
if (clickedButton != null) if (clickedButton != null)
{ {
Text buttonText = clickedButton.GetComponentInChildren<Text>(); Text buttonText = clickedButton.GetComponentInChildren<Text>();
if (buttonText != null && buttonText.tag == Tags.people) if (buttonText != null && buttonText.tag == Tags.people)//这里可以获取标签为人员的信息
{ {
name = buttonText.text; name = buttonText.text;
Debug.Log(name); Debug.Log(name);
} }
else if (buttonText != null && buttonText.tag == Tags.scene) else if (buttonText != null && buttonText.tag == Tags.scene)//这里可以获取标签为场景的信息
{ {
scene = buttonText.text; scene = buttonText.text;
Debug.Log(scene); Debug.Log(scene);
} }
else if (buttonText != null && buttonText.tag == Tags.duty) else if (buttonText != null && buttonText.tag == Tags.duty)//这里可以获取标签为职责的信息
{ {
duty = buttonText.text; duty = buttonText.text;
Debug.Log(duty); Debug.Log(duty);

View File

@ -8,3 +8,5 @@ public class Tags
public const string duty = "Duty"; public const string duty = "Duty";
public const string scene = "Scene"; public const string scene = "Scene";
} }