JetBrains / JetBrains/resharper-unity

Warn if a serialized field is being excluded from build with #if UNITY_EDITOR

Open
#427 9 comments 4 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.2k
Forks
142
PR merge metrics
No merged PRs in 30d

Description

Unity doesn't like when the serialized data layout changes between the editor and builds.
For example, having something like this in a behavior `SomeBehaviour`

```
#if UNITY_EDITOR
[SerializeField]
private int _someField;
#endif
```

or this

```
#if UNITY_EDITOR
public int SomeField;
#endif
```

will cause problems in builds (A script behavior (probably SomeBehavior) has a different serialization layout when loading. (Read X bytes but expected Y bytes))

Having a warning (or error) for those situations would be pretty nice.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.