From 3b9324c19bfba7352928cbfbb56d4f2277ce22d2 Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Mon, 6 Nov 2017 18:28:30 -0800 Subject: [PATCH] cleaned up script --- .../UX/Scripts/OptimizeSceneforDeviceType.cs | 26 +++---------------- .../Boundary/Scripts/SceneContentAdjuster.cs | 19 +++++++++++--- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/Assets/HoloToolkit-Examples/UX/Scripts/OptimizeSceneforDeviceType.cs b/Assets/HoloToolkit-Examples/UX/Scripts/OptimizeSceneforDeviceType.cs index 7ba67189dd2..e154f4c2e11 100644 --- a/Assets/HoloToolkit-Examples/UX/Scripts/OptimizeSceneforDeviceType.cs +++ b/Assets/HoloToolkit-Examples/UX/Scripts/OptimizeSceneforDeviceType.cs @@ -2,35 +2,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. // -using HoloToolkit.Unity; -using System.Collections.Generic; + +using System; using UnityEngine; -using UnityEngine.XR.WSA; namespace HoloToolkit.Unity.Examples { + [Obsolete("Use SceneContentAdjuster")] public class OptimizeSceneforDeviceType : MonoBehaviour { public GameObject containerObject; - - void Start() - { - // Check if the device type is HoloLens or Immersive HMD - if (HolographicSettings.IsDisplayOpaque) - { - // Optimize the default postion of the objects for Immersive HMD - containerObject.transform.position = new Vector3(0.05f, 1.2f, 1.08f); - - } - else - { - // Optimize the default postion of the objects for HoloLens - containerObject.transform.position = new Vector3(0.05f, -0.65f, 1.65f); - - // Remove skybox for HoloLens - RenderSettings.skybox = null; - } - } - } } diff --git a/Assets/HoloToolkit/Boundary/Scripts/SceneContentAdjuster.cs b/Assets/HoloToolkit/Boundary/Scripts/SceneContentAdjuster.cs index 870ea7e534a..a466a0fd5c5 100644 --- a/Assets/HoloToolkit/Boundary/Scripts/SceneContentAdjuster.cs +++ b/Assets/HoloToolkit/Boundary/Scripts/SceneContentAdjuster.cs @@ -1,7 +1,10 @@ -using HoloToolkit.Unity.Boundary; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + using UnityEngine; #if UNITY_2017_2_OR_NEWER +using HoloToolkit.Unity.Boundary; using UnityEngine.XR; #else using UnityEngine.VR; @@ -12,13 +15,23 @@ public class SceneContentAdjuster : MonoBehaviour private Vector3 lastFloorHeight; private float floorHeightOffset = 1f; + [SerializeField] + [Tooltip("Optional container object reference. If null, this script will move the object it's attached to.")] + private Transform containerObject; + + private void Awake() { + if (containerObject == null) + { + containerObject = transform; + } + #if UNITY_2017_2_OR_NEWER if (Application.isEditor && XRDevice.isPresent) { lastFloorHeight.y = floorHeightOffset; - transform.position = lastFloorHeight; + containerObject.position = lastFloorHeight; } #else if (VRDevice.isPresent) @@ -38,7 +51,7 @@ private void Update() if (lastFloorHeight.y != floorHeightOffset) { lastFloorHeight.y = floorHeightOffset; - transform.position = lastFloorHeight; + containerObject.position = lastFloorHeight; } } #endif