HATEBIN
>
using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UnitActionSystemUI : MonoBehaviour { [SerializeField] private Transform actionButtonPrefab; [SerializeField] private Transform actionButtonContainerTransform; private void Start() { // why the fuck do we += this?! -Dino UnitActionSystem.Instance.OnSelectedUnitChanged += UnitActionSystem_OnSelectedUnitChanged; CreateUnitActionButtons(); } private void CreateUnitActionButtons() { // nuke any existing buttons foreach(Transform buttonTransform in actionButtonContainerTransform) { Destroy(buttonTransform.gameObject); } // get the selected unit Unit selectedUnit = UnitActionSystem.Instance.GetSelectedUnit(); // create the appropriate buttons for this unit. foreach(BaseAction baseAction in selectedUnit.GetBaseActionArray()) { Transform actionButtonTransform = Instantiate(actionButtonPrefab, actionButtonContainerTransform); ActionButtonUI actionButtonUI = actionButtonTransform.GetComponent
(); actionButtonUI.SetBaseAction(baseAction); } } private void UnitActionSystem_OnSelectedUnitChanged(object sender, EventArgs e) { CreateUnitActionButtons(); } }