Closed FejZa closed 2 years ago
It's a lot easier to set a component active/inactive using the enabled
property.
This extension method was meant to be used purely to enable/disable the game object that the component is attached to.
Yes, but enabled
is again a whole different story.
"This extension method was meant to be used purely to enable/disable the game object that the component is attached to."
Exactly, and that is what it is failing to do.
IF the parent game object is disabled but the game object that it is attached to is not, then SetActive(false) won't disable it.
The fix would be:
if (component.gameObject.activeSelf != isActive)
{
component.gameObject.SetActive(isActive);
}
Makes sense to me. Thanks for catching this! 🙏
XRTK - Mixed Reality Toolkit Bug Report
Describe the bug
XRTK's component extension SetActive
is error prone and it differs from people would expect when setting a GameObject active / inactive.
activeInHierarchy
is not the same asactiveSelf
. If an object is notactiveInHierarchy
butactiveSelf
callingSetActive(false)
using this extension will result in the object not being set to inactive.