Quantcast
Channel: Questions in topic: "vs"
Viewing all articles
Browse latest Browse all 110

Public variables vs {get{return variable;}}

$
0
0
So, for my Unity project I've been setting any variable in a script that needs to be accessed by another script as public. I don't need to edit these in the inspector but because they're public they show up in the inspector anyways. This was fine at the beginning, but as the project grew there were more and more and they started cluttering the inspector. My friend showed me how to add this to make the the variables that are only accessed for their information stay private and not clutter the inspector. public int FunctionVariableReturn {get{return variable;}} But as I started going through my scripts I was wondering if it was really worth it. I have to add this for any variable I need to share, but only if it doesn't need to be changed by the other script. P.S. I was also wondering what the difference would be between something set as *private int var* and just *int var* P.S.S. I was also wondering if there was any place where people show others their code and they help make it better. I doubt my code is very optimized, but I've doing my best to look things up. Thanks.

Viewing all articles
Browse latest Browse all 110

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>