Application.RegisterLogCallback 注册日志回调

static function RegisterLogCallback (handler : Application.LogCallback) : void

Description描述

Register a delegate to be called on log messages.

在一个日志信息上注册一个委托来被调用。

Pass null to remove log handler.

通过null来去除日志处理器。

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 : String = "";

var stack : String = "";



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;

}
See Also: Application.LogCallback, LogType.
Page last updated: 2011-7-20