Logger.LogError

声明

public void LogError(string tag, object message);

声明

public void LogError(string tag, object message, Object context);

参数

tag 用于标识日志消息的来源。它通常标识日志调用发生的类。
message 要转换为字符串表示形式以显示的字符串或对象。
context 消息所适用的对象。

描述

一种记录错误消息的 Logger.Log 变体。

using UnityEngine;
using System.Collections;

public class MyGameClass : MonoBehaviour { private static ILogger logger = Debug.unityLogger; private static string kTAG = "MyGameTag"; private Transform tr;

void MyGameMethod() { if (tr == null) { logger.LogError(kTAG, "memberVariable must be set to point to a Transform.", tr);

Debug.unityLogger.LogError(kTAG, "Failed! to set Transform", tr); } } }

请注意,当启用“ErrorPause”时,这会暂停编辑器。


Did you find this page useful? Please give it a rating: