-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathShakeTest.cs
More file actions
124 lines (113 loc) · 4.25 KB
/
ShakeTest.cs
File metadata and controls
124 lines (113 loc) · 4.25 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* Copyright (c) scott.cgi All Rights Reserved.
*
* This source code belongs to project MojoUnity-Packages, which is hosted on GitHub, and licensed under the MIT License.
*
* License: https://github.com/scottcgi/MojoUnity-Packages/blob/main/LICENSE
* GitHub : https://github.com/scottcgi/MojoUnity-Packages
* Package: https://github.com/scottcgi/MojoUnity-Packages/tree/main/MojoUnity-Shake
*
* Since : 2021-4-20
* Update : 2021-4-20
* Author : scott.cgi
*/
using UnityEngine;
using MojoUnity;
public class ShakeTest : MonoBehaviour
{
public float speed = 100f;
public float duration = 2.0f;
[Space(10)]
public float positionMagnitude = 0.2f;
public bool isShakePositionX;
public bool isShakePositionY;
public bool isShakePositionZ;
public bool isShakePositionXY;
public bool isShakePosition;
[Space(10)]
public float scaleMagnitude = 0.1f;
public bool isShakeScaleX;
public bool isShakeScaleY;
public bool isShakeScaleZ;
public bool isShakeScaleXY;
public bool isShakeScale;
[Space(10)]
public float rotationMagnitude = 30.0f;
public bool isShakeRotationX;
public bool isShakeRotationY;
public bool isShakeRotationZ;
public bool isShakeRotation;
private void Update()
{
if (this.isShakePositionX)
{
this.isShakePositionX = false;
this.transform.ShakePositionX(this.positionMagnitude, this.speed, this.duration, null);
}
else if (this.isShakePositionY)
{
this.isShakePositionY = false;
this.transform.ShakePositionY(this.positionMagnitude, this.speed, this.duration, null);
}
else if (this.isShakePositionZ)
{
this.isShakePositionZ = false;
this.transform.ShakePositionZ(this.positionMagnitude, this.speed, this.duration, null);
}
else if (this.isShakePositionXY)
{
this.isShakePositionXY = false;
this.transform.ShakePositionXY(this.positionMagnitude, this.speed, this.duration, null);
}
else if (this.isShakePosition)
{
this.isShakePosition = false;
this.transform.ShakePosition(this.positionMagnitude, this.speed, this.duration, null);
}
if (this.isShakeScaleX)
{
this.isShakeScaleX = false;
this.transform.ShakeScaleX(this.scaleMagnitude, this.speed, this.duration, null);
}
else if (this.isShakeScaleY)
{
this.isShakeScaleY = false;
this.transform.ShakeScaleY(this.scaleMagnitude, this.speed, this.duration, null);
}
else if (this.isShakeScaleZ)
{
this.isShakeScaleZ = false;
this.transform.ShakeScaleZ(this.scaleMagnitude, this.speed, this.duration, null);
}
else if (this.isShakeScaleXY)
{
this.isShakeScaleXY = false;
this.transform.ShakeScaleXY(this.scaleMagnitude, this.speed, this.duration, null);
}
else if (this.isShakeScale)
{
this.isShakeScale = false;
this.transform.ShakeScale(this.scaleMagnitude, this.speed, this.duration, null);
}
if (this.isShakeRotationX)
{
this.isShakeRotationX = false;
this.transform.ShakeRotationX(this.rotationMagnitude, this.speed, this.duration, null);
}
else if (this.isShakeRotationY)
{
this.isShakeRotationY = false;
this.transform.ShakeRotationY(this.rotationMagnitude, this.speed, this.duration, null);
}
else if (this.isShakeRotationZ)
{
this.isShakeRotationZ = false;
this.transform.ShakeRotationZ(this.rotationMagnitude, this.speed, this.duration, null);
}
else if (this.isShakeRotation)
{
this.isShakeRotation = false;
this.transform.ShakeRotation(this.rotationMagnitude, this.speed, this.duration, null);
}
}
}