完成预览确认后宠物数据存储

This commit is contained in:
YL 2025-04-09 15:12:37 +08:00
parent 4bb91f4082
commit 6fc123fd82
2 changed files with 61 additions and 9 deletions

File diff suppressed because one or more lines are too long

View File

@ -10,6 +10,9 @@ namespace GameLogic
[Window(UILayer.UI)]
class UIARPreviewWindow : UIWindow
{
public PetResponseScriptableObject petData; // 宠物数据本地配置
private const string PET_DATA_PATH = "PetResponseData"; // 宠物数据本地配置路径
#region
private TextMeshProUGUI m_tmptextPetName;
private TextMeshProUGUI m_tmptextPetType;
@ -33,6 +36,8 @@ namespace GameLogic
private async UniTaskVoid OnClickSureBtn() // 确认
{
await UniTask.Yield();
PetInfoSave();
GameModule.UI.CloseUI<UIARPreviewWindow>();
await ARBrochureHomeSystem.Instance.CoroShowAllMainUI();
}
@ -76,5 +81,29 @@ namespace GameLogic
GameModule.UI.CloseUI<UIARPetInfoRecWindow>();
}
private void PetInfoSave()
{
petData = GameModule.Resource.LoadAsset<PetResponseScriptableObject>(PET_DATA_PATH);
if (petData == null)
{
Debug.LogError("加载宠物ScriptableObject配置数据路径错误" + PET_DATA_PATH);
}
else
{
// 创建一个新的 SkinData 实例
PetResponseScriptableObject.PetData newSkinData = new PetResponseScriptableObject.PetData();
newSkinData.id = 222;
newSkinData.openid = "oCD4_4zqcfgo-X66d7pdb7Mn0a3w";
newSkinData.pic = "https://arp3.arsnowslide.com/0cc96a251c44408b9c54cec443483d33.jpg?versionId=G00111959395337FFFFF981700E681A1";
newSkinData.name = this.m_tmptextPetName.text;
newSkinData.type = this.m_tmptextPetType.text;
newSkinData.master = this.m_tmptextOwnName.text;
newSkinData.place = this.m_tmptextPetOwnOri.text;
newSkinData.phone = this.m_tmptextPetOwnNum.text;
petData.responseData.data.Add(newSkinData);
}
}
}
}