Rather than click on the character to select it, I want to make buttons to select each unit. I’ve worked ahead in the course and have seen how we instantiate buttons for each character’s actions. I’ve adapted the code as follows:
}
private void CreateUnitActionButtons()
{
foreach(Transform buttonTransform in characterActionButtonContainerTransform)
{
Destroy(buttonTransform.gameObject);
}
foreach(GameObject gameObject in characterGameObjectList) //The array will have multiple functions, based on what unit we are selecting
{
Debug.Log(gameObject.name);
Transform characterActionButtonTransform = Instantiate(characterActionButtonPrefab, characterActionButtonContainerTransform); //We create a button for each relevant section
actionButtonUI = characterActionButtonTransform.GetComponent<CharacterActionButtonUI>();
actionButtonUI.textMeshPro.text = gameObject.name;
actionButtonUI.unitAttachedToButton = gameObject;
}
//Debug.Log(characterActionButtonUIList);
}
The buttons are labelled properly, which means they are reading each unit properly. I don’t know how to send a signal back to the specific character, to indicate that when I click on their name, they should be selected.
Any advice, or hints on how to get started?