zoukankan      html  css  js  c++  java
  • Auto Clear Unity Console Log

    功能

    可以在Editor模式下执行,当然也可以Runtime模式下执行,自动清除 Console的log信息

    image

    功能需求

    当在制作Editor的一些功能时,常常需要手动的点击Console窗口的Clear来清除日志,通过这个方法可以很方便的在脚本编译后自动清除日志

    [InitializeOnLoad]
    [ExecuteInEditMode]
    public partial class CSimulateEnv : MonoBehaviour
    {
        static CSimulateEnv()
        {
           ClearLog();
        }
    }

    示例代码

    using System.Reflection;
    using UnityEngine;
    
    public class ClearTest : MonoBehaviour
    {
        // Use this for initialization
        void Start()
        {
            ClearLog();
        }
    
        void OnGUI()
        {
            if (GUILayout.Button(" clear "))
            {
                ClearLog();
            }
        }
    
        public void ClearLog()
        {
            var assembly = Assembly.GetAssembly(typeof(UnityEditor.ActiveEditorTracker));
            var type = assembly.GetType("UnityEditorInternal.LogEntries");
            var method = type.GetMethod("Clear");
            method.Invoke(new object(), null);
        }
    }

    参考资料

    http://answers.unity3d.com/questions/10580/editor-script-how-to-clear-the-console-output-wind.html

  • 相关阅读:
    consumer详解
    消费幂等
    死信队列
    消息重试
    负载均衡
    存储层
    producer消息
    消息发送与接收
    TCC
    form表单提交前进行加密
  • 原文地址:https://www.cnblogs.com/zhaoqingqing/p/4026812.html
Copyright © 2011-2022 走看看