Okay, this is kind of a repost of a previous thread except I’ve replicated the bug I was experiencing. So, I’m making an idle clicker rpg and I needed to switch to new scenes when clicking the screen. I watched a tutorial on writing a code for such a thing and learned to load a scene on index using a button press. Since the game is for mobile, the entire screen would act as a button in these circumstances so I stretched a button over the canvas. I inserted the code as a component and set the button to use the code to load a scene on index. I was feeling lazy and just disabled the image and text parts of the standard Unity UI button and started up the game. Sadly, the button never did anything in game. I looked over everything multiple times and set the button back to its default state and tried it again. To my amazement, the button worked but I didn’t want to see the button so I disabled the text and image features again and tested it; the button went back to being useless. I was confused and upset at the time and thought about what I could do and decided to try enabling the image and text features but removing the image and deleting the text. This solution worked. I then wanted to experiment with different combinations of enabled and disabled button features that might work. I found that only the text portion of the button need to be enabled in order for the button to function. I just wanted to know if anyone else has had similar problems with actual unity elements not working properly when using script commands. I will link the code I used in the thread if anyone wants to test it themselves. I believe it came from the live training video posted by unity in 2016, but I can’t be too sure.
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class StartSceneOnClick : MonoBehaviour {
public void LoadByIndex (int SceneIndex)
{
SceneManager.LoadScene (SceneIndex);
}
}