Skip to content

Conversation

@4demec
Copy link

@4demec 4demec commented Apr 13, 2024

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() 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() 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.

fixed incorrect non-reference return values causing null reference errors when being cast to T in GetItem<T>()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant