Skip to content

Commit

Permalink
Merge pull request microsoft#25 from keveleigh/Ecnassianer-SolverExam…
Browse files Browse the repository at this point in the history
…pleUpdates

Responding to feedback
  • Loading branch information
Ecnassianer authored Jun 13, 2018
2 parents 3996719 + a0ee02c commit 929c4a0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 25 deletions.
38 changes: 16 additions & 22 deletions Assets/HoloToolkit-Examples/Utilities/Scripts/SwapVolume.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using HoloToolkit.Unity.InputModule;
using UnityEngine;

namespace HoloToolkit.Unity.InputModule.Tests
namespace HoloToolkit.Unity.Examples.Utilities
{
/// <summary>
/// This class is used in the SolverExamples scene, used to swap between active solvers
Expand All @@ -21,9 +22,17 @@ public class SwapVolume : MonoBehaviour, IInputClickHandler
private bool updateSolverTargetToClickSource = true;

private SolverHandler solverHandler;
private bool isOn = false;
private GameObject spawnedObject;

private void Awake()
{
// This example script depends on both GameObjects being properly set.
if (hideThisObject == null || spawnThisPrefab == null)
{
Destroy(gameObject);
}
}

private void Start()
{
spawnedObject = Instantiate(spawnThisPrefab, hideThisObject.transform.position, hideThisObject.transform.rotation);
Expand All @@ -33,27 +42,16 @@ private void Start()

public void OnInputClicked(InputClickedEventData eventData)
{
if (isOn)
if (spawnedObject.activeSelf)
{
if (spawnedObject != null)
{
spawnedObject.SetActive(false);
}
if (hideThisObject != null)
{
hideThisObject.SetActive(true);
}
spawnedObject.SetActive(false);
hideThisObject.SetActive(true);
}
else
{
if (spawnedObject == null)
{
return;
}

spawnedObject.SetActive(true);

if (updateSolverTargetToClickSource)
if (updateSolverTargetToClickSource && solverHandler != null)
{
InteractionInputSource interactionInputSource = eventData.InputSource as InteractionInputSource;

Expand Down Expand Up @@ -86,13 +84,9 @@ public void OnInputClicked(InputClickedEventData eventData)
}
}

if (hideThisObject != null)
{
hideThisObject.SetActive(false);
}
hideThisObject.SetActive(false);
}

isOn = !isOn;
eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.

using UnityEngine;
#if UNITY_WSA
#if UNITY_2017_2_OR_NEWER
using UnityEngine.XR.WSA.Input;
#else
using UnityEngine.VR.WSA.Input;
#endif
#endif

namespace HoloToolkit.Unity.InputModule
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ public class SolverInBetweenEditor : Editor

private void OnEnable()
{

trackedObjectReferenceProperty = serializedObject.FindProperty("trackedObjectForSecondTransform");
transformTargetProperty = serializedObject.FindProperty("secondTransformOverride");

solverInBetween = target as SolverInBetween;
}
}

public override void OnInspectorGUI()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class SolverInBetween : Solver
{
[SerializeField]
[Tooltip("Distance along the center line the object will be located. 0.5 is halfway, 1.0 is at the second transform, 0.0 is at the first transform.")]
[Range(0f, 1f)]
private float partwayOffset = 0.5f;

/// <summary>
Expand All @@ -20,7 +21,7 @@ public class SolverInBetween : Solver
public float PartwayOffset
{
get { return partwayOffset; }
set { partwayOffset = value; }
set { partwayOffset = Mathf.Clamp(value, 0.0f, 1.0f); }
}

[SerializeField]
Expand Down

0 comments on commit 929c4a0

Please sign in to comment.