From 07ed9c0986725dd614889ade96fb88cf39abdb17 Mon Sep 17 00:00:00 2001 From: Adam Mollis <36461279+AMollis@users.noreply.github.com> Date: Thu, 20 Jul 2023 23:15:31 -0700 Subject: [PATCH] Fixing XML Documentation warnings. Pass 4 (#11724) * Fixing XML Documentation warnings --- .../EyeTracking/EyeTrackingUtilities.cs | 27 ++++---- .../TargetPositioning/MoveObjectByEyeGaze.cs | 61 ++++++++++--------- .../EyeTracking/Visualizer/DrawOnTexture.cs | 2 +- 3 files changed, 46 insertions(+), 44 deletions(-) diff --git a/UnityProjects/MRTKDevTemplate/Assets/Scripts/EyeTracking/EyeTrackingUtilities.cs b/UnityProjects/MRTKDevTemplate/Assets/Scripts/EyeTracking/EyeTrackingUtilities.cs index 80d1df9be06..4bb1665322b 100644 --- a/UnityProjects/MRTKDevTemplate/Assets/Scripts/EyeTracking/EyeTrackingUtilities.cs +++ b/UnityProjects/MRTKDevTemplate/Assets/Scripts/EyeTracking/EyeTrackingUtilities.cs @@ -49,15 +49,15 @@ public static IEnumerator LoadNewScene(string sceneToBeLoaded, float delayInSeco /// /// Change the material color of the given . /// - /// The object whose material colors will be changed. + /// The object whose material colors will be changed. /// The new color to apply to the object's materials. /// Obtain the original color of the first material's . This must be to obtain this original color. /// to only change materials on the root , and to change children's materials too. - public static void SetGameObjectColor(GameObject gameObject, Color newColor, ref Color? originalColor, bool onlyApplyToRoot) + public static void SetGameObjectColor(GameObject target, Color newColor, ref Color? originalColor, bool onlyApplyToRoot) { try { - Renderer[] renderers = gameObject.GetComponents(); + Renderer[] renderers = target.GetComponents(); for (int i = 0; i < renderers.Length; i++) { Material[] mats = renderers[i].materials; @@ -76,7 +76,7 @@ public static void SetGameObjectColor(GameObject gameObject, Color newColor, ref if (!onlyApplyToRoot) { - renderers = gameObject.GetComponentsInChildren(); + renderers = target.GetComponentsInChildren(); for (int i = 0; i < renderers.Length; i++) { Material[] mats = renderers[i].materials; @@ -94,29 +94,30 @@ public static void SetGameObjectColor(GameObject gameObject, Color newColor, ref } /// - /// Change the transparency of game object "gameObject" with a transparency value between 0 and 1; + /// Change the transparency of a with a transparency value between 0 and 1. /// - public static void GameObject_ChangeTransparency(GameObject gameObject, float newTransparency) + public static void SetGameObjectTransparency(GameObject target, float newTransparency) { float originalTransparency = 0; // just a dummy variable to reuse the following function - GameObject_ChangeTransparency(gameObject, newTransparency, ref originalTransparency); + SetGameObjectTransparency(target, newTransparency, ref originalTransparency); } /// - /// Change the transparency of game object "gameObject" with a transparency value between 0 and 255 with the option to + /// Change the transparency of a with a transparency value between 0 and 255 with the option to /// receive the original transparency value back. /// + /// The function will query for instances on this target object, and change the transparency on the found instances. /// Expected values range from 0 (fully transparent) to 1 (fully opaque). /// Input "-1" if you don't know the original transparency yet. - public static void GameObject_ChangeTransparency(GameObject gameObject, float transparency, ref float originalTransparency) + public static void SetGameObjectTransparency(GameObject target, float transparency, ref float originalTransparency) { try { // Go through renderers in main object - Renderers_ChangeTransparency(gameObject.GetComponents(), transparency, ref originalTransparency); + SetRenderersTransparency(target.GetComponents(), transparency, ref originalTransparency); // Go through renderers in children objects - Renderers_ChangeTransparency(gameObject.GetComponentsInChildren(), transparency, ref originalTransparency); + SetRenderersTransparency(target.GetComponentsInChildren(), transparency, ref originalTransparency); } catch (System.Exception) { @@ -125,12 +126,12 @@ public static void GameObject_ChangeTransparency(GameObject gameObject, float tr } /// - /// Change the transparency of a given array of renderers to a given transparency value between 0 and 255; + /// Change the transparency of a given array of renderers to a given transparency value between 0 and 255. /// /// Array of renderers to apply a new transparency value to. /// Value between 0 and 255. /// Option to return the original transparency value. - private static void Renderers_ChangeTransparency(Renderer[] renderers, float transparency, ref float originalTransparency) + private static void SetRenderersTransparency(Renderer[] renderers, float transparency, ref float originalTransparency) { for (int i = 0; i < renderers.Length; i++) { diff --git a/UnityProjects/MRTKDevTemplate/Assets/Scripts/EyeTracking/TargetPositioning/MoveObjectByEyeGaze.cs b/UnityProjects/MRTKDevTemplate/Assets/Scripts/EyeTracking/TargetPositioning/MoveObjectByEyeGaze.cs index e93cf23e172..be0af55952d 100644 --- a/UnityProjects/MRTKDevTemplate/Assets/Scripts/EyeTracking/TargetPositioning/MoveObjectByEyeGaze.cs +++ b/UnityProjects/MRTKDevTemplate/Assets/Scripts/EyeTracking/TargetPositioning/MoveObjectByEyeGaze.cs @@ -135,7 +135,7 @@ private bool private bool manualTargetManipulation = false; - private Vector3 initalGazeDirection; + private Vector3 initialGazeDirection; private static bool isManipulatingUsingHands = false; private static bool isManipulatingUsingVoice = false; private Vector3 handPositionAbsolute; @@ -147,8 +147,8 @@ private bool private Ray? headPreviousRay; private float headDeltaDirectionThreshold = 0.05f; - private float headSmoothf = 0.1f; - private float headDeltaDirectionf = 0f; + private float headSmooth = 0.1f; + private float headDeltaDirection = 0f; private int ConstraintX => freezeX ? 0 : 1; private int ConstraintY => freezeY ? 0 : 1; @@ -164,6 +164,7 @@ private bool private readonly float minDiffAngleForVerticalPlacement = 50f; #endregion + /// public override float GetSelectionProgress() { return objectIsGrabbed ? 1f : base.GetSelectionProgress(); @@ -453,7 +454,7 @@ private void ActivatePreview() { previewGameObject = Instantiate(gameObject); previewGameObject.GetComponent().enabled = false; - EyeTrackingUtilities.GameObject_ChangeTransparency(previewGameObject, transparencyPreview); + EyeTrackingUtilities.SetGameObjectTransparency(previewGameObject, transparencyPreview); placePreviewAtHitPoint = false; } @@ -481,17 +482,17 @@ private void DragAndDrop_Start() if (!objectIsGrabbed && isHovered) { objectIsGrabbed = true; - EyeTrackingUtilities.GameObject_ChangeTransparency(gameObject, transparencyInTransition, ref originalTransparency); + EyeTrackingUtilities.SetGameObjectTransparency(gameObject, transparencyInTransition, ref originalTransparency); initialHandPosition = handPositionAbsolute; - initalGazeDirection = new Vector3(Camera.main.transform.forward.x, Camera.main.transform.forward.y, Camera.main.transform.forward.z); + initialGazeDirection = new Vector3(Camera.main.transform.forward.x, Camera.main.transform.forward.y, Camera.main.transform.forward.z); - if (TryGetComponent(out var rbody)) + if (TryGetComponent(out var rigidbody)) { - originalUseGravity = rbody.useGravity; - originalDrag = rbody.drag; + originalUseGravity = rigidbody.useGravity; + originalDrag = rigidbody.drag; - rbody.useGravity = false; - rbody.drag = float.PositiveInfinity; + rigidbody.useGravity = false; + rigidbody.drag = float.PositiveInfinity; } } } @@ -516,11 +517,11 @@ private void DragAndDrop_Finish() objectIsGrabbed = false; DeactivatePreview(); - EyeTrackingUtilities.GameObject_ChangeTransparency(gameObject, originalTransparency); - if (TryGetComponent(out var rbody)) + EyeTrackingUtilities.SetGameObjectTransparency(gameObject, originalTransparency); + if (TryGetComponent(out var rigidbody)) { - rbody.useGravity = originalUseGravity; - rbody.drag = originalDrag; + rigidbody.useGravity = originalUseGravity; + rigidbody.drag = originalDrag; } onDrop.Invoke(); @@ -541,20 +542,20 @@ private void RelativeMoveUpdate(Vector3 relativeMovement) /// private float Angle_InitialGazeToCurrGazeDir() { - return Vector3.Angle(initalGazeDirection, Camera.main.transform.forward); + return Vector3.Angle(initialGazeDirection, Camera.main.transform.forward); } /// - /// Compute angle between target center ( OR original targeting location??? ) and current targeting direction + /// Compute angle between target center and current targeting direction /// - private float Angle_ToCurrHitTarget(GameObject gobj) + private float Angle_ToCurrHitTarget(GameObject target) { if (gazeInteractor.PreciseHitResult.targetInteractable != null) { // Target is currently hit - if (gazeInteractor.PreciseHitResult.targetInteractable.transform.gameObject == gobj) + if (gazeInteractor.PreciseHitResult.targetInteractable.transform.gameObject == target) { - initalGazeDirection = new Vector3(Camera.main.transform.forward.x, Camera.main.transform.forward.y, Camera.main.transform.forward.z); + initialGazeDirection = new Vector3(Camera.main.transform.forward.x, Camera.main.transform.forward.y, Camera.main.transform.forward.z); return 0.0f; } @@ -579,9 +580,9 @@ private bool HeadIsInMotion() float deltaDir = Vector3.Distance(headPreviousRay.Value.direction, forward); if (deltaPos != 0f && deltaDir != 0f) { - headDeltaDirectionf = deltaDir * headSmoothf + headDeltaDirectionf * (1f - headSmoothf); + headDeltaDirection = deltaDir * headSmooth + headDeltaDirection * (1f - headSmooth); - headIsInMotion = headDeltaDirectionf > headDeltaDirectionThreshold; + headIsInMotion = headDeltaDirection > headDeltaDirectionThreshold; } } @@ -617,13 +618,13 @@ private void MoveTargetBy(Vector3 delta) hitPosition.y += gameObject.transform.localScale.y * 0.5f; } - Vector3 objp = gameObject.transform.position; + Vector3 objectPosition = gameObject.transform.position; // Constrain in y-direction gameObject.transform.position = new Vector3( - (((ConstraintX + 1) % 2) * objp.x) + (ConstraintX * hitPosition.x), - (((ConstraintY + 1) % 2) * objp.y) + (ConstraintY * hitPosition.y), - (((ConstraintZ + 1) % 2) * objp.z) + (ConstraintZ * hitPosition.z)); + (((ConstraintX + 1) % 2) * objectPosition.x) + (ConstraintX * hitPosition.x), + (((ConstraintY + 1) % 2) * objectPosition.y) + (ConstraintY * hitPosition.y), + (((ConstraintZ + 1) % 2) * objectPosition.z) + (ConstraintZ * hitPosition.z)); ConstrainMovement(); @@ -675,13 +676,13 @@ private void MoveTargetTo(Vector3 destination) destination.y += gameObject.transform.localScale.y * 0.5f; } - Vector3 objp = gameObject.transform.position; + Vector3 objectPosition = gameObject.transform.position; // Constrain movement gameObject.transform.position = new Vector3( - ((ConstraintX + 1) % 2 * objp.x) + (ConstraintX * destination.x), - ((ConstraintY + 1) % 2 * objp.y) + (ConstraintY * destination.y), - ((ConstraintZ + 1) % 2 * objp.z) + (ConstraintZ * destination.z)); + ((ConstraintX + 1) % 2 * objectPosition.x) + (ConstraintX * destination.x), + ((ConstraintY + 1) % 2 * objectPosition.y) + (ConstraintY * destination.y), + ((ConstraintZ + 1) % 2 * objectPosition.z) + (ConstraintZ * destination.z)); initialHandPosition = handPositionAbsolute; } diff --git a/UnityProjects/MRTKDevTemplate/Assets/Scripts/EyeTracking/Visualizer/DrawOnTexture.cs b/UnityProjects/MRTKDevTemplate/Assets/Scripts/EyeTracking/Visualizer/DrawOnTexture.cs index 102c9572b5f..a82a3e24159 100644 --- a/UnityProjects/MRTKDevTemplate/Assets/Scripts/EyeTracking/Visualizer/DrawOnTexture.cs +++ b/UnityProjects/MRTKDevTemplate/Assets/Scripts/EyeTracking/Visualizer/DrawOnTexture.cs @@ -92,7 +92,7 @@ public override void ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase up } /// - /// Updates the heat map with a hit at . + /// Updates the heat map with a hit at . /// /// The hit position in world co-ordinates. public void DrawAtThisHitPos(Vector3 hitPosition)