这应该很简单,但仍然找不到一个直接的答案:
我该如何使用C# Unity脚本记录简单的消息?
我尝试了以下代码:
Debug.Log("Hello Log");
它不能工作,或者我没有看对地方。
这应该很简单,但仍然找不到一个直接的答案:
我该如何使用C# Unity脚本记录简单的消息?
我尝试了以下代码:
Debug.Log("Hello Log");
它不能工作,或者我没有看对地方。
Debug.Log("Hello Log");
可以在 控制台选项卡 找到。
为了让您能够看到它:
1.您必须将其放入脚本的函数中。
public class Test : MonoBehaviour
{
void Start()
{
Debug.Log("Hello Log");
}
}
2。脚本必须附加到游戏对象上。
3.脚本和其所附加的游戏对象必须同时启用。
4.如果您无法看到控制台选项卡,请重置布局。
编辑:
我在 Android 设备上测试了它。这就是为什么我没看到它。
在这种情况下,使用 Android Studio 中的 Android Monitor 查看来自您的 Android 设备的日志。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Simple : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Debug.Log("Attach this script to component and simple message will be there when you start project");
}
// Update is called once per frame
void Update()
{
}
}