StatefulUI icon indicating copy to clipboard operation
StatefulUI copied to clipboard

Fixed incorrect return values

Open 4demec opened this issue 1 year ago • 0 comments

When using GetImage(), GetContainer(),GetSlider(), and GetToggle(), the Unity UI component is returned, instead of the expected reference types.

Using GetImage() as an example, GetItem<T>() is only ever called with T being an ImageReference type, ContainerReference type, etc. When GetImage(roleValue) returns an Image, it then gets cast to type ImageReference, and fails because the two types aren't compatible, thus creating a NullReferenceException.

Furthermore, there was a previous fix to this (Images only, not containers/sliders/toggles) by creating a new method called GetImageReference() and replacing GetImage() in GetItem<T>() with it. However, GetImage() is not used elsewhere, so I have fixed GetImage() as the other methods do not have GetXReference() in their name in the current convention, and removed the GetImageReference() method.

4demec avatar Apr 13 '24 22:04 4demec