Skip to content

Commit 67e86d8

Browse files
Merged MixedRealityToolkit-Unity-master into HTK-WorldAnchorManagerUpdate
2 parents dde189e + 2495716 commit 67e86d8

File tree

159 files changed

+2263
-1220
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+2263
-1220
lines changed

Assets/HoloToolkit-Examples/GazeRuler/Scripts/LineManager.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ public void AddPoint(GameObject LinePrefab, GameObject PointPrefab, GameObject T
3030
if (lastPoint != null && lastPoint.IsStart)
3131
{
3232
Vector3 centerPos = (lastPoint.Position + hitPoint) * 0.5f;
33+
Vector3 cameraPosition = CameraCache.Main.transform.position;
34+
Vector3 directionFromCamera = centerPos - cameraPosition;
3335

34-
Vector3 directionFromCamera = centerPos - Camera.main.transform.position;
35-
36-
float distanceA = Vector3.Distance(lastPoint.Position, Camera.main.transform.position);
37-
float distanceB = Vector3.Distance(hitPoint, Camera.main.transform.position);
36+
float distanceA = Vector3.Distance(lastPoint.Position, cameraPosition);
37+
float distanceB = Vector3.Distance(hitPoint, cameraPosition);
3838

3939
Debug.Log("A: " + distanceA + ",B: " + distanceB);
4040
Vector3 direction;

Assets/HoloToolkit-Examples/InteractiveElements/Scripts/Controls/ButtonThemeWidget.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using UnityEngine;
55
using System.Collections;
66
using HoloToolkit.Examples.Prototyping;
7+
using System;
78

89
namespace HoloToolkit.Examples.InteractiveElements
910
{
@@ -38,6 +39,10 @@ public class ButtonThemeWidget : InteractiveThemeWidget
3839
// material
3940
private Material mMaterial;
4041

42+
private string mCheckColorThemeTag = "";
43+
private string mCheckPositionThemeTag = "";
44+
private string mCheckScaleThemeTag = "";
45+
4146
/// <summary>
4247
/// Get animaiton components
4348
/// </summary>
@@ -67,20 +72,29 @@ private void Awake()
6772
}
6873

6974
private void Start()
75+
{
76+
SetTheme();
77+
RefreshIfNeeded();
78+
}
79+
80+
public override void SetTheme()
7081
{
7182
if (ColorThemeTag != "")
7283
{
7384
mColorTheme = GetColorTheme(ColorThemeTag);
85+
mCheckColorThemeTag = ColorThemeTag;
7486
}
7587

7688
if (PositionThemeTag != "")
7789
{
7890
mPositionTheme = GetVector3Theme(PositionThemeTag);
91+
mCheckPositionThemeTag = PositionThemeTag;
7992
}
8093

8194
if (ScaleThemeTag != "")
8295
{
8396
mScaleTheme = GetVector3Theme(ScaleThemeTag);
97+
mCheckScaleThemeTag = ScaleThemeTag;
8498
}
8599
}
86100

@@ -131,6 +145,15 @@ public override void SetState(Interactive.ButtonStateEnum state)
131145
}
132146
}
133147

148+
private void Update()
149+
{
150+
if(!mCheckScaleThemeTag.Equals(ScaleThemeTag) || !mCheckPositionThemeTag.Equals(PositionThemeTag) || !mCheckColorThemeTag.Equals(ColorThemeTag))
151+
{
152+
SetTheme();
153+
RefreshIfNeeded();
154+
}
155+
}
156+
134157
/// <summary>
135158
/// clean up if material was created dynamically
136159
/// </summary>

Assets/HoloToolkit-Examples/InteractiveElements/Scripts/Controls/ButtonThemeWidgetLabel.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using UnityEngine;
55
using System.Collections;
66
using HoloToolkit.Examples.Prototyping;
7+
using System;
78

89
namespace HoloToolkit.Examples.InteractiveElements
910
{
@@ -30,6 +31,9 @@ public class ButtonThemeWidgetLabel : InteractiveThemeWidget
3031

3132
// the TextMesh
3233
private TextMesh mText;
34+
35+
private string mCheckColorThemeTag = "";
36+
private string mCheckPositionThemeTag = "";
3337

3438
/// <summary>
3539
/// Get the TextMesh and position animation component
@@ -45,15 +49,23 @@ private void Awake()
4549
}
4650

4751
private void Start()
52+
{
53+
SetTheme();
54+
RefreshIfNeeded();
55+
}
56+
57+
public override void SetTheme()
4858
{
4959
if (ColorThemeTag != "")
5060
{
5161
mColorTheme = GetColorTheme(ColorThemeTag);
62+
mCheckColorThemeTag = ColorThemeTag;
5263
}
5364

5465
if (PositionThemeTag != "")
5566
{
5667
mPositionTheme = GetVector3Theme(PositionThemeTag);
68+
mCheckPositionThemeTag = PositionThemeTag;
5769
}
5870
}
5971

