I am trying to figure this out.
I built an .apk to load onto my device to test it out. I am not using unity remote, as it does not work for me. Nor’ am I using any debug services like ADB as my usb port on my phone is not working.
I run the application fine on the phone. I have a Samsung S9+ with the highest API being 29 I believe currently. I wanted to assume that the OnClick() callback function doesn’t work with Touch Phones, but I couldn’t find a google search that supported that argument.
I have a start button that changes the scene to the main level selector. I use Application.LoadScene(int sceneIndex) to change scenes. This is where I assumed the OnClick() callback doesn’t work because the animation for the button script works perfectly; it does its thing.
Is there something I am missing?
Here is the code. Everything runs completely fine on unity editor and PC.
using UnityEngine; using System.Collections; using System.Collections.Generic; using System; using SimpleJSON; public class HomeController : BaseController { private const int PLAY = 0, RATE = 2; public ToggleButton tgSound, tgMusic; protected override void Start() { base.Start(); GameState.currentMode = GameState.GameMode.Challenge; tgSound.IsOn = Sound.instance.IsEnabled(); tgMusic.IsOn = Music.instance.IsEnabled(); Music.instance.Play(Music.Type.MainMusic, true); } public void OnToggleSound() { tgSound.Toggle(); Sound.instance.SetEnabled(tgSound.IsOn); Sound.instance.PlayButton(); } public void OnToggleMusic() { tgMusic.Toggle(); Music.instance.SetEnabled(tgMusic.IsOn, true); Sound.instance.PlayButton(); } public void OnClick(int index) { Debug.Log("Button Pressed"); Sound.instance.PlayButton(); Debug.Log("Sound Played"); switch (index) { case PLAY: CUtils.LoadLevel(1); Debug.Log("Level Loaded"); GameState.currentMode = GameState.GameMode.Challenge; break; case RATE: CUtils.RateGame(); break; } } } ` This code handles the actual scene change. ``
public static void LoadLevel(int levelIndex) { SceneManager.LoadScene(levelIndex); SetPreviousScene(); }
`