I’m using System.Serializable and SerializeField a lot in order to see the data inside my fields to make my work easy. Should i remove them when building?
I’m building for WebGL if this information is needed. By “build performance” I mean the built product (the WebGL page in my case) that will used by the end user.
I saw this and got more confused. Don’t know if it’s related to what i asked though.
[SerializeField] has no bearing on performance as far as i know. It is just a way to serialize a private field. As far as performance building goes I believe if you ever get to a point where Serializing is causing build performance than something else is wrong.
The only variables that should be public are those that need to be directly altered by another class somewhere. If you need to change it in the Inspector I always use [SerializeField].
public class Foo
Is also very similar. I run a ton of helper classes like this inside other Mono classes just to condense the code to a little more readability and to clean the inspector.
Maybe not as fast as creating the variables in the Mono class but again , This will not slow the game out of the microseconds category unless something is wrong.
Just my .01 1/2 cents. Someone feel free to correct me if I am wrong for sure.
It checks for SerializedField values/components each frame, so it’s resource-heavy if the component is not a simple value like float. Better to do something heavy once in on Start.