@@ -105,5 +117,14 @@ public override void SetState(Interactive.ButtonStateEnum state)
105117
}
106118
}
107119
}
120+
121+
private void Update()
122+
{
123+
if (!mCheckPositionThemeTag.Equals(PositionThemeTag) || !mCheckColorThemeTag.Equals(ColorThemeTag))
124+
{
125+
SetTheme();
126+
RefreshIfNeeded();
127+
}
128+
}
108129
}
109130
}

Assets/HoloToolkit-Examples/InteractiveElements/Scripts/Controls/ButtonThemeWidgetOutline.cs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using UnityEngine;
55
using System.Collections;
66
using HoloToolkit.Examples.Prototyping;
7+
using System;
78

89
namespace HoloToolkit.Examples.InteractiveElements
910
{
@@ -28,9 +29,12 @@ public class ButtonThemeWidgetOutline : InteractiveThemeWidget
2829
[Tooltip("A color tween component : required, but could be on a different object")]
2930
public ColorTransition ColorBlender;
3031

31-
private ColorInteractiveTheme mInnterColorTheme;
32+
private ColorInteractiveTheme mInnerColorTheme;
3233
private ColorInteractiveTheme mOuterColorTheme;
33-
34+
35+
private string mCheckInnerColorThemeTag = "";
36+
private string mCheckOuterColorThemeTag = "";
37+
3438
/// <summary>
3539
/// set the ColorBlender
3640
/// </summary>
@@ -52,15 +56,23 @@ private void Awake()
5256
/// get the themes
5357
/// </summary>
5458
private void Start()
59+
{
60+
SetTheme();
61+
RefreshIfNeeded();
62+
}
63+
64+
public override void SetTheme()
5565
{
5666
if (InnerColorThemeTag != "")
5767
{
58-
mInnterColorTheme = GetColorTheme(InnerColorThemeTag);
68+
mInnerColorTheme = GetColorTheme(InnerColorThemeTag);
69+
mCheckInnerColorThemeTag = InnerColorThemeTag;
5970
}
6071

6172
if (OuterColorThemeTag != "")
6273
{
6374
mOuterColorTheme = GetColorTheme(OuterColorThemeTag);
75+
mCheckOuterColorThemeTag = OuterColorThemeTag;
6476
}
6577
}
6678

@@ -72,15 +84,24 @@ public override void SetState(Interactive.ButtonStateEnum state)
7284
{
7385
base.SetState(state);
7486

75-
if (mInnterColorTheme != null)
87+
if (mInnerColorTheme != null)
7688
{
77-
ColorBlender.StartTransition(mInnterColorTheme.GetThemeValue(state), InnerMaterial.name);
89+
ColorBlender.StartTransition(mInnerColorTheme.GetThemeValue(state), InnerMaterial.name);
7890
}
7991

8092
if (mOuterColorTheme != null)
8193
{
8294
ColorBlender.StartTransition(mOuterColorTheme.GetThemeValue(state), OuterMaterial.name);
8395
}
8496
}
97+
98+
private void Update()
99+
{
100+
if (!mCheckOuterColorThemeTag.Equals(OuterColorThemeTag) || !mCheckInnerColorThemeTag.Equals(InnerColorThemeTag))
101+
{
102+
SetTheme();
103+
RefreshIfNeeded();
104+
}
105+
}
85106
}
86107
}

Assets/HoloToolkit-Examples/InteractiveElements/Scripts/Controls/SliderGestureControl.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ public override void ManipulationUpdate(Vector3 startGesturePosition, Vector3 cu
151151

152152
// get the current delta
153153
float delta = (CurrentDistance > 0) ? CurrentPercentage : -CurrentPercentage;
154-
print(delta);
155154

156155
// combine the delta with the current slider position so the slider does not start over every time
157156
mDeltaValue = Mathf.Clamp01(delta + mCachedValue);

Assets/HoloToolkit-Examples/InteractiveElements/Scripts/GestureInteractive.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4-
using UnityEngine;
54
using System.Collections;
5+
using HoloToolkit.Unity;
66
using HoloToolkit.Unity.InputModule;
7+
using UnityEngine;
8+
using Cursor = HoloToolkit.Unity.InputModule.Cursor;
79

8-
#if UNITY_EDITOR || UNITY_WSA
10+
#if UNITY_WSA || UNITY_STANDALONE_WIN
911
using UnityEngine.Windows.Speech;
1012
#endif
1113

@@ -22,14 +24,14 @@ public class GestureInteractive : Interactive, ISourceStateHandler
2224
/// <summary>
2325
/// Gesture Manipulation states
2426
/// </summary>
25-
public enum GestureManipulationState { None, Start, Update, Lost };
27+
public enum GestureManipulationState { None, Start, Update, Lost }
2628
public GestureManipulationState GestureState { get; protected set; }
2729

2830
private IInputSource mCurrentInputSource;
2931
private uint mCurrentInputSourceId;
3032

3133
[Tooltip("Sets the time before the gesture starts after a press has occured, handy when a select event is also being used")]
32-
public float StartDelay = 0;
34+
public float StartDelay;
3335

3436
[Tooltip ("The GestureInteractiveControl to send gesture updates to")]
3537
public GestureInteractiveControl Control;
@@ -38,7 +40,7 @@ public enum GestureManipulationState { None, Start, Update, Lost };
3840
/// Provide additional UI for gesture feedback.
3941
/// </summary>
4042
[Tooltip("Should this control hide the cursor during this manipulation?")]
41-
public bool HideCursorOnManipulation = false;
43+
public bool HideCursorOnManipulation;
4244

4345
/// <summary>
4446
/// cached gesture values for computations
@@ -47,7 +49,7 @@ public enum GestureManipulationState { None, Start, Update, Lost };
4749
private Vector3 mStartHeadRay;
4850
private Vector3 mStartHandPosition;
4951
private Vector3 mCurrentHandPosition;
50-
private HoloToolkit.Unity.InputModule.Cursor mCursor;
52+
private Cursor mCursor;
5153

5254
private Coroutine mTicker;
5355
private IInputSource mTempInputSource;
@@ -137,8 +139,8 @@ private void HandleStartGesture()
137139
mCurrentInputSource = mTempInputSource;
138140
mCurrentInputSourceId = mTempInputSourceId;
139141

140-
mStartHeadPosition = Camera.main.transform.position;
141-
mStartHeadRay = Camera.main.transform.forward;
142+
mStartHeadPosition = CameraCache.Main.transform.position;
143+
mStartHeadRay = CameraCache.Main.transform.forward;
142144

143145
Vector3 handPosition;
144146
mCurrentInputSource.TryGetPosition(mCurrentInputSourceId, out handPosition);
@@ -276,10 +278,10 @@ private Vector3 GetCurrentHandPosition()
276278
private void HandleCursor(bool state)
277279
{
278280
// Hack for now.
279-
// TODO: Update Cursor Modifyer to handle HideOnGesture, then calculate visibility so cursors can handle this correctly
281+
// TODO: Update Cursor Modifier to handle HideOnGesture, then calculate visibility so cursors can handle this correctly
280282
if (state)
281283
{
282-
mCursor = GameObject.FindObjectOfType<HoloToolkit.Unity.InputModule.Cursor>();
284+
mCursor = FindObjectOfType<Cursor>();
283285
}
284286

285287
if (HideCursorOnManipulation && mCursor != null)
@@ -302,7 +304,7 @@ protected override void Update()
302304
}
303305
}
304306

305-
#if UNITY_EDITOR || UNITY_WSA
307+
#if UNITY_WSA || UNITY_STANDALONE_WIN
306308
/// <summary>
307309
/// From Interactive, but customized for triggering gestures from keywords
308310
/// Handle the manipulation in the GestureInteractiveControl
@@ -312,11 +314,10 @@ protected override void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEve
312314
{
313315
base.KeywordRecognizer_OnPhraseRecognized(args);
314316

315-
int index;
316-
//base.KeywordRecognizer_OnPhraseRecognized(args);
317317
// Check to make sure the recognized keyword matches, then invoke the corresponding method.
318318
if ((!KeywordRequiresGaze || HasGaze) && mKeywordDictionary != null)
319319
{
320+
int index;
320321
if (mKeywordDictionary.TryGetValue(args.text, out index))
321322
{
322323
Control.setGestureValue(index);

Assets/HoloToolkit-Examples/InteractiveElements/Scripts/GestureInteractiveControl.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using UnityEngine;
55
using System.Collections;
6+
using HoloToolkit.Unity;
67

78
namespace HoloToolkit.Examples.InteractiveElements
89
{
@@ -86,7 +87,7 @@ public enum GestureDataType { Raw, Camera, Aligned }
8687
/// <summary>
8788
/// Camera reference
8889
/// </summary>
89-
protected Camera MainCamera { get { return Camera.main; } }
90+
protected Camera MainCamera { get { return CameraCache.Main; } }
9091

9192
/// <summary>
9293
/// Orientation based on the user facing direction.
@@ -385,7 +386,7 @@ private Vector3 RotateVectorOnY(Vector3 vector, Vector3 pivot, float angle)
385386
protected float FlipDistanceOnFacingControl(float toFlip, Vector3 controlPosition, Vector3 controlForward)
386387
{
387388
Vector3 cameraRay = StartHeadPosition - controlPosition;
388-
bool facingForward = Vector3.Dot(Camera.main.transform.forward, StartHeadRay) >= 0;
389+
bool facingForward = Vector3.Dot(MainCamera.transform.forward, StartHeadRay) >= 0;
389390
bool facingControl = Vector3.Dot(cameraRay, controlForward) >= 0;
390391

391392
if (!facingForward)

0 commit comments

Comments
 (0)