About 'Using SerializeField vs public'!

In this lecture…

  1. Multiply a vector by a float to change length.
  2. SerializeField vs public to expose to Inspector.
  3. Creating design “levers”.
  4. Tweaking our rocket movement.

We would love to know…

  • What you found good about this lecture?
  • What we could do better?

Remember that you can reply to this topic, or create a new topic. The easiest way to create a new topic is to follow the link in Resources. That way the topic will…

  • Be in the correct forum (for the course).
  • Be in the right sub-form (for the section)
  • Have the correct lecture tag.

Enjoy the your stay in our thriving community!

Regards

Ben

3 Likes

I just used a serializefield last night to modify one of the scripts in the first person character asset files.

Didn’t even know what it was for until I googled ‘serializefield vs public’.
Still not sure if I will use it instead of public, just that the script used it everywhere, so I went with the flow.

2 Likes

Give it time, at first I just kept using public too but later you wont want to make a lot of your stuff public but still access it in the inspector.

2 Likes

I have a question about serializefield… if I enter a value in the inspector, then later on change the value in code, the value in the inspector overwrites the value in code. Even if I take the [serializefield] off of that variable later,Unity still remembers whatever value I entered in the inspector. Is there any way to get Unity to forget the inspector value and use what I put in the code instead?

SerializeField is a great idea.

Great lecture.
Only 1 small comment I’d make, you suggest in the video that a variable is accessible because it is indented. I get what you mean but perhaps it might be better to explicitly state that the variable is accessible because it is inside the method, and the indentation is just something that coders use to stop wear and tear on our eyeballs.

2 Likes

Hi Ben,
I am enjoying learning Unity with your course, but I have come across one little issue. When I am in playmode and I alter any of the values the rocket justs stops and I have to restart playmode again. Do you have any idea what I am doing wrong?
Regards,
Andre

I always used public up until this point, I didn’t even know what SerializeField was for but I can definitely see how useful it is now.

Privacy & Terms