看效果,直接上图。

当日志拥有了自己的颜色,会不会瞬间酷炫起来?
如何拥有呢?
直接上代码!
//===============================================
//名 称 :Log
//描 述 :打印日志 Assets/_Scripts/Common/Log.cs
//作 者 :caoxiaopao
//邮 箱 :1115694700@qq.com
//时 间 :2021.08.25 10:55:38
//===============================================
using UnityEngine;
public static class DEBUG
{
/// <summary>
/// color 转换hexadecimal
/// </summary>
/// <param name="color"></param>
/// <returns></returns>
public static string ToHexColor(this Color color)
{
int r = Mathf.RoundToInt(color.r * 255.0f);
int g = Mathf.RoundToInt(color.g * 255.0f);
int b = Mathf.RoundToInt(color.b * 255.0f);
int a = Mathf.RoundToInt(color.a * 255.0f);
string hex = string.Format("{0:X2}{1
Unity中使用DEBUG.Log创建彩色日志教程

本文介绍如何在Unity中通过DEBUG.Log实现彩色日志打印,提高日志可读性。提供了预定义的颜色类型,并展示了使用方法,同时提及了Odin作为测试工具的便利性。
最低0.47元/天 解锁文章
7589

被折叠的 条评论
为什么被折叠?



