using System.Collections; using System.Collections.Generic; using UnityEngine; public class RotateObj : MonoBehaviour { // Start is called before the first frame update // Rotate public float speed = 10; public string axis; public bool isRotate; public void Update() { if (isRotate) { if (axis.ToUpper().Equals("X")) { transform.Rotate(Vector3.up * speed); } if (axis.ToUpper().Equals("Y")) { transform.Rotate(Vector3.right * speed); } } } public void RotateObject(string axis) { this.axis = axis; isRotate = true; } public void StopRotate() { isRotate = false; } }