123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using UnityEngine;
- using System.Collections;
- public class UIRotate : MonoBehaviour
- {
- public bool mExcute;
- public float speed;
- public bool left;
- public bool rotateX;
- public bool rotateY;
- Vector3 baseDir;
- float x;
- float y;
- float z;
- void Start()
- {
- baseDir = transform.localEulerAngles;
- }
-
- void Update()
- {
- if (mExcute)
- {
- if (rotateX)
- {
- if (left)
- {
- x += Time.deltaTime * speed;
- }
- else
- {
- x -= Time.deltaTime * speed;
- }
- }
- else if (rotateY)
- {
- if (left)
- {
- y += Time.deltaTime * speed;
- }
- else
- {
- y -= Time.deltaTime * speed;
- }
- }
- else
- {
- if (left)
- {
- z += Time.deltaTime * speed;
- }
- else
- {
- z -= Time.deltaTime * speed;
- }
- }
- SetRotate();
- }
- }
- void SetRotate()
- {
- if (rotateX)
- {
- transform.localEulerAngles = new Vector3(x, baseDir.y, baseDir.z);
- }
- else if (rotateY)
- {
- transform.localEulerAngles = new Vector3(baseDir.x, y, baseDir.z);
- }
- else
- {
- transform.localEulerAngles = new Vector3(baseDir.x, baseDir.y, z);
- }
- }
- }
|