using System; using Data; using HK; using TMPro; using UnityEngine; namespace Runtime.UI { public class Setting_Monetary_NoteBookInformationItem : MonoBehaviour { public TMP_Text notebookName; public TMP_InputField bookPrice; public TMP_InputField designPrice; public TMP_InputField discountPrice; NoteBookInformationData currentData; private void OnEnable() { if (currentData != null) { notebookName.text = currentData.BookChinName; bookPrice.text = currentData.BookPrice.ToString(); designPrice.text = currentData.DesignPrice.ToString(); discountPrice.text = currentData.DiscountPrice.ToString(); } } public void SetData(NoteBookInformationData data) { currentData = data; notebookName.text = data.BookChinName; bookPrice.text = data.BookPrice.ToString(); designPrice.text = data.DesignPrice.ToString(); discountPrice.text = data.DiscountPrice.ToString(); gameObject.SetActive(true); } public void SaveData() { var book = $"{currentData.GetType().Name}_{currentData.ID}_{currentData.BookPrice}"; PlayerPersistent.SetInt(book, currentData.BookPrice); var design = $"{currentData.GetType().Name}_{currentData.ID}_{currentData.DesignPrice}"; PlayerPersistent.SetInt(design, currentData.DesignPrice); var discount = $"{currentData.GetType().Name}_{currentData.ID}_{currentData.DiscountPrice}"; PlayerPersistent.SetInt(discount, currentData.DiscountPrice); currentData.BookPrice = int.Parse(bookPrice.text); currentData.DesignPrice = int.Parse(designPrice.text); currentData.DiscountPrice = int.Parse(discountPrice.text); } } }