2025-10-17 17:28:16 +08:00

116 lines
3.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections;
using System.Collections.Generic;
using Unity.XR.PXR;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using YiLiao.JingLuoXueWei;
using ZXKFramework;
public class SouSuoPanel : UIBase
{
public override string GroupName => typeof(SouSuoPanel).Name;
public override string Name => typeof(SouSuoPanel).Name;
Button exit_Btn;
InputField souSuo_InputField;
List<JingLuoSmall> allJingLuoSmall;
List<Button> allSouSuoBtn;
public override void Init(IUIManager uictrl)
{
base.Init(uictrl);
allSouSuoBtn = new List<Button>();
exit_Btn = transform.FindFirst<Button>("Exit_Btn");
exit_Btn.onClick.AddListener(() =>
{
uiManager.CloseUI<SouSuoPanel>();
});
allJingLuoSmall = MVC.GetModel<GameModel>().excelData.allJingLuoSmall;
souSuo_InputField = transform.FindFirst<InputField>("souSuo_Input");
souSuo_InputField.onValueChanged.AddListener(InputValueChanged);
souSuo_InputField.onSubmit.AddListener(InputSubmit);
}
private void InputSubmit(string arg0)
{
if (allSouSuoBtn.Count > 0)
{
for (int i = 0; i < allSouSuoBtn.Count; i++)
{
Destroy(allSouSuoBtn[i]);
}
}
for (int i = 0; i < allJingLuoSmall.Count; i++)
{
if (allJingLuoSmall[i].XueWeiName_NoPinYin.Contains(arg0))
{
//souSuo_InputField.text = $"{arg0}";
GameObject go = Resources.Load<GameObject>("souSuoBtn");
GameObject obj = GameObject.Instantiate(go, transform.FindFirst("souSuoBtnContent").transform);
obj.GetComponentInChildren<Text>().text = allJingLuoSmall[i].XueWeiName_NoPinYin;
Button btn = obj.GetComponent<Button>();
allSouSuoBtn.Add(btn);
//TODO ËÑË÷°´Å¥µã»÷ʼþ
}
}
}
private void InputValueChanged(string arg0)
{
transform.FindFirst("Placeholder").SetActive(false);
}
//void Update()
//{
// // »ñÈ¡EventSystemʵÀý£¨³¡¾°ÖÐÐèÏÈÌí¼ÓEventSystem×é¼þ£©
// EventSystem eventSystem = EventSystem.current;
// if (eventSystem == null)
// {
// souSuo_InputField.text = "³¡¾°ÖÐδÕÒµ½EventSystem£¬ÇëÏÈÌí¼Ó£¡";
// return;
// }
// // »ñÈ¡µ±Ç°¾Û½¹µÄÓÎÏ·¶ÔÏó
// GameObject focusedObj = eventSystem.currentSelectedGameObject;
// if (focusedObj == null)
// {
// souSuo_InputField.text = "µ±Ç°ÎÞUIÔªËØ¾Û½¹";
// return;
// }
// // ÅжϾ۽¹¶ÔÏóµÄÀàÐÍ
// InputField inputField = focusedObj.GetComponent<InputField>();
// if (inputField != null)
// {
// // Èô¾Û½¹¶ÔÏóÊÇInputField£¬¿É½øÒ»²½ÅжÏÊÇ·ñÕæµÄ´¦ÓÚÊäÈë½¹µã
// if (inputField.isFocused)
// {
// //Debug.Log($"½¹µã£º{inputField.name}");
// souSuo_InputField.text = $"½¹µã£º{inputField.name}";
// }
// return;
// }
// Button button = focusedObj.GetComponent<Button>();
// if (button != null)
// {
// //Debug.Log($"½¹µã£º{button.name}");
// souSuo_InputField.text = $"½¹µã£º{button.name}";
// return;
// }
// // ÆäËû¿É½»»¥×é¼þ£¨ÈçSlider¡¢ToggleµÈ£©¿ÉÀàËÆÅжÏ
// Selectable selectable = focusedObj.GetComponent<Selectable>();
// if (selectable != null)
// {
// //Debug.Log($"½¹µã£º{selectable.name}");
// souSuo_InputField.text = $"½¹µã£º{selectable.name}";
// }
//}
}