修改AR游戏接口使用sg自动生成,修改AR宠物信息录入脚本编码

This commit is contained in:
YL 2025-04-14 14:13:15 +08:00
parent a51e633949
commit 3c8dda6ebf
5 changed files with 41 additions and 71 deletions

View File

@ -6,6 +6,7 @@ namespace GameLogic
[EventInterface(EEventGroup.GroupUI)]
public interface UIARGameInterface
{
void GetCurGameName(string gamename);
public void GetCurGameName(string curgamename);
public void WidgetIDSelect(int widgetID);
}
}

View File

@ -30,10 +30,10 @@ namespace GameLogic
private async UniTaskVoid OnClickSelectBtn()
{
await UniTask.Yield();
GameEvent.SendWidgetSelected(_widgetId);
GameEvent.Send<string>("UIARGameInterface", m_textName.text);
GameEvent.Get<UIARGameInterface>().WidgetIDSelect(_widgetId);
GameEvent.Get<UIARGameInterface>().GetCurGameName(this.m_textName.text);
}
#endregion
@ -44,19 +44,12 @@ namespace GameLogic
this.m_textName.text = gameName;
LockFunc(islock);
GameEvent.AddWidgetSelectedListener(OnWidgetSelected);
GameEvent.AddEventListener<int>(UIARGameInterface_Event.WidgetIDSelect, WidgetIDSelect);
}
protected override void OnDestroy()
public void WidgetIDSelect(int widgetID)
{
base.OnDestroy();
GameEvent.RemoveWidgetSelectedListener(OnWidgetSelected);
}
private void OnWidgetSelected(int selectedWidgetId)
{
if (_widgetId == selectedWidgetId)
if (_widgetId == widgetID)
{
OnClickSelect();
}

View File

@ -32,23 +32,10 @@ namespace GameLogic
private async UniTaskVoid OnClickSureBtn()
{
await UniTask.Yield();
Debug.LogError(curgamename);
}
#endregion
protected override void RegisterEvent()
{
base.RegisterEvent();
GameEvent.AddEventListener<string>(
"UIARGameInterface",
(gamename) =>
{
this.curgamename = gamename;
});
}
protected override void OnCreate()
{
base.OnCreate();
@ -58,6 +45,18 @@ namespace GameLogic
RegisterEvent();
}
protected override void RegisterEvent()
{
base.RegisterEvent();
GameEvent.AddEventListener<string>(UIARGameInterface_Event.GetCurGameName,GetCurGameName);
}
public void GetCurGameName(string gameName)
{
this.curgamename = gameName;
}
private async void LoadARGameData()
{
aRGame = GameModule.Resource.LoadAsset<ARGameScriptableObject>(GAME_DATA_PATH);

View File

@ -1,18 +1,15 @@
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using TEngine;
using TMPro;
using System.Security.Policy;
using Lightbug.Utilities;
using NodeCanvas.DialogueTrees;
namespace GameLogic
{
[Window(UILayer.UI)]
class UIARPetInfoRecWindow : UIWindow
{
#region
#region
private Button m_btnPetImg;
private Image m_imgPet;
private TMP_InputField m_tmpinputPetName;
@ -42,8 +39,8 @@ namespace GameLogic
}
#endregion
#region
private async UniTaskVoid OnClickPetImgBtn() // 开启摄像头拍照,给宠物拍照
#region
private async UniTaskVoid OnClickPetImgBtn() // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
await UniTask.Yield();
m_imgPet.gameObject.SetActive(true);
@ -52,12 +49,12 @@ namespace GameLogic
private async UniTaskVoid OnClickSelectTypeBtn()
{
await UniTask.Yield();
SelectTypeFunc("波斯猫");
SelectTypeFunc("<EFBFBD><EFBFBD>˹è");
}
private async UniTaskVoid OnClickSelectZoneBtn()
{
await UniTask.Yield();
SelectZoneFunc("ShangHai->徐汇区");
SelectZoneFunc("ShangHai-><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
private async UniTaskVoid OnClickARPreBtn()
{
@ -67,9 +64,9 @@ namespace GameLogic
#endregion
/// <summary>
/// 选择宠物得品种
/// 选择品种
/// </summary>
/// <param name="PetType">品种</param>
/// <param name="PetType">宠物品种</param>
private void SelectTypeFunc(string PetType)
{
this.m_tmptextType.text = PetType;
@ -77,54 +74,54 @@ namespace GameLogic
}
/// <summary>
/// 选择地区
/// 选择地区
/// </summary>
/// <param name="Zone">地区</param>
/// <param name="Zone">地区</param>
private void SelectZoneFunc(string Zone)
{
this.m_tmptextZone.text = Zone;
this.m_tmptextZone.color = Color.black;
}
// 打开宠物预览UI
// 打开宠物预览UI
private void OpenPetPreviewUI()
{
GameModule.UI.ShowUI<UIARPreviewWindow>();
// 触发事件
GameEvent.Send<string, string, string, string, string>("UIPetInfoRecInterface", m_tmpinputPetName.text, m_tmptextType.text, m_tmpinputOwnName.text, m_tmptextZone.text, m_tmpinputNumber.text);
}
// 检查宠物信息
// 检查宠物信息
private void CheckPetInfoInputFunc()
{
if (string.IsNullOrEmpty(m_tmpinputPetName.text))
{
Debug.LogError("请填入宠物名字");
Debug.LogError("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
return;
}
else if (m_tmptextType.text == "请选择品种")
else if (m_tmptextType.text == "<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD>")
{
Debug.LogError("请选择品种");
Debug.LogError("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD>");
return;
}
else if (string.IsNullOrEmpty(m_tmpinputOwnName.text))
{
Debug.LogError("请填入宠物主人名字");
Debug.LogError("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
return;
}
else if (m_tmptextZone.text == "请选择地区地址")
else if (m_tmptextZone.text == "<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ")
{
Debug.LogError("请选择地区地址");
Debug.LogError("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ");
return;
}
else if (string.IsNullOrEmpty(m_tmpinputNumber.text))
{
Debug.LogError("请输入宠物主人号码");
Debug.LogError("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><EFBFBD><EFBFBD>");
return;
}
else if (m_tmpinputNumber.text.Length != 11 || m_tmpinputNumber.text[0] != '1')
{
Debug.LogError("请输入以 1 开头的 11 位手机号码");
Debug.LogError("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 <20><>ͷ<EFBFBD><CDB7> 11 λ<>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>");
return;
}
else

View File

@ -593,25 +593,5 @@ namespace TEngine
{
_eventMgr.Init();
}
/// <summary>
/// AR游戏事件
/// </summary>
/// <param name="widgetId"></param>
public static void SendWidgetSelected(int widgetId)
{
_eventMgr.Dispatcher.Send(RuntimeId.ToRuntimeId("WidgetSelected"), widgetId);
}
public static bool AddWidgetSelectedListener(Action<int> handler)
{
return _eventMgr.Dispatcher.AddEventListener(RuntimeId.ToRuntimeId("WidgetSelected"), handler);
}
public static void RemoveWidgetSelectedListener(Action<int> handler)
{
_eventMgr.Dispatcher.RemoveEventListener(RuntimeId.ToRuntimeId("WidgetSelected"), handler);
}
}
}