12345678910111213141516171819202122232425262728293031 |
- using System;
- using UnityEngine;
- [AddComponentMenu("NGUI/Examples/Window Drag Tilt")]
- public class WindowDragTilt : MonoBehaviour
- {
- private void OnEnable()
- {
- this.mTrans = base.transform;
- this.mLastPos = this.mTrans.position;
- }
- private void Update()
- {
- Vector3 vector = this.mTrans.position - this.mLastPos;
- this.mLastPos = this.mTrans.position;
- this.mAngle += vector.x * this.degrees;
- this.mAngle = NGUIMath.SpringLerp(this.mAngle, 0f, 20f, Time.deltaTime);
- this.mTrans.localRotation = Quaternion.Euler(0f, 0f, -this.mAngle);
- }
- public int updateOrder;
- public float degrees = 30f;
- private Vector3 mLastPos;
- private Transform mTrans;
- private float mAngle;
- }
|