简单的日志输出

unity打包测试时,不会有控制台输出日志,所以简单一个日志输出脚本

using UnityEngine;
using UnityEngine.UI;

public class LogInfo : MonoBehaviour
{
    public bool isDebug = true;
    private Text log;

    public static LogInfo theLogger;

    public void Log(string info)
    {
        if(isDebug)
        log.text += "\r\n" + info;
    }

    private void Clear()
    {
        log.text = "Log:";
    }

    void Start ()
    {
        theLogger = this;
        log = GetComponent<Text>();
        log.text = "Log:";
        GetComponentInChildren<Button>().onClick.AddListener(Clear);
    }

}

 

posted @ 2018-08-04 09:17  81192  阅读(165)  评论(0编辑  收藏  举报