- Home /
When do I make something editable in the inspector?
I'm just wondering about convention-- in our code, we can serialize a field so that it appears in the inspector, allowing us to modify values. When should I use this? I could see that, for instance, if I am using a class that dozens of objects will use and have different values, I would do so. But, what if I have a script that will only be used by one object? Should I still serialize values? Or should I store them in scripts so that they are easier to maintain?
Answer by SlowCircuit · Jun 17, 2018 at 07:36 AM
Being able to edit the value in inspector means you can change the value at runtime without having to recompile and restart after every change. For instance, if your player has a movement speed variable, making that editable in inspector means you can tweak the speed and test it right away.
Making values editable in inspector is also useful for setting references. Instead of doing a ton of GameObject.FInd and GetComponent style calls, you can just drag it into the inspector slot.
Your answer
Follow this Question
Related Questions
Public fields not showing in inspector 2 Answers
Serializing lists 0 Answers
Serializable custom class with game object not shown 0 Answers
what does [Serializable] mean in C Sharp 5 Answers
Custom Inspector for an array of a serialized class 0 Answers