UI on android

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using UnityEngine.SocialPlatforms;
using KidozSDK;
public class GameOver : MonoBehaviour {
    float timer;
    public GameObject PA;
    public GameObject PAY;
    public GameObject PAN;
    public GameObject IF;
    public AudioSource Timed;
    public string GetName = "";
    public bool OK;
    public GameObject KK;
    SaveData data;
    // Use this for initialization
    void Awake(){
        GameObject SV = GameObject.FindGameObjectWithTag ("SV");
        data = SaveData.Load (Application.streamingAssetsPath +"\\"+ "Jewelified.uml");
        data["GC"] = SV.GetComponent<SavedVars> ().GemsCaught;
        data.Save ();
        }
    void Start () {
        timer = 0;
    }

    public void Okay(){
        GameObject TXT = GameObject.FindGameObjectWithTag ("NI");
        GetName = TXT.GetComponent<Text> ().text;
        OK = true;
    }
    // Update is called once per frame
    void Update () {
        if (Input.GetKeyDown (KeyCode.Escape)) {
            SceneManager.LoadScene (1);
        }
        GameObject SV = GameObject.FindGameObjectWithTag ("SV");
        if ((!Timed.isPlaying) && (OK)) {
            SV.GetComponent<SavedVars> ().Name = GetName;
            PA.GetComponent<Text> ().enabled = true;
            PAY.GetComponent<Image> ().enabled = true;
            PAY.GetComponent<Button> ().enabled = true;
            PAN.GetComponent<Image> ().enabled = true;
            PAN.GetComponent<Button> ().enabled = true;
            IF.GetComponent<Image> ().enabled = false;
            IF.GetComponent<InputField> ().enabled = false;
            KK.GetComponent<Image> ().enabled = false;
            KK.GetComponent<Button> ().enabled = false;
            KK.GetComponentInChildren<Text> ().enabled = false;
        }
    }
    public void PlayAgain(){
        GameObject SaveG = GameObject.FindGameObjectWithTag ("SV");
        if (SaveG.GetComponent<SavedVars> ().GameMode == "PM") {
            SceneManager.LoadScene (5);
        }
        if (SaveG.GetComponent<SavedVars> ().GameMode == "Game") {
            SceneManager.LoadScene (1);
        }
        if (SaveG.GetComponent<SavedVars> ().GameMode == "Coinified"){
            SceneManager.LoadScene (7);
        }
    }
    public void GiveUp(){
        GameObject Save = GameObject.FindGameObjectWithTag("SV");
        Debug.Log (Save.GetComponent<SavedVars> ().GameMode);
        if (Save.GetComponent<SavedVars>().GameMode == "PM") {
           
            SceneManager.LoadScene (6);
        } if (Save.GetComponent<SavedVars> ().GameMode == "Coinified"){
            SceneManager.LoadScene (8);
        }
        if (Save.GetComponent<SavedVars> ().GameMode == "Game") {
            SceneManager.LoadScene (4);
        }
    }
    }

All of a sudden the button for one of the scenes stopped working and I don’t know why the button for the other scenes work, but the Okay function is the one the button is set under. It works on the PC, but not android.

Hi there

Here is a list of steps that might bring you on the right track to get it solved.

  1. Try making sure that the Click event of the GameObjects Button component is bound to the object iwth the script and the right method name.

  2. To check that the butto callback is being called insert a Debug.Log( “Okay invoked” ); and look in the adb log when running on Android device. If its being called then it’s not the Button logic that is the problem but rather the code being invoked that is the problem.

  3. If “okay invoked” is not in the adb log, maybe there is an object occluding the button on Android due to the difference in the screen aspect/size? Try setting the PC/Editor size of the GameView to something that resembles the Android screen dimensions / aspect ratio and see if it works…

How do I use ADB log?

HI Zuvizu

You can use the ADB log in the console by writing

PathTOAndroidSDKTools/adb logcat

Cheers!

PS. If you’re on OSX you can filter the output using “adb logcat | grep Unity”

Is there a tutorial video or a tutorial with screen shots? Sorry…

Oh, sorry it was under platform-tools in the android SDK, but what do you mean by the console do you mean command prompt?