admin管理员组文章数量:1570428
接上一个汽车控制,现在我需要实现的是在汽车跑的时候实时打印它的速度在屏幕上,我们都知道如果直接Debug.Log()的话,它打印在控制台上,我们只需要制作一个GUI窗口,打印log就可以了,这个功能是一个外国蜀黍的,我拿来改了一下,灰常对不起,我找了半天找不到原博地址了,我说一下修改的内容吧,由于原程序虽然可以打印log,但是不能和控制台一样往下实时刷新,它的滚动条不能自己往下刷新,你要看还要用鼠标往下拉,这样很不方便。
我怎么做的呢,其实很简单,加一个协程(start和clearlog函数)就好了,我定了每0.1s定时清空一次log,看上去和实时刷新差不多,效果图,为什么不能每帧刷新呢?因为FixedUpdate的每一帧和Update的帧的长度不一样,神奇~
我这个人美感不行,你可以自己调调位置界面颜色之类的。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Consolation
{
/// <summary>
/// A console to display Unity's debug logs in-game.
/// </summary>
class TestConsole : MonoBehaviour
{
//#if USE_TESTCONSOLE
struct Log
{
public string message;
public string stackTrace;
public LogType type;
}
#region Inspector Settings
/// <summary>
/// The hotkey to show and hide the console window.
/// </summary>
public KeyCode toggleKey = KeyCode.BackQuote;
/// <summary>
/// Whether to open the window by shaking the device (mobile-only).
/// </summary>
public bool shakeToOpen = true;
/// <summary>
/// The (squared) acceleration above which the window should open.
/// </summary>
public float shakeAcceleration = 3f;
/// <s
版权声明:本文标题:unity控制台上的信息打印到屏幕上 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1727669226a1124986.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论