Skip to content

Commit 84e10ff

Browse files
committed
Add InterfaceBase and update scenes
1 parent d2ef2ca commit 84e10ff

9 files changed

Lines changed: 395 additions & 122 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
4+
public class SampleAnalog : OSVR.Unity.InterfaceBase
5+
{
6+
7+
// Use this for initialization
8+
void Start()
9+
{
10+
osvrInterface.RegisterCallback(callback);
11+
}
12+
13+
void callback(string path, float value)
14+
{
15+
Debug.Log("Got analog value " + value);
16+
}
17+
}

OSVR-Unity/Assets/OSVRUnity/Sample/Scripts/SampleAnalog.cs.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
4+
public class SampleButtonScript : OSVR.Unity.InterfaceBase
5+
{
6+
void Start()
7+
{
8+
osvrInterface.RegisterCallback(handleButton);
9+
}
10+
11+
void handleButton(string path, bool state)
12+
{
13+
Debug.Log("Got button: " + path + " state is " + state);
14+
}
15+
}

OSVR-Unity/Assets/OSVRUnity/Sample/Scripts/SampleButtonScript.cs.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OSVR-Unity/Assets/OSVRUnity/Sample/minigame.unity

Lines changed: 213 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,59 @@ MeshFilter:
246246
m_PrefabInternal: {fileID: 0}
247247
m_GameObject: {fileID: 308720490}
248248
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
249+
--- !u!1 &371375254
250+
GameObject:
251+
m_ObjectHideFlags: 0
252+
m_PrefabParentObject: {fileID: 112524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
253+
m_PrefabInternal: {fileID: 917996766}
254+
serializedVersion: 4
255+
m_Component:
256+
- 4: {fileID: 371375257}
257+
- 114: {fileID: 371375256}
258+
- 114: {fileID: 371375255}
259+
m_Layer: 0
260+
m_Name: Left1Button
261+
m_TagString: Untagged
262+
m_Icon: {fileID: 0}
263+
m_NavMeshLayer: 0
264+
m_StaticEditorFlags: 0
265+
m_IsActive: 1
266+
--- !u!114 &371375255
267+
MonoBehaviour:
268+
m_ObjectHideFlags: 0
269+
m_PrefabParentObject: {fileID: 0}
270+
m_PrefabInternal: {fileID: 0}
271+
m_GameObject: {fileID: 371375254}
272+
m_Enabled: 1
273+
m_EditorHideFlags: 0
274+
m_Script: {fileID: 11500000, guid: da05f6fface48e1409543808d4b8bc39, type: 3}
275+
m_Name:
276+
m_EditorClassIdentifier:
277+
--- !u!114 &371375256
278+
MonoBehaviour:
279+
m_ObjectHideFlags: 0
280+
m_PrefabParentObject: {fileID: 11412524, guid: 510671571090a2c43bb457bd223da5d4,
281+
type: 2}
282+
m_PrefabInternal: {fileID: 917996766}
283+
m_GameObject: {fileID: 371375254}
284+
m_Enabled: 1
285+
m_EditorHideFlags: 0
286+
m_Script: {fileID: 11500000, guid: 2dbe481ddb829b04a8f8f4fa85065051, type: 3}
287+
m_Name:
288+
m_EditorClassIdentifier:
289+
path: /controller/left/1
290+
--- !u!4 &371375257
291+
Transform:
292+
m_ObjectHideFlags: 0
293+
m_PrefabParentObject: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
294+
m_PrefabInternal: {fileID: 917996766}
295+
m_GameObject: {fileID: 371375254}
296+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
297+
m_LocalPosition: {x: 0, y: 0, z: 0}
298+
m_LocalScale: {x: 1, y: 1, z: 1}
299+
m_Children: []
300+
m_Father: {fileID: 0}
301+
m_RootOrder: 5
249302
--- !u!1001 &383423477
250303
Prefab:
251304
m_ObjectHideFlags: 0
@@ -342,6 +395,58 @@ Prefab:
342395
m_RootGameObject: {fileID: 2002675860}
343396
m_IsPrefabParent: 0
344397
m_IsExploded: 1
398+
--- !u!1001 &470093076
399+
Prefab:
400+
m_ObjectHideFlags: 0
401+
serializedVersion: 2
402+
m_Modification:
403+
m_TransformParent: {fileID: 0}
404+
m_Modifications:
405+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
406+
propertyPath: m_LocalPosition.x
407+
value: 0
408+
objectReference: {fileID: 0}
409+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
410+
propertyPath: m_LocalPosition.y
411+
value: 0
412+
objectReference: {fileID: 0}
413+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
414+
propertyPath: m_LocalPosition.z
415+
value: 0
416+
objectReference: {fileID: 0}
417+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
418+
propertyPath: m_LocalRotation.x
419+
value: 0
420+
objectReference: {fileID: 0}
421+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
422+
propertyPath: m_LocalRotation.y
423+
value: 0
424+
objectReference: {fileID: 0}
425+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
426+
propertyPath: m_LocalRotation.z
427+
value: 0
428+
objectReference: {fileID: 0}
429+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
430+
propertyPath: m_LocalRotation.w
431+
value: 1
432+
objectReference: {fileID: 0}
433+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
434+
propertyPath: m_RootOrder
435+
value: 6
436+
objectReference: {fileID: 0}
437+
- target: {fileID: 112524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
438+
propertyPath: m_Name
439+
value: LeftAnalogTrigger
440+
objectReference: {fileID: 0}
441+
- target: {fileID: 11412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
442+
propertyPath: path
443+
value: /controller/left/trigger
444+
objectReference: {fileID: 0}
445+
m_RemovedComponents: []
446+
m_ParentPrefab: {fileID: 100100000, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
447+
m_RootGameObject: {fileID: 2101970566}
448+
m_IsPrefabParent: 0
449+
m_IsExploded: 1
345450
--- !u!1 &605626977
346451
GameObject:
347452
m_ObjectHideFlags: 0
@@ -395,7 +500,7 @@ GameObject:
395500
- 114: {fileID: 738728246}
396501
m_Layer: 0
397502
m_Name: ClientKit
398-
m_TagString: OSVRClientKit
503+
m_TagString: Untagged
399504
m_Icon: {fileID: 0}
400505
m_NavMeshLayer: 0
401506
m_StaticEditorFlags: 4294967295
@@ -425,6 +530,58 @@ Transform:
425530
m_Children: []
426531
m_Father: {fileID: 0}
427532
m_RootOrder: 4
533+
--- !u!1001 &917996766
534+
Prefab:
535+
m_ObjectHideFlags: 0
536+
serializedVersion: 2
537+
m_Modification:
538+
m_TransformParent: {fileID: 0}
539+
m_Modifications:
540+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
541+
propertyPath: m_LocalPosition.x
542+
value: 0
543+
objectReference: {fileID: 0}
544+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
545+
propertyPath: m_LocalPosition.y
546+
value: 0
547+
objectReference: {fileID: 0}
548+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
549+
propertyPath: m_LocalPosition.z
550+
value: 0
551+
objectReference: {fileID: 0}
552+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
553+
propertyPath: m_LocalRotation.x
554+
value: 0
555+
objectReference: {fileID: 0}
556+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
557+
propertyPath: m_LocalRotation.y
558+
value: 0
559+
objectReference: {fileID: 0}
560+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
561+
propertyPath: m_LocalRotation.z
562+
value: 0
563+
objectReference: {fileID: 0}
564+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
565+
propertyPath: m_LocalRotation.w
566+
value: 1
567+
objectReference: {fileID: 0}
568+
- target: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
569+
propertyPath: m_RootOrder
570+
value: 5
571+
objectReference: {fileID: 0}
572+
- target: {fileID: 112524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
573+
propertyPath: m_Name
574+
value: Left1Button
575+
objectReference: {fileID: 0}
576+
- target: {fileID: 11412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
577+
propertyPath: path
578+
value: /controller/left/1
579+
objectReference: {fileID: 0}
580+
m_RemovedComponents: []
581+
m_ParentPrefab: {fileID: 100100000, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
582+
m_RootGameObject: {fileID: 371375254}
583+
m_IsPrefabParent: 0
584+
m_IsExploded: 1
428585
--- !u!1 &1121138429
429586
GameObject:
430587
m_ObjectHideFlags: 0
@@ -998,7 +1155,7 @@ Transform:
9981155
m_GameObject: {fileID: 1906774593}
9991156
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
10001157
m_LocalPosition: {x: -.100000001, y: 0, z: 0}
1001-
m_LocalScale: {x: .100000001, y: .100000001, z: .100000001}
1158+
m_LocalScale: {x: 1, y: 1, z: 1}
10021159
m_Children:
10031160
- {fileID: 1890437449}
10041161
m_Father: {fileID: 0}
@@ -1040,7 +1197,7 @@ Transform:
10401197
m_GameObject: {fileID: 2002675860}
10411198
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
10421199
m_LocalPosition: {x: -.100000001, y: 0, z: 0}
1043-
m_LocalScale: {x: .100000001, y: .100000001, z: .100000001}
1200+
m_LocalScale: {x: 1, y: 1, z: 1}
10441201
m_Children:
10451202
- {fileID: 1735307939}
10461203
m_Father: {fileID: 0}
@@ -1058,3 +1215,56 @@ MonoBehaviour:
10581215
m_Name:
10591216
m_EditorClassIdentifier:
10601217
path: /me/hands/right
1218+
--- !u!1 &2101970566
1219+
GameObject:
1220+
m_ObjectHideFlags: 0
1221+
m_PrefabParentObject: {fileID: 112524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
1222+
m_PrefabInternal: {fileID: 470093076}
1223+
serializedVersion: 4
1224+
m_Component:
1225+
- 4: {fileID: 2101970569}
1226+
- 114: {fileID: 2101970568}
1227+
- 114: {fileID: 2101970567}
1228+
m_Layer: 0
1229+
m_Name: LeftAnalogTrigger
1230+
m_TagString: Untagged
1231+
m_Icon: {fileID: 0}
1232+
m_NavMeshLayer: 0
1233+
m_StaticEditorFlags: 0
1234+
m_IsActive: 1
1235+
--- !u!114 &2101970567
1236+
MonoBehaviour:
1237+
m_ObjectHideFlags: 0
1238+
m_PrefabParentObject: {fileID: 0}
1239+
m_PrefabInternal: {fileID: 0}
1240+
m_GameObject: {fileID: 2101970566}
1241+
m_Enabled: 1
1242+
m_EditorHideFlags: 0
1243+
m_Script: {fileID: 11500000, guid: bd266b88118538f409116423e7b455c0, type: 3}
1244+
m_Name:
1245+
m_EditorClassIdentifier:
1246+
--- !u!114 &2101970568
1247+
MonoBehaviour:
1248+
m_ObjectHideFlags: 0
1249+
m_PrefabParentObject: {fileID: 11412524, guid: 510671571090a2c43bb457bd223da5d4,
1250+
type: 2}
1251+
m_PrefabInternal: {fileID: 470093076}
1252+
m_GameObject: {fileID: 2101970566}
1253+
m_Enabled: 1
1254+
m_EditorHideFlags: 0
1255+
m_Script: {fileID: 11500000, guid: 2dbe481ddb829b04a8f8f4fa85065051, type: 3}
1256+
m_Name:
1257+
m_EditorClassIdentifier:
1258+
path: /controller/left/trigger
1259+
--- !u!4 &2101970569
1260+
Transform:
1261+
m_ObjectHideFlags: 0
1262+
m_PrefabParentObject: {fileID: 412524, guid: 510671571090a2c43bb457bd223da5d4, type: 2}
1263+
m_PrefabInternal: {fileID: 470093076}
1264+
m_GameObject: {fileID: 2101970566}
1265+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
1266+
m_LocalPosition: {x: 0, y: 0, z: 0}
1267+
m_LocalScale: {x: 1, y: 1, z: 1}
1268+
m_Children: []
1269+
m_Father: {fileID: 0}
1270+
m_RootOrder: 6
Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
using UnityEngine;
2-
using System.Collections;
3-
4-
public class HandleButtonPress : MonoBehaviour {
5-
public void Start() {
6-
GetComponent<OSVR.Unity.InterfaceCallbacks> ().RegisterCallback (handleButton);
7-
}
8-
9-
public void handleButton(string path, bool state) {
10-
Debug.Log ("Got button: " + path + " state is " + state);
11-
}
12-
}
1+
using UnityEngine;
2+
using System.Collections;
3+
4+
/// <summary>
5+
/// This is a manual way of accessing the InterfaceGameObject component. See SampleButtonScript for the slightly more elegant solution.
6+
/// </summary>
7+
[RequireComponent(typeof(OSVR.Unity.InterfaceGameObject))]
8+
public class HandleButtonPress : MonoBehaviour
9+
{
10+
public void Start()
11+
{
12+
gameObject.GetComponent<OSVR.Unity.InterfaceGameObject>().osvrInterface.RegisterCallback(handleButton);
13+
}
14+
15+
public void handleButton(string path, bool state)
16+
{
17+
Debug.Log("Got button: " + path + " state is " + state);
18+
}
19+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* OSVR-Unity Connection
2+
*
3+
* <http://sensics.com/osvr>
4+
* Copyright 2014 Sensics, Inc.
5+
* All rights reserved.
6+
*
7+
* Final version intended to be licensed under Apache v2.0
8+
*/
9+
10+
using UnityEngine;
11+
12+
namespace OSVR
13+
{
14+
namespace Unity
15+
{
16+
/// <summary>
17+
/// Base class for a script that requires an OSVR interface.
18+
/// </summary>
19+
[RequireComponent(typeof(InterfaceGameObject))]
20+
public class InterfaceBase : MonoBehaviour
21+
{
22+
/// <summary>
23+
/// Accessor for the sibling InterfaceGameObject component.
24+
/// </summary>
25+
public InterfaceGameObject interfaceGameObject
26+
{
27+
get
28+
{
29+
return GetComponent<InterfaceGameObject>();
30+
}
31+
}
32+
33+
/// <summary>
34+
/// Accessor for the InterfaceCallbacks object in the sibling InterfaceGameObject component.
35+
/// </summary>
36+
public InterfaceCallbacks osvrInterface
37+
{
38+
get
39+
{
40+
if (null == interfaceGameObject) {
41+
return null;
42+
}
43+
return interfaceGameObject.osvrInterface;
44+
}
45+
}
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)