public static void LogException (Exception exception);
public static void LogException (Exception exception, Object context);

参数

context此消息应用到的对象。
exception运行时异常。

描述

将错误消息记录到控制台的 Debug.Log 的变体。

当在控制台中选择此消息时,将绘制与上下文对象的连接。 如果您想要知道哪个对象发生了错误,这非常有用。

另请参阅:Debug.unityLoggerILoggerLogger.LogException

using System;
using UnityEngine;
using System.Collections;

public class MyGameClass : MonoBehaviour { void MyGameMethod() { try { // Do something that can throw an exception } catch (Exception e) { Debug.LogException(e, this); } } }

注意,当启用了“ErrorPause”时,这会暂停该 Editor。

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961