-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpinny.cs
52 lines (45 loc) · 1.38 KB
/
Spinny.cs
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
using UdonSharp;
using UnityEngine;
namespace UwUtils
{
[AddComponentMenu("UwUtils/Spinny")]
[UdonBehaviourSyncMode(BehaviourSyncMode.None)]
public class Spinny : UdonSharpBehaviour
{
#region References
[Header("Objects to rotate")]
[Header("Settings")]
#endregion
[Range(0.1f, 60f)]
[SerializeField] private float rotation_Speed = 1.5f;
[Range(1f, 2000f)]
[SerializeField] private float update_Interval_Milliseconds = 1f;
[Header("Target object rotation axis:")]
[Header("[0] Y [1] X [2] Z")]
[SerializeField] [Range(0, 2)] private int targetRotation;
public void OnEnable()
{
UpdateRotation();
}
public void UpdateRotation()
{
if (targetRotation == 0)
{
transform.Rotate(Vector3.up, rotation_Speed);
}
else if (targetRotation == 1)
{
transform.Rotate(Vector3.right, rotation_Speed);
}
else if (targetRotation == 2)
{
transform.Rotate(Vector3.forward, rotation_Speed);
}
else
{
Debug.Log("Error: Function invalid");
}
SendCustomEventDelayedSeconds(nameof(UpdateRotation), update_Interval_Milliseconds / 100);
}
}
}