Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- namespace Sonar.Misc {
- public class DevelopmentBuildOnly : MonoBehaviour {
- public Text consoleText;
- public bool logStack;
- public Color errorColor;
- public Color warningColor;
- #if DEBUG
- [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
- private static void Init() {
- var instance = FindObjectOfType<DevelopmentBuildOnly>();
- Application.logMessageReceived += (message, stack, type) => {
- var color = Color.white;
- switch(type) {
- case LogType.Assert:
- case LogType.Error:
- case LogType.Exception:
- color = instance.errorColor;
- break;
- case LogType.Warning:
- color = instance.warningColor;
- break;
- }
- if(instance.logStack)
- instance.consoleText.text += string.Format("<color=#{3}>{0}: {1} at {2}\n\n</color>", type, message, stack, ColorUtility.ToHtmlStringRGB(color));
- else
- instance.consoleText.text += string.Format("<color=#{2}>{0}: {1}\n\n</color>", type, message, ColorUtility.ToHtmlStringRGB(color));
- };
- }
- #endif
- #if !DEBUG
- private void Start() {
- Destroy(gameObject);
- }
- #endif
- public void ResetData() {
- PlayerPrefs.DeleteAll();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement