Hello in this course
- I find I can use SerializeField without assign Unity UI, unlike previous course what is different?
- usually i use public void when i make a method, in this time we no need to do that? what is different too?
Hello in this course
Hi,
Thank you for your questions.
public
? If so, Unity exposes the variable in the Inspector.public
access modifier only if another object needs to call our method. If we need our method only within the same object, we prefer the private
access modifier. That makes our code more secure because other objects will not be able to access everything in our object.Did this clear it up for you?
See also:
Here are some docs related to your questions, this is a little technical.
i still not get it, can you share some example so i can understand more?
or maybe some case study?
Ben and Rick adress this topic in their hangout video in the Block Breaker section as of the 9:23 mark. The video is named “Block Breaker Instructor Hangout #2” (currently #84 on Udemy).
- yes it is public, what if i didn’t use public? it won’t show in inspector?
Without the [SerializeField] attribute, the variable would not appear in the Inspector.
- if we use private, if i accidentally use the same namespace for the method my code still has no problem. if i use public i might find some issue?
Could you please share an code example? I’m not sure if I understood your idea correctly.
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.