Skip to content

Conversation

@marc-antoine-girard
Copy link
Contributor

Description

Fixes #31.

This is a weird bug, because it only happens when the ReferenceMode mode variable is defaulted to ReferenceMode.Unity. A quick fix would have been to make it equal to ReferenceMode.Raw, but this implementation makes also a lot of sense. This is simply a safer way to cast.

Adding the where TInterface : class also removes some warning about potential boxing.

Note

Right now, while the fields are defaulted to ReferenceMode.Unity, elements in lists are not and will show None (Mono Script). It seems Unity instantiates the class, but then changes all the fields to a default value.
image
This means that switching the order of the values in the enum would make ReferenceMode.Unity the default one, and apparently, it is true:

image

@Thundernerd Thundernerd merged commit 3ae1fd4 into Thundernerd:main Jul 22, 2022
@Thundernerd
Copy link
Owner

🎉 This PR is included in version 1.7.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InvalidCastException when accessing Value property

2 participants