2024-12-14 18:27:59 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
using QFramework;
|
|
|
|
|
|
using System.Collections.Generic;
|
2024-12-30 19:15:34 +08:00
|
|
|
|
using static OperationController;
|
2024-12-14 18:27:59 +08:00
|
|
|
|
|
|
|
|
|
|
namespace QFramework.Example
|
|
|
|
|
|
{
|
|
|
|
|
|
public class UIPointQuestionData : UIPanelData
|
|
|
|
|
|
{
|
|
|
|
|
|
public string paths;
|
|
|
|
|
|
}
|
|
|
|
|
|
public partial class UIPointQuestion : UIPanel
|
|
|
|
|
|
{
|
|
|
|
|
|
public Dictionary<GameObject, GameObject> pointMap = new Dictionary<GameObject, GameObject>();
|
|
|
|
|
|
protected override void OnInit(IUIData uiData = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
mData = uiData as UIPointQuestionData ?? new UIPointQuestionData();
|
|
|
|
|
|
// please add init code here
|
2025-01-09 09:43:15 +08:00
|
|
|
|
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
|
2024-12-30 19:15:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnStepChanged(StepStatusOnChange change)
|
|
|
|
|
|
{
|
|
|
|
|
|
Hide();
|
2024-12-14 18:27:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnOpen(IUIData uiData = null)
|
|
|
|
|
|
{
|
2025-01-09 13:35:04 +08:00
|
|
|
|
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged).UnRegisterWhenDisabled(gameObject);
|
2024-12-14 18:27:59 +08:00
|
|
|
|
mData = uiData as UIPointQuestionData ?? new UIPointQuestionData();
|
2024-12-31 13:54:29 +08:00
|
|
|
|
|
|
|
|
|
|
Content.RemoveAllChildren();
|
2024-12-14 18:27:59 +08:00
|
|
|
|
var paths = mData.paths.Split(',');
|
|
|
|
|
|
for (int i = 0; i < paths.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
string path = paths[i];
|
|
|
|
|
|
GameObject obj = Utility.FindObj(path);
|
|
|
|
|
|
if (obj != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
GameObject point = GameObject.Instantiate(PointPrefab.gameObject, Content);
|
|
|
|
|
|
point.name = (i + 1).ToString();
|
|
|
|
|
|
pointMap.Add(obj, point);
|
|
|
|
|
|
}
|
2024-12-31 17:27:27 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError($"û<><C3BB><EFBFBD>ҵ<EFBFBD>·<EFBFBD><C2B7>{path}");
|
|
|
|
|
|
}
|
2024-12-14 18:27:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (gameObject.activeSelf)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in pointMap)
|
|
|
|
|
|
{
|
|
|
|
|
|
Vector3 screenPosition = Camera.main.WorldToScreenPoint(item.Key.Position());
|
|
|
|
|
|
item.Value.transform.position = screenPosition;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnShow()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnHide()
|
|
|
|
|
|
{
|
2024-12-31 13:54:29 +08:00
|
|
|
|
pointMap.Clear();
|
2024-12-14 18:27:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnClose()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|