Debug.LogError 记录错误

static function LogError (message : object) : void

Description描述

A variant of Debug.Log that logs an error message to the console.

Debug.Log的一个变体,是用来记录一个错误消息到控制台。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Transform memberVariable;
	public void Awake() {
		if (memberVariable == null)
			Debug.LogError("memberVariable must be set to point to a Transform.");

	}
}
var memberVariable : Transform;
if(memberVariable == null)
	Debug.LogError("memberVariable must be set to point to a Transform.");

• static function LogError (message : object, context : Object) : void

Description描述

A variant of Debug.Log that logs an error message to the console.

Debug.Log的一个变体,是用来记录一个错误消息到控制台。

When you select the message in the console a connection to the context object will be drawn. This is very useful if you want know on which object an error occurs.

当你在看控制台选择消息的时候,到上下文物体的一个连接将被绘制。如果你想知道在那个对象上发生了错误,这是非常有用的。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Transform memberVariable;
	public void Awake() {
		if (memberVariable == null)
			Debug.LogError("memberVariable must be set to point to a Transform.", transform);

	}
}
var memberVariable : Transform;
if(memberVariable == null)
	Debug.LogError("memberVariable must be set to point to a Transform.", transform);
Page last updated: 2010-12-24