diff --git a/Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployPortal.cs b/Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployPortal.cs index b08813d1628..a0725fdb033 100644 --- a/Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployPortal.cs +++ b/Assets/HoloToolkit/BuildAndDeploy/Editor/BuildDeployPortal.cs @@ -71,7 +71,9 @@ private static string WebRequestGet(string query, string auth, bool showProgress using (var webRequest = UnityWebRequest.Get(query)) { webRequest.SetRequestHeader("Authorization", auth); +#if UNITY_2017_1_OR_NEWER webRequest.timeout = (int)TimeOut; +#endif #if UNITY_2017_2_OR_NEWER webRequest.SendWebRequest(); @@ -149,7 +151,9 @@ private static string WebRequestPost(string query, WWWForm postData, string auth using (var webRequest = UnityWebRequest.Post(query, postData)) { webRequest.SetRequestHeader("Authorization", auth); +#if UNITY_2017_1_OR_NEWER webRequest.timeout = (int)TimeOut; +#endif // HACK: Workaround for extra quotes around boundary. string contentType = webRequest.GetRequestHeader("Content-Type"); @@ -236,7 +240,9 @@ private static bool WebRequestDelete(string query, string auth, bool showDialog using (var webRequest = UnityWebRequest.Delete(query)) { webRequest.SetRequestHeader("Authorization", auth); +#if UNITY_2017_1_OR_NEWER webRequest.timeout = (int)TimeOut; +#endif #if UNITY_2017_2_OR_NEWER webRequest.SendWebRequest(); diff --git a/Assets/HoloToolkit/Common/Scripts/Extensions/InteractionSourceExtensions.cs b/Assets/HoloToolkit/Common/Scripts/Extensions/InteractionSourceExtensions.cs index 97df7f50176..ebb44d33740 100644 --- a/Assets/HoloToolkit/Common/Scripts/Extensions/InteractionSourceExtensions.cs +++ b/Assets/HoloToolkit/Common/Scripts/Extensions/InteractionSourceExtensions.cs @@ -28,13 +28,14 @@ namespace HoloToolkit.Unity /// public static class InteractionSourceExtensions { +#if UNITY_2017_2_OR_NEWER #if UNITY_EDITOR_WIN && UNITY_WSA [DllImport("EditorMotionController")] private static extern bool StartHaptics([In] uint controllerId, [In] float intensity, [In] float durationInSeconds); [DllImport("EditorMotionController")] private static extern bool StopHaptics([In] uint controllerId); -#endif +#endif // UNITY_EDITOR_WIN && UNITY_WSA // This value is standardized according to www.usb.org/developers/hidpage/HUTRR63b_-_Haptics_Page_Redline.pdf private const ushort ContinuousBuzzWaveform = 0x1004; @@ -52,7 +53,7 @@ public static void StartHaptics(this InteractionSource interactionSource, float return; } -#if !UNITY_EDITOR && UNITY_2017_2_OR_NEWER +#if !UNITY_EDITOR UnityEngine.WSA.Application.InvokeOnUIThread(() => { IReadOnlyList sources = SpatialInteractionManager.GetForCurrentView().GetDetectedSourcesAtTimestamp(PerceptionTimestampHelper.FromHistoricalTargetTime(DateTimeOffset.Now)); @@ -80,9 +81,9 @@ public static void StartHaptics(this InteractionSource interactionSource, float } } }, true); -#elif UNITY_EDITOR_WIN && UNITY_2017_2_OR_NEWER +#elif UNITY_EDITOR_WIN StartHaptics(interactionSource.id, intensity, durationInSeconds); -#endif +#endif // !UNITY_EDITOR } public static void StopHaptics(this InteractionSource interactionSource) @@ -92,7 +93,7 @@ public static void StopHaptics(this InteractionSource interactionSource) return; } -#if !UNITY_EDITOR && UNITY_2017_2_OR_NEWER +#if !UNITY_EDITOR UnityEngine.WSA.Application.InvokeOnUIThread(() => { IReadOnlyList sources = SpatialInteractionManager.GetForCurrentView().GetDetectedSourcesAtTimestamp(PerceptionTimestampHelper.FromHistoricalTargetTime(DateTimeOffset.Now)); @@ -105,12 +106,12 @@ public static void StopHaptics(this InteractionSource interactionSource) } } }, true); -#elif UNITY_EDITOR_WIN && UNITY_2017_2_OR_NEWER +#elif UNITY_EDITOR_WIN StopHaptics(interactionSource.id); -#endif +#endif // !UNITY_EDITOR } -#if !UNITY_EDITOR && UNITY_2017_2_OR_NEWER +#if !UNITY_EDITOR public static IAsyncOperation TryGetRenderableModelAsync(this InteractionSource interactionSource) { IAsyncOperation returnValue = null; @@ -133,7 +134,8 @@ public static IAsyncOperation TryGetRenderab return returnValue; } -#endif -#endif +#endif // !UNITY_EDITOR +#endif // UNITY_WSA +#endif // UNITY_2017_2_OR_NEWER } } diff --git a/Assets/HoloToolkit/Input/Scripts/Focus/FocusManager.cs b/Assets/HoloToolkit/Input/Scripts/Focus/FocusManager.cs index 7bf8369b937..da97e6fd77b 100644 --- a/Assets/HoloToolkit/Input/Scripts/Focus/FocusManager.cs +++ b/Assets/HoloToolkit/Input/Scripts/Focus/FocusManager.cs @@ -347,7 +347,11 @@ public GameObject TryGetFocusedObject(BaseEventData eventData) TryGetPointingSource(eventData, out pointingSource); PointerInputEventData pointerInputEventData = GetSpecificPointerEventData(pointingSource); - Debug.Assert(pointerInputEventData != null); + // GetSpecificPointerEventData can return null. Be sure to handle that case. + if (pointerInputEventData == null) + { + return null; + } return pointerInputEventData.selectedObject; } diff --git a/Assets/HoloToolkit/UX/Scripts/BoundingBoxes/BoundingBoxGizmoHandle.cs b/Assets/HoloToolkit/UX/Scripts/BoundingBoxes/BoundingBoxGizmoHandle.cs index 0a3d7c22c59..7445f5c8e71 100644 --- a/Assets/HoloToolkit/UX/Scripts/BoundingBoxes/BoundingBoxGizmoHandle.cs +++ b/Assets/HoloToolkit/UX/Scripts/BoundingBoxes/BoundingBoxGizmoHandle.cs @@ -224,6 +224,7 @@ private void ApplyScale(Vector3 currentHandPosition) } private void ApplyRotation(Quaternion currentHandOrientation) { +#if UNITY_2017_1_OR_NEWER Matrix4x4 m = Matrix4x4.Rotate(initialHandOrientation); Vector3 initRay = new Vector3(0, 0, 1); initRay = m.MultiplyPoint(initRay); @@ -260,6 +261,7 @@ private void ApplyRotation(Quaternion currentHandOrientation) transformToAffect.localRotation = initialRotation; transformToAffect.Rotate(axis, angle * 5.0f); } +#endif // UNITY_2017_1_OR_NEWER } private void ApplyRotation(Vector3 currentHandPosition) { diff --git a/Assets/HoloToolkit/UX/Scripts/BoundingBoxes/BoundingBoxRig.cs b/Assets/HoloToolkit/UX/Scripts/BoundingBoxes/BoundingBoxRig.cs index fde8804cf81..a744634d68c 100644 --- a/Assets/HoloToolkit/UX/Scripts/BoundingBoxes/BoundingBoxRig.cs +++ b/Assets/HoloToolkit/UX/Scripts/BoundingBoxes/BoundingBoxRig.cs @@ -489,13 +489,14 @@ private List GetBounds() BoundingBox.GetMeshFilterBoundsPoints(clone, bounds, mask); Vector3 centroid = boxInstance.TargetBoundsCenter; GameObject.Destroy(clone); +#if UNITY_2017_1_OR_NEWER Matrix4x4 m = Matrix4x4.Rotate(objectToBound.transform.rotation); for (int i = 0; i < bounds.Count; ++i) { bounds[i] = m.MultiplyPoint(bounds[i]); bounds[i] += boxInstance.TargetBoundsCenter; } - +#endif // UNITY_2017_1_OR_NEWER return bounds; } diff --git a/Assets/HoloToolkit/Utilities/Scripts/AtlasReferenceUpdater/AtlasPrefabReference.cs b/Assets/HoloToolkit/Utilities/Scripts/AtlasReferenceUpdater/AtlasPrefabReference.cs index 2b62e756dd6..ebc58321c23 100644 --- a/Assets/HoloToolkit/Utilities/Scripts/AtlasReferenceUpdater/AtlasPrefabReference.cs +++ b/Assets/HoloToolkit/Utilities/Scripts/AtlasReferenceUpdater/AtlasPrefabReference.cs @@ -2,13 +2,17 @@ // Licensed under the MIT License. See LICENSE in the project root for license information. using System.Collections.Generic; using UnityEngine; +#if UNITY_2017_1_OR_NEWER using UnityEngine.U2D; +#endif // UNITY_2017_1_OR_NEWER namespace HoloToolkit.Unity { public class AtlasPrefabReference : ScriptableObject { +#if UNITY_2017_1_OR_NEWER [SerializeField] public List Prefabs; [SerializeField] public SpriteAtlas Atlas; +#endif // UNITY_2017_1_OR_NEWER } } diff --git a/Assets/HoloToolkit/Utilities/Scripts/AtlasReferenceUpdater/Editor/AtlasReferenceUpdater.cs b/Assets/HoloToolkit/Utilities/Scripts/AtlasReferenceUpdater/Editor/AtlasReferenceUpdater.cs index 1739238c99f..82caf5875cc 100644 --- a/Assets/HoloToolkit/Utilities/Scripts/AtlasReferenceUpdater/Editor/AtlasReferenceUpdater.cs +++ b/Assets/HoloToolkit/Utilities/Scripts/AtlasReferenceUpdater/Editor/AtlasReferenceUpdater.cs @@ -11,6 +11,7 @@ namespace HoloToolkit.Unity [InitializeOnLoad] public class AtlasReferenceUpdater : UnityEditor.AssetModificationProcessor { +#if UNITY_2017_1_OR_NEWER private static readonly List References = new List(); static AtlasReferenceUpdater() @@ -115,5 +116,6 @@ private static IEnumerable GetDistinctSprites(IEnumerable pr return prefabs.SelectMany(p => p.GetComponentsInChildren()) .Select(img => img.sprite).Where(img => img != null).Distinct(); } +#endif // UNITY_2017_1_OR_NEWER } } diff --git a/Assets/HoloToolkit/Utilities/Scripts/AtlasReferenceUpdater/Editor/Extensions/SpriteAtlasExtensions.cs b/Assets/HoloToolkit/Utilities/Scripts/AtlasReferenceUpdater/Editor/Extensions/SpriteAtlasExtensions.cs index 413be7c53b4..7f37387271f 100644 --- a/Assets/HoloToolkit/Utilities/Scripts/AtlasReferenceUpdater/Editor/Extensions/SpriteAtlasExtensions.cs +++ b/Assets/HoloToolkit/Utilities/Scripts/AtlasReferenceUpdater/Editor/Extensions/SpriteAtlasExtensions.cs @@ -9,6 +9,7 @@ namespace HoloToolkit.Unity { public static class SpriteAtlasExtensions { +#if UNITY_2017_1_OR_NEWER public const string SpritePackables = "m_EditorData.packables"; public static void SetSprites(this SpriteAtlas spriteAtlas, IList sprites) @@ -31,5 +32,6 @@ public static bool ContainsSprite(this SpriteAtlas spriteAtlas, Sprite sprite) } return false; } +#endif // UNITY_2017_1_OR_NEWER } }