UI Button not working?
I have an EventSystem. Tried with the EventSystem option Force Module Active. I have only one Canvas. The Canvas has a Graphic Raycaster component. I've tried with and without a Graphic Raycaster component on the button's parent (canvas child) Canvas Render Mode is set to Screen Space - Camera, tried with Overlay I tried making the button a child object of the Canvas. The button is marked as interactable and calls a function from a script. There are no other HUD objects that are at the same place as the button. I've added using UnityEngine.EventSystems; to my script. Tried putting the button on different places in the hierarchy. Tried playing the game and restarting Unity I added a Canvas Group to my Canvas I tried moving the button around in my Hierarchy
Here's my C# for the button
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class ChangeApp : MonoBehaviour
{
public SpriteRenderer part;
public Sprite[] options;
public int index;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
for (int i = 0; i < options.Length; i++)
{
if (i == index)
{
part.sprite = options[i];
}
}
}
public void Swap()
{
if (index < options.Length - 1)
{
index++;
}
else
{
index = 0;
}
}
}
Your answer
Follow this Question
Related Questions
UI buttons don't work with Canvas Render Mode: Screen Space - Camera. 2 Answers
How do I make a UI button imitating mouse click 0 Answers
How can I check if there is no free space in the Text component? 1 Answer
OnPointerEnter blocked by something 2 Answers
If I disable/enable my canvas (pause game menu), controller navigation in the canvas stops to work? 1 Answer