blob: d306e2400354da49a78426041b26b0d53065506f (
plain)
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
|
using System;
using UnityEngine;
public class DialBehaviour : MonoBehaviour
{
public FloatRange DialRange;
public Collider2D collider;
public Controller myController = new Controller();
public float Value;
public bool Engaged;
public Transform DialTrans;
public Transform DialShadTrans;
public void Update()
{
this.Engaged = false;
this.myController.Update();
DragState dragState = this.myController.CheckDrag(this.collider, false);
if (dragState == DragState.Dragging)
{
Vector2 vector = this.myController.DragPosition - base.transform.position;
float num = Vector2.up.AngleSigned(vector);
if (num < -180f)
{
num += 360f;
}
num = this.DialRange.Clamp(num);
this.SetValue(num);
this.Engaged = true;
}
}
public void SetValue(float angle)
{
this.Value = angle;
Vector3 localEulerAngles = new Vector3(0f, 0f, angle);
this.DialTrans.localEulerAngles = localEulerAngles;
this.DialShadTrans.localEulerAngles = localEulerAngles;
}
}
|