MixedRealityToolkit-Unity
MixedRealityToolkit-Unity copied to clipboard
Directional Indicator throw exception when object is destroyed
Describe the bug
Directional Indicator throw exception when object is destroyed due to use wrong flag.
To reproduce
Steps to reproduce the behavior:
- Attach Directional Indicator to gameobject
- Set any transform of gameobject to Directional target in Directional Indicator
- Destroy GameObject
- 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.