using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class cs01 : MonoBehaviour { public InputField i1; float n1; // Start is called before the first frame update void Start() { } // 在update裡面的運動,就是幀動畫 void Update() { //因為一開始InputField沒有輸入數字,造成float.Parse(...)發生錯誤 //所以,要用try....catch...,若是出現錯誤,就可以將n1 = 0 try { n1 = float.Parse(i1.text); } catch(System.Exception e2) { Debug.Log(e2.Message); n1 = 0; } this.gameObject.transform.Rotate(0, n1, 0, Space.Self); //this.gameObject.transform.Rotate(new Vector3(0, n1, 0), Space.Self); } }