先在unity中创建一个c#脚本,并在VS下进行编辑
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Demo1 : MonoBehaviour {// Use this for initialization
void Start () {
GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
go.GetComponent<MeshRenderer>().material.color = Color.red;
}
// Update is called once per frame
void Update () {
}
}
其运行结果如图