using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; public class MinionBar : MonoBehaviour { public GameObject[] minionTypes; public GameObject minionIconPrefab; MinionIcon[] minionIcons; int currentIndex; public void Start() { minionIcons = new MinionIcon[minionTypes.Length]; for (int i=0; i(); // minionIcons[i].icon = minionTypes.icon; // TODO minionIcons[i].indexInMinionList = i; minionIcons[i].UnSelect(); } minionIcons[currentIndex].Select(); } public void ChangeSelectedIcon(InputAction.CallbackContext context) { float floatDelta = context.ReadValue(); int delta = 0; if(floatDelta > 0.5f) { delta = 1; } else if(floatDelta < -0.5f) { delta = -1; } minionIcons[currentIndex].UnSelect(); currentIndex += delta; if(currentIndex >= minionIcons.Length) { currentIndex = 0; } else if(currentIndex < 0) { currentIndex = minionIcons.Length - 1; } minionIcons[currentIndex].Select(); // print("new selected minion type : " + currentIndex.ToString()); } public GameObject GetCurrentMinion() { return minionTypes[currentIndex]; } }