-
Notifications
You must be signed in to change notification settings - Fork 0
/
TouchManager.cs
50 lines (32 loc) · 1014 Bytes
/
TouchManager.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
using UnityEngine;
using System.Collections;
using UnityEngine.XR.iOS;
public class TouchManager : MonoBehaviour {
public GameObject particle;
RaycastHit hit = new RaycastHit();
ConstantForce cF;
[SerializeField]
private UnityARHitTestExample unityARHitTest;
void Update() {
if (unityARHitTest.bPlaceObject == true) {
return;
}
for (var i = 0; i < Input.touchCount; ++i) {
if (Input.GetTouch (i).phase == TouchPhase.Began) {
// Construct a ray from the current touch coordinates
Ray ray = Camera.main.ScreenPointToRay (Input.GetTouch (i).position);
// Create a particle if hit
if (Physics.Raycast (ray, out hit)) {
//If we hit the sun move it
if (hit.collider.gameObject.name == "sun") {
cF = hit.collider.gameObject.GetComponent<ConstantForce> ();
cF.force = new Vector3 (0.01f, 0, 0);
}
}
}
}
}
public void PlaceObjectMode(){
unityARHitTest.bPlaceObject = !unityARHitTest.bPlaceObject;
}
}