When the game is released to the phone debugging sometimes need to print some information on the screen, I wrote a Gadget class, share it, with the Ongui, very simple, directly on the code
Using Unityengine;
Using System.Collections;
Using System.Collections.Generic;
public class Onguidebug:monobehaviour {
public static Onguidebug Instance;
public int FontSize = 40;
public int labelheight = 40;
int labelpos_y = 0;
Message list
static list<string> msglist = new list<string> ();
Guistyle style = null;
void Awake () {
style = new Guistyle ();
Style.fontsize = fontSize;
Style.normal.textColor = color.red;
Instance = this;
Dontdestroyonload (Gameobject);
}
public static void Addmsg (String msg)
{
if (!msglist.contains (msg))
Msglist.add (msg);
}
void Ongui ()
{
Labelpos_y = 10;
for (int i = 0; i < Msglist.count; i++)
{
Gui. Label (New Rect (Ten, Labelpos_y, Labelheight, msglist[i], style);
Labelpos_y + = Labelheight;
}
if (labelpos_y >= screen.height)
{
if (Msglist.count > 0)
Msglist.removeat (0);
}
}
void Start ()
{
Invokerepeating ("Testmsg", 1, 1);
}
int counter = 0;
void Testmsg ()
{
Msglist.add ("Test" + (++counter). ToString ());
}
}
In fact, if you use a text field with a scroll bar or scroll view what might be better to use, you can try it.
Share a tool class that uses Ongui to print debug information on your phone