BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / Oculus / SampleFramework / Usage / DistanceGrab / Scripts / DistanceGrabberSample.cs

DistanceGrabberSample.cs

Project Import
timfa Tim Falken · pushed by timfa · 6 years ago
b77834a1 History
DistanceGrabberSample.cs 2.3 KiB Download Raw
1/************************************************************************************
2
3Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
4
5See SampleFramework license.txt for license terms. Unless required by applicable law
6or agreed to in writing, the sample code is provided “AS IS” WITHOUT WARRANTIES OR
7CONDITIONS OF ANY KIND, either express or implied. See the license for specific
8language governing permissions and limitations under the license.
9
10************************************************************************************/
11using System.Collections;
12using System.Collections.Generic;
13using UnityEngine;
14using UnityEngine.UI;
15
16namespace OculusSampleFramework
17{
18 public class DistanceGrabberSample : MonoBehaviour
19 {
20
21 bool museSpherecast = false;
22 bool allowGrabThroughWalls = false;
23
24 public bool UseSpherecast
25 {
26 get { return museSpherecast; }
27 set
28 {
29 museSpherecast = value;
30 for (int i = 0; i < m_grabbers.Length; ++i)
31 {
32 m_grabbers[i].UseSpherecast = museSpherecast;
33 }
34 }
35 }
36
37 public bool AllowGrabThroughWalls
38 {
39 get { return allowGrabThroughWalls; }
40 set
41 {
42 allowGrabThroughWalls = value;
43 for (int i = 0; i < m_grabbers.Length; ++i)
44 {
45 m_grabbers[i].m_preventGrabThroughWalls = !allowGrabThroughWalls;
46 }
47 }
48 }
49
50 [SerializeField]
51 DistanceGrabber[] m_grabbers;
52
53 // Use this for initialization
54 void Start()
55 {
56 DebugUIBuilder.instance.AddLabel("Distance Grab Sample");
57 DebugUIBuilder.instance.AddToggle("Use Spherecasting", ToggleSphereCasting, museSpherecast);
58 DebugUIBuilder.instance.AddToggle("Grab Through Walls", ToggleGrabThroughWalls, allowGrabThroughWalls);
59 DebugUIBuilder.instance.Show();
60 }
61
62 public void ToggleSphereCasting(Toggle t)
63 {
64 UseSpherecast = !UseSpherecast;
65 }
66
67 public void ToggleGrabThroughWalls(Toggle t)
68 {
69 AllowGrabThroughWalls = !AllowGrabThroughWalls;
70 }
71 }
72}