UGUI_回転オブジェクトを作成し、スライダーを使用してボールの回転速度を制御します.

2535 ワード

 1 using System.Collections;
 2 using System.Collections.Generic;
 3 using UnityEngine;
 4 
 5 public class Player : MonoBehaviour {
 6     public float speed = 50f;
 7     // Use this for initialization
 8     void Start () {
 9         
10     }
11     
12     // Update is called once per frame
13     void Update () {
14         transform.Rotate(Vector3.up,speed *Time.deltaTime);
15     }
16     public void ChangeSpeed(float newSpeed)
17     {
18         this.speed = newSpeed; 
19     }
20 }

Player空の物体、Playerスクリプトをマウントします;
CanvasでのSlider,OnValueChangedイベント処理:Playerオブジェクト+(playerスクリプトでの)ChangeSpeedメソッド.
転載先:https://www.cnblogs.com/NBOWeb/p/8968175.html