- Home /
Get object, which is more optimized?
More optimized to findobject(s) by tag, or to script so that the object(s) are set in hierarchy? If you need to find/assign components or varables of other scripts, would your answer change?
they are both pretty optimised, you should be able to use find with tag once every 10 frames without any hitches, it only searches through the objects in hierarchy anyway.
Answer by Paulo-Henrique025 · Jan 30, 2013 at 11:52 AM
I do believe that assigning the object to a public GameObject var is more optimized, as you are setting the var before the game start, but finding objects is not a big deal, unless you keep doing it in the Update().
The best practice is to aways find things in the Start() and them use them trough your code, if you are going to use lots of GetComponents first declare a var of the component type as public and set it in the Start() so you will never worry about getting the component again.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to access .int variable? 1 Answer
Shared variable problem, between scripts, help? 1 Answer
how to use / simulate a using declaration in unityscript 1 Answer
Help converting C# to Unityscript 1 Answer