unity3D写一个hello world
打开unity并且在assets建立一个新的文件,新的文件命名为hello world.unity.接着创建一个新的C#Sript脚本文件,命名为hello world.C#Script,用VS2015打开并编写该脚本程序。
代码如下:
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start() {
}
// Update is called once per frame
void Update() {
}
void OnGUI ()
{
GUI.skin.label.fontSize = 100;
GUI.Label(new Rect(10,10,Screen.width,Screen.height),"hello world");
}
}
在unity中选定主摄像机,将写好的脚本程序拖到最右下角的复选框,然后点击中间运行按钮