Nextrek
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
using UnityEngine;
/// <summary>
/// Attach this script to a child of a draggable window to make it tilt as it's dragged.
/// Look at how it's used in Example 6.
/// </summary>
[AddComponentMenu("NGUI/Examples/Window Drag Tilt")]
public class WindowDragTilt : MonoBehaviour
{
public int updateOrder = 0;
public float degrees = 30f;
Vector3 mLastPos;
Transform mTrans;
float mAngle = 0f;
void OnEnable ()
{
mTrans = transform;
mLastPos = mTrans.position;
}
void Update ()
{
Vector3 deltaPos = mTrans.position - mLastPos;
mLastPos = mTrans.position;
mAngle += deltaPos.x * degrees;
mAngle = NGUIMath.SpringLerp(mAngle, 0f, 20f, Time.deltaTime);
mTrans.localRotation = Quaternion.Euler(0f, 0f, -mAngle);
}
}
|
Revision |
Author |
Commited |
Message |
83
|
FMMortaroli
|
Tue 13 May, 2014 11:32:51 +0000 |
|