- Home /
Quick question about performance
If I cache a script like this: cacheScript = GetComponent(); Then just directly call a variable from it like this: cacheScript.variable //do smething Is it bad? Am doing it a lot, and because I want the value to update I don´t want to store that value in a new variable since that will only create a copy of it.
nope that's not bad. However, this is bad:
GetComponent().variable
but once you have a direct reference to the code, it's the best way to go with unity
Your answer
Follow this Question
Related Questions
Passing a variable to thread function in Javascript 1 Answer
What is the best way to share data across child classes? 1 Answer
What is better: Set a animator variable each frame or use a if to check if need? 2 Answers
Passing variables back and forth in client server environment using RPC 1 Answer
Are there any major consequences when using Playerprefs? 0 Answers