55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Cielonos.MainGame.Inventory;
|
|
using SLSFramework.UI;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.UI
|
|
{
|
|
public class MainWeaponUIArea : UIElementBase
|
|
{
|
|
public MainWeaponBase mainWeapon;
|
|
|
|
public GameObject functionIconPrefab;
|
|
public RectTransform functionIconContainer;
|
|
|
|
public MainWeaponDisplayer displayer;
|
|
public List<MainWeaponFunctionIcon> functionIcons;
|
|
|
|
private void Awake()
|
|
{
|
|
functionIcons = new List<MainWeaponFunctionIcon>();
|
|
}
|
|
|
|
public void Initialize(MainWeaponBase mainWeapon)
|
|
{
|
|
this.mainWeapon = mainWeapon;
|
|
|
|
ClearIcons();
|
|
|
|
foreach (KeyValuePair<string, RuntimeFunctionUnit> unit in mainWeapon.functionSm.functionUnits)
|
|
{
|
|
if (!unit.Value.data.shownInUI) continue;
|
|
|
|
MainWeaponFunctionIcon icon = Instantiate(functionIconPrefab, functionIconContainer).GetComponent<MainWeaponFunctionIcon>();
|
|
icon.Initialize(unit.Value);
|
|
functionIcons.Add(icon);
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
functionIcons.ForEach(icon => icon.UpdateUI());
|
|
}
|
|
|
|
private void ClearIcons()
|
|
{
|
|
foreach (MainWeaponFunctionIcon icon in functionIcons)
|
|
{
|
|
Destroy(icon.gameObject);
|
|
}
|
|
|
|
functionIcons.Clear();
|
|
}
|
|
}
|
|
} |