Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint-ban GameObject.isStatic in non-editor code #232

Open
jeffomatic opened this issue Jul 10, 2022 · 0 comments
Open

Lint-ban GameObject.isStatic in non-editor code #232

jeffomatic opened this issue Jul 10, 2022 · 0 comments

Comments

@jeffomatic
Copy link

jeffomatic commented Jul 10, 2022

Problem statement

When read in the editor, including during playmode, the isStaticproperty of a GameObject instance may be true or false depending on how the object is configured in the inspector. However, in builds, the property is always false. At least, I have observed it to be always false in Unity 2021.3f1.

The fact that runtime behavior is different between builds and the editor playmode can lead to subtle bugs, including the one I just spent the whole day debugging! It is fair to say that neither the property name nor the docs make this behavior discoverable. Honestly, I would prefer if Unity just crashed if the property were read from a build runtime, but a lint ban would do nicely.

There seems to be a decade's worth of grousing about this issue in the forums.

Proposed solution

Issue a warning any time isStatic is read from a GameObject instance, except when any of the following conditions are true:

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

No branches or pull requests

2 participants