55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Data;
|
|||
|
using HK;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.Serialization;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
namespace Runtime.UI
|
|||
|
{
|
|||
|
public class Setting_Inventory : MonoBehaviour
|
|||
|
{
|
|||
|
[SerializeField] private Setting_Inventory_NoteBookInformationItem notebookPfb;
|
|||
|
[SerializeField] Button btnSubmit;
|
|||
|
|
|||
|
List<Setting_Inventory_NoteBookInformationItem> notebookList =
|
|||
|
new List<Setting_Inventory_NoteBookInformationItem>();
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
// TODO:读取本地持久化数据,如果持久化数据不存在,则使用Excel数据进行填充。存在则使用本地数据
|
|||
|
|
|||
|
foreach (var data in ExcelManager.Inventory.Datas.InventoryList)
|
|||
|
{
|
|||
|
var item = GameObject.Instantiate(notebookPfb, notebookPfb.transform.parent);
|
|||
|
item.gameObject.SetActive(true);
|
|||
|
var key = $"{data.GetType().Name}_{data.ID}";
|
|||
|
if (!PlayerPersistent.HasKey(key))
|
|||
|
{
|
|||
|
PlayerPersistent.SetInt(key, data.Count);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
data.Count = PlayerPersistent.GetInt(key);
|
|||
|
}
|
|||
|
|
|||
|
item.SetData(data);
|
|||
|
notebookList.Add(item);
|
|||
|
}
|
|||
|
|
|||
|
btnSubmit.onClick.AddListener(Submit);
|
|||
|
}
|
|||
|
|
|||
|
private void Submit()
|
|||
|
{
|
|||
|
// 保存
|
|||
|
foreach (var item in notebookList)
|
|||
|
{
|
|||
|
item.SaveData();
|
|||
|
}
|
|||
|
|
|||
|
gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|