【拆分mono】临时拆分 UI_CurrencyList

main
刘涛 2025-04-29 19:04:41 +08:00
parent f078f1641a
commit 97fb75b2f7
4 changed files with 28 additions and 9 deletions

View File

@ -10,5 +10,11 @@
void OnCurrencyIDChanged();
bool IsShowPlus { get; set; }
UI_CurrencyItem monoInst
{
get;
set;
}
}
}

View File

@ -28,11 +28,18 @@ public class UI_CurrencyItem : MonoBehaviour
}
}
public ICurrencyItem logic;
private void Awake()
private ICurrencyItem _logic;
public ICurrencyItem logic
{
logic.FakeAwake();
get
{
return _logic;
}
set
{
_logic = value;
_logic.FakeAwake();
}
}
void OnCurrencyIDChanged()

View File

@ -65,10 +65,12 @@ public class UI_CurrencyList: UINode
{
// Gameplay.UI.Common.UI_CurrencyItemLogic
// TODO: 临时通过反射创建
var type = System.Type.GetType("Gameplay.UI.Common.UI_CurrencyItemLogic");
var type = System.Type.GetType("Gameplay.UI.Common.UI_CurrencyItemLogic, GamePlay");
if (type != null)
{
currencyItemMono.logic = (ICurrencyItem)System.Activator.CreateInstance(type, currencyItemMono);
var inst = (ICurrencyItem)System.Activator.CreateInstance(type);
inst.monoInst = currencyItemMono;
currencyItemMono.logic = inst;
}
else
{

View File

@ -13,7 +13,11 @@ namespace Gameplay.UI.Common
{
public class UI_CurrencyItemLogic : ICurrencyItem
{
public UI_CurrencyItem monoInst;
public UI_CurrencyItem monoInst
{
get;
set;
}
private TMP_Text _num;
private GameObject moneyObj;
@ -40,9 +44,9 @@ namespace Gameplay.UI.Common
set { isShowPlus = value; }
}
public UI_CurrencyItemLogic(UI_CurrencyItem inst)
public UI_CurrencyItemLogic()
{
monoInst = inst;
}
public void FakeAwake()