通过滑动条控制Cube旋转

private float speed = 10;
private float speedValue;
private GameObject slider;
private GameObject cubeObj;

void Start()
{
  slider = GameObject.Find("Canvas/Slider");
  cubeObj = GameObject.Find("Cube");
  slider.GetComponent<Slider>().onValueChanged.AddListener(delegate
  {
    speedValue = slider.GetComponent<Slider>().value;
    speed = speedValue;
  });
}

void Update ()
{
  cubeObj.transform.Rotate(Vector3.up * Time.deltaTime * speed);
}

posted @ 2017-07-12 10:13  U3DEngineer  阅读(1277)  评论(0编辑  收藏  举报