You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/GleyPlugins/Ads/Scripts/ScreenWriter.cs

43 lines
1.3 KiB
C#

3 months ago
namespace GleyMobileAds
{
using UnityEngine;
/// <summary>
/// writes text on screen if debug is enable from Settings Window
/// </summary>
public class ScreenWriter : MonoBehaviour
{
private static string logMessage;
private static ScreenWriter instance;
public static void Write(object message)
{
if (Advertisements.Instance.debug == true)
{
if (instance == null)
{
GameObject go = new GameObject();
go.name = "DebugMessagesHolder";
instance = go.AddComponent<ScreenWriter>();
logMessage += ("\nDebugMessages instance created on DebugMessagesHolder");
}
logMessage += "\n" + message.ToString();
}
}
void OnGUI()
{
if (Advertisements.Instance.debug == true)
{
if (logMessage != null)
{
GUI.Label(new Rect(0, 0, Screen.width, Screen.height), logMessage);
if (GUI.Button(new Rect(Screen.width - 100, Screen.height - 100, 100, 100), "Clear"))
{
logMessage = null;
}
}
}
}
}
}