资源简介
Unity的debug输出显示在游戏场景Game ;Unity的debug输出显示在游戏场景中

代码片段和文件信息
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class DebugConsole : MonoBehaviour
{
private static DebugConsole instance = null;
public class Log
{
public string msg;
public string stacktrace;
public LogType type;
public Log(string msg string stacktrace LogType type)
{
this.msg = msg;
this.stacktrace = stacktrace;
this.type = type;
}
}
static readonly Dictionary logTypeColors = new Dictionary
{
{ LogType.Assert Color.white }
{ LogType.Error Color.red }
{ LogType.Exception Color.red }
{ LogType.Log Color.white }
{ LogType.Warning Color.yellow }
};
private double lastInterval = 0.0;
private int frames = 0;
private float m_fps;
private float m_accumTime = 0;
private float m_fpsUpdateInterval = 0.5f;
private string strFPS;
private string strMem;
private List m_logs = new List();
private Vector2 scrollPosition = Vector2.zero;
private bool m_logEnabled = true;
void Awake()
{
if (instance == null)
{
instance = this;
DontDestroyonload(gameobject);
}
}
void Start()
{
lastInterval = Time.realtimeSinceStartup;
frames = 0;
}
void HandleLog(string msg string stacktrace LogType type)
{
if (!m_logEnabled)
{
return;
}
//if (type == LogType.Assert || type == LogType.Error || type == LogType.Exception) {
m_logs.Add(new Log(msg stacktrace type));
//}
scrollPosition.y = float.MaxValue;
}
void OnEnable()
{
Application.logMessageReceived += HandleLog;
}
void OnDisable()
{
Application.logMessageReceived -= HandleLog;
}
// Update is called once per frame
void Update()
{
++frames;
float timeNow = Time.realtimeSinceStartup;
if (timeNow - lastInterval > m_fpsUpdateInterval)
{
float fps = frames / (float)(timeNow - lastInterval);
float ms = 1000.0f / Mathf.Max(fps 0.0001f);
strFPS = string.Format(“{0} ms {1}FPS“ ms.ToString(“f1“) fps.ToString(“f2“));
frames = 0;
lastInterval = timeNow;
}
// system info
if (Time.frameCount % 30 == 0)
{
strMem = string.Format(“memory : {0} MB“ System.GC.GetTotalMemory(false) / (1024 * 1024));
}
}
void OnGUI()
{
GUI.skin.label.fontSize = 24;
GUI.skin.button.fontSize = 24;
GUI.skin.button.margin = new RectOffset(20 10 10 10);
GUILayout.Label(strFPS);
//GUILayout.Label (strM
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4213 2017-12-05 15:29 DebugConsole.cs
- 上一篇:粒子群优化算法优化CEC基准测试函数
- 下一篇:R语言LDA对鸾尾花数据分类
相关资源
- Unity3D登录界面工程
- unity3d反编译工具
-
UnityWebPla
yer及UnityWebPla yerFull -
UnityWebPla
yerFull - unity4.0官方正式版
- Behavior Designer 1.6.3(u2018.3.0).unitypa
- Unity纪念碑谷.rar
- A Pathfinding Project Pro v4.2.2.rar
- Unity 声音播放插件,支持将字符串转
- Gaia 1.7.2
- Unity3d实现扭动挤压浏览效果
- UnityShader卷轴效果
- 爱酱(绊爱Kizuna)模型
- 遗传算法越野小车unity5.5
- unity 3D 百度语音合成 并播放
- unity案例入门坦克大战源码
- Graph And Chart 1.91.unitypackage
- Animated Steel Coaster 1.51.rar
- Unity3D游戏开发.pdf 宣雨松著完整高清
- Unity3D版水果忍者
- unity3d爆炸特效包
- unity3d_见缝插针源码及报告.zip
- Unity3d车库场景模型
- unity3d 警察动画模型
- unity20多种烟雾以及爆炸特效
- unity博物馆.zip
- burpsuite_community社区版x86系统
- unity3D 新手引导遮罩,支持圆形和矩形
- 兼容unity的System.Drawing.dll
- unity3d枪支武器包FPS第一人称射击游戏
评论
共有 条评论