资源简介
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对鸾尾花数据分类
相关资源
- PolyNav - 2D Pathfinding.unitypackage
- Legacy Image Effects.unitypackage
- 水波纹water 3D.unitypackage
- 无双小师妹手游源码+服务端源码+文档
- UGUI轮播功能基于DoTween
- 最新Kinect v2 with MS-SDK 2.10.1 for Unity3D
- Kinect for unity sdk v2.9.unitypackage
- Unity3D地下守护神ARPG开发三部曲视频教
- unity3d 类似LOL的游戏源码
-
Editor sc
ripting for n00bs Unity编辑器 - arduino与Unity串口通讯.docx
- untiyPC端窗口最前
- LitJson修改版,Unity支持float数据类型
- Unity图片切换轮播功能
- Main.unity
- PrintImage.exe是一个调用打印机后台打印
- unity汉化包,中文补丁
- CYC.unity
- 航母模型,unity模型
- 跑酷游戏泰课教程 Escape From The Earth
- 炉石传说-卡牌游戏开发视频教程源码
- 自动驾驶UNITY源代码
- 翻页效果 书翻页
- opencvforunity最新版
- Sprite Mask 1.4
- Unity粒子特效特效 100种 包含20个插件
- (接入华为sdk for unity) eclipse部分
- unity 5.x 3D游戏开发案例
- unity3d恐怖游戏开发模板
- Obfuscator v2.0.4Unity代码混淆2018.4亲测可
评论
共有 条评论