public class createlight : MonoBehaviour {
public GameObject clight;//创建一个游戏物体变量,存放物体
public Light jglight;
public GameObject qiu;
// Use this for initialization
void Start () {
//这个方法 new GameObject(); 可以创建一个新物体
clight=new GameObject("clight01");
clight.transform.position = new Vector3 (0,5f,0);//给灯定义一个方向
jglight=clight.AddComponent<Light> (); //添加灯组件
jglight.type = LightType.Spot;
jglight.intensity = 10f;
jglight.color = Color.yellow;
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown ("space")) {
new GameObject("clight02");
}
jglight.transform.LookAt (qiu.transform.position);
}
}
06-19
8850
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-04
3049
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-11
09-11
09-11