MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

Directional Indicator throw exception when object is destroyed

Open decoc opened this issue 6 years ago • 0 comments

Describe the bug

Directional Indicator throw exception when object is destroyed due to use wrong flag.

To reproduce

Steps to reproduce the behavior:

  1. Attach Directional Indicator to gameobject
  2. Set any transform of gameobject to Directional target in Directional Indicator
  3. Destroy GameObject
  4. See error

Expected behavior

Directional Indicator become invisible when lost target object.

Your setup (please complete the following information)

  • Unity Version 2018.4.11f
  • MRTK Version 2.3

Target platform (please complete the following information)

  • HoloLens 2

Suggestion

DirectionalIndicator.cs

        private bool IsVisible()
        {
            if (DirectionalTarget == null || SolverHandler.TransformTarget == null)
            {
                return true;  //<-- chage true from false
            }

            return MathUtilities.IsInFOV(DirectionalTarget.position, SolverHandler.TransformTarget,
                VisibilityScaleFactor * CameraCache.Main.fieldOfView, VisibilityScaleFactor * CameraCache.Main.GetHorizontalFieldOfViewDegrees(),
                CameraCache.Main.nearClipPlane, CameraCache.Main.farClipPlane);
        }

It will work as expected, however, IsVisible() is not an intuitive name. I suggest that change method name to IsInvisible() or something else.

decoc avatar Feb 16 '20 14:02 decoc