using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CubeRotate : MonoBehaviour
{
//物体自动旋转的速度 可以外部手动调
public int speed = 5;
// Update is called once per frame
void Update ()
{
//物体自动旋转
this.transform.Rotate(Vector3.up * speed);
//this.transform.Rotate(Vector3.down * speed);
//this.transform.Rotate(Vector3.left * speed);
//this.transform.Rotate(Vector3.right * speed);
}
//变颜色的对象
public GameObject Obj;
//点击按钮后调用的方法
public void toRed()//变红
{
Obj.GetComponent<Renderer>().material.color = Color.red;
}
public void toGreen()//变绿
{
Obj.GetComponent<Renderer>().material.color = Color.green;
}
public void toBlue()//变蓝
{
Obj.GetComponent<Renderer>().material.color = Color.blue;
}
public void toYellow()//变黄
{
Obj.GetComponent<Renderer>().material.color = Color.yellow;
}
}
物体自动旋转和换颜色
最新推荐文章于 2020-09-23 21:58:13 发布