Print是MonoBehaviour的一個成員嘹黔。Debug則是一個密閉的類。
所以在使用的范圍上莫瞬,Print必須要繼承MonoBehaviour類儡蔓,而Debug不用。
通過反編譯疼邀,我們可以看到print方法具體如下:
public static void print(object message)
{
Debug.Log(message);
}
這說明print方法還是通過debug.log實現(xiàn)的喂江,所以print和debug.log在實質上是沒區(qū)別的,print就是debug.log的一個簡單封裝旁振。
使用:?
usingUnityEngine;
usingSystem.Collections;
public class MyGameClass:MonoBehaviour
{
OnButtonClick()
{
print("hello,print ");
Debug.Log("hello,Debug.Log");
}
}
print();打印是一個很費時的事情,
Debug.log();比print();要好的地方在于正式發(fā)布的時候获询,程序是不會執(zhí)行的