Hello!
My goal is to have 4 different GameObjects that are SetActive(true); or SetActive(false); based on when the button is pressed or when it is rolled over with the mouse. They are all UI Images.

I currently have this working for 3 States (Normal, Normal-Rollover and Selected) in my script that I have pasted below but I can’t figure out how to add the extra 4th State being “Selected-Rollover”.
What I want to add to the code:
** if Normal = true then the rollover image should be Normal-Rollover
else if
Selected = true then the rollover image should be Selected-Rollover**
This is my Button Controller script:
public class ButtonController : MonoBehaviour
{
public GameObject normal;
public GameObject selected;
public GameObject normalRollover;
public GameObject selectedRollover;
public void ActiveButton()
{
// Sets the button to Selected when you click on it
selected.SetActive(true);
normal.SetActive(false);
}
public void DeActiveButton()
{
// Sets the button back to Normal when you click on another Button
normal.SetActive(true);
selected.SetActive(false);
}
public void OnPointerEnter()
{
normalRollover.SetActive(true);
normal.SetActive(false);
}
public void OnPointerExit()
{
normal.SetActive(true);
normalRollover.SetActive(false);
}
This is my GameManager script
public Button[] panelHatButtons;
// NORMAL ROLLOVER
public void PanelHatPointerEnter(int buttonNum)
{ // Gets sent the int index of the button from the OnPointerEnter Event Trigger
for (int i = 0; i < panelHatButtons.Length; i++)
{ // Loop through the array buttons
if (i == buttonNum)
{
panelHatButtons*.GetComponent<ButtonController>().OnPointerEnter();*
}
}
}
public void PanelHatPointerExit(int buttonNum)
{ // Gets sent the int index of the button from the OnPointerExit Event Trigger
for (int i = 0; i < panelHatButtons.Length; i++)
{ // Loop through the array buttons
if (i == buttonNum)
{
panelHatButtons*.GetComponent().OnPointerExit();*
}
}
}
// BUTTON SELECTED
public void PanelHatButtonPressed(int buttonNum)
{ // Gets sent the int index of the button from the OnClick()
for (int i = 0; i < panelHatButtons.Length; i++)
{ // Loop through the array buttons
if (i == buttonNum)
{ /
panelHatButtons*.GetComponent().ActiveButton();*
}
else
{ // This is every other button
panelHatButtons*.GetComponent().DeActiveButton();*
}
}
}
Any advice/tips you could offer would be super appreciated!
Thank you so much!
@evskii Hello! I hope you don’t mind me tagging you, I thought I would since I’m using the script you helped me with a few days ago and I have just attempted to add Rollover states to it. I got stuck on this part. Thank you!