This is a theory question of sorts, where I am trying to learn more about different types of programming languages and their structure.
In Unity, the `GameObject.Find()` and `GameObject.GetComponent()` are used to designate objects - what is this kind of system called, and what are some other systems? How do they compare to each other? Is Unity's Find, GetComponent and such more preferable than others? How might Unity be improved to not use Find, GetComponent?
Although I do not know how the underlying code works for those methods, those are basicly known as 'setters' and 'getters', or mutators and accessors. Its part of what is known as Object Oriented Programming (OOP).
As far as performance goes, it is usually better to directly access those properties, rather than accessing it with the likes of getters and setters, but that can cause problems as well.
In my admittedly limited experience, I recently smashed several tutorial projects together and did a lot of code conversion to C#. In doing so I noticed a disturbing amount of code that looks like this:
//In every update cycle....
void Update(){
GameObject foo = GameObject.Find("Foo");
BarComponent bar = foo.GetComponent<Bar>();
GameObject[] gos = GameObject.FindWithTag("AllFoos");
}
My smashup, when tested on my Droid 2 was getting something on the order of 18fps on average after a certain point. When the object graph was relatively small, I didn't have nearly so many problems with performance. So what I decided to do was pre-cache those values in void Start() instead of accessing them every update I immediately shot up to an average of 25fps. It really makes a difference, and the more gameobjects you have in your scene the bigger the difference will be.
Not appropriate for this site.
– JessyIt's a question in need of answers, though an open-ended one. Pity the "community wiki" checkbox isn't enabled on this stack...
– inaWhat happens at exactly 0.7?
– meat5000