How to log in an android game?
Hi there!
Sorry for the noob question, but how to I view Debug.Log when I have built the game as an .APK on an Android device? If there is something else than Debug.Log, what is it? I just need to log some lines in my script while it is running on an Android device(NOT EDITOR) since I'm having issues with Google Play Leaderboard login.
Thank you so much!
Answer by mateo4632 · Feb 09, 2016 at 02:11 AM
using UnityEngine;
using System.Collections;
public class GuiTextDebug : MonoBehaviour {
private float windowPosition = -440.0f;
private int positionCheck = 2;
private static string windowText = "";
private Vector2 scrollViewVector = Vector2.zero;
private GUIStyle debugBoxStyle;
private float leftSide = 0.0f;
private float debugWidth = 420.0f;
public bool debugIsOn = false;
public static void debug(string newString)
{
windowText = newString + "\n" + windowText;
UnityEngine.Debug.Log(newString);
}
void Start () {
debugBoxStyle = new GUIStyle();
debugBoxStyle.alignment = TextAnchor.UpperLeft;
leftSide = 120; //Screen.width - debugWidth - 3;
}
void OnGUI () {
if (debugIsOn) {
GUI.depth = 0;
GUI.BeginGroup (new Rect(windowPosition, 40.0f, leftSide, 200.0f));
scrollViewVector = GUI.BeginScrollView (new Rect (0, 0.0f, debugWidth, 200.0f), scrollViewVector, new Rect (0.0f, 0.0f, 400.0f, 2000.0f));
GUI.Box (new Rect (0, 0.0f, debugWidth - 20.0f, 2000.0f), windowText, debugBoxStyle);
GUI.EndScrollView();
GUI.EndGroup ();
if (GUI.Button(new Rect (leftSide, 0.0f,75.0f,40.0f), "Debug")){
if (positionCheck == 1){
windowPosition = -440.0f;
positionCheck = 2;
}
else {
windowPosition = leftSide;
positionCheck = 1;
}
}
if (GUI.Button(new Rect (leftSide + 80f,0.0f,75.0f,40.0f),"Clear")){
windowText = "";
}
}
}
}
This is an older code but should still work just add it a game object. Let me know if this worked for you!
Your answer
Follow this Question
Related Questions
transform.position not working on phone (Cardboard) 0 Answers
how to make my character move up and down (Vertical) in android control 0 Answers
Rotate character 0 Answers
How do i fix this problem 1 Answer
Help with a C# script .SetActive 1 Answer