-
创建一个Scene,并在里面创建一个GameObject。
-
编写一个脚本,并作为组件加载到GameObject上。
MainPlayer
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace VariablesAndTheInspector {
public class MainPlayer : MonoBehaviour {
public string myName;
// Start is called before the first frame update
private void Start() {
Debug.Log("I am alive and my name is " + myName);
}
// Update is called once per frame
private void Update() {
}
}
}
-
最后的文件结构是这样。
-
在控制台上看到log输出。