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
最后修改:2011年7月20日 Wednesday 13:05

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。