Application.LogCallback 日志回调

delegate LogCallback (condition : string, stackTrace : string, type : LogType) : void

Description描述

Use this delegate type with RegisterLogCallback to monitor what gets logged.

用RegisterLogCallback来使用这个委托类型,去监控什么得到记录了

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public string output = "";
	public string stack = "";
	void OnEnable() {
		Application.RegisterLogCallback(HandleLog);
	}
	void OnDisable() {
		Application.RegisterLogCallback(null);
	}
	void HandleLog(string logString, string stackTrace, LogType type) {
		output = logString;
		stack = stackTrace;
	}
}
var output = "";
var stack= "";

function OnEnable () {
	Application.RegisterLogCallback(HandleLog);
}

function OnDisable () {
	// Remove callback when object goes out of scope
	//当对象超出范围,删除回调
	Application.RegisterLogCallback(null);
}

function HandleLog (logString : String, stackTrace : String, type : LogType) {
	output = logString;
	stack = stackTrace;
}
参见: Application.RegisterLogCallback, LogType
Page last updated: 2011-7-20