-
Notifications
You must be signed in to change notification settings - Fork 47
/
TouchMouseCursorController.cs
84 lines (67 loc) · 2.05 KB
/
TouchMouseCursorController.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
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
using UnityEngine;
using System;
using System.Collections;
using g3;
namespace f3 {
public class TouchMouseCursorController : ICursorController
{
FContext context;
protected Ray3f CurrentWorldRay;
public Ray3f CurrentCursorWorldRay()
{
return CurrentWorldRay;
}
protected Ray3f CurrentUIRay;
public Ray3f CurrentCursorOrthoRay()
{
return CurrentUIRay;
}
protected bool secondWorldRayValid;
protected Ray3f secondWorldRay;
public bool HasSecondPosition {
get { return secondWorldRayValid; }
}
public Ray3f SecondWorldRay()
{
return secondWorldRay;
}
public TouchMouseCursorController(FContext context)
{
this.context = context;
}
// Use this for initialization
public void Start ()
{
}
public void Update ()
{
// just convert current touch position into ray
if (Input.touchCount > 0) {
Vector2f touchPos = Input.touches[0].position;
Vector3f touchPos3 = new Vector3f(touchPos.x, touchPos.y, 0);
CurrentWorldRay = ((Camera)context.ActiveCamera).ScreenPointToRay(touchPos3);
CurrentUIRay = ((Camera)context.OrthoUICamera).ScreenPointToRay(touchPos3);
}
if (Input.touchCount > 1) {
Vector2f touchPos = Input.touches[1].position;
Vector3f touchPos3 = new Vector3f(touchPos.x, touchPos.y, 0);
secondWorldRayValid = true;
secondWorldRay = ((Camera)context.ActiveCamera).ScreenPointToRay(touchPos3);
} else {
secondWorldRayValid = false;
}
}
public void ResetCursorToCenter()
{
// invalid for system cursor
}
public void HideCursor()
{
// invalid for system cursor
}
public void ShowCursor()
{
// invalid for system cursor
}
}
}