Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class DebugConsole : MonoBehaviour
- {
- private static string debugText = "Hello, world.\n";
- private static bool consoleOn = false;
- private static Vector2 scrollPosition;
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.Tab))
- {
- consoleOn = !consoleOn;
- }
- }
- public void Log(string text)
- {
- debugText = text + "\n" + debugText;
- const int max = 1024;
- if (debugText.Length > max)
- {
- debugText = debugText.Substring(0, max);
- }
- }
- void OnGUI()
- {
- if (consoleOn)
- {
- scrollPosition = GUILayout.BeginScrollView (
- scrollPosition, GUILayout.Width (400), GUILayout.Height (100));
- GUILayout.Label (debugText);
- GUILayout.EndScrollView ();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement