- Home /
Does these codes slow down my game?
Hello
i have 2 questions regarding fps or how fast/slow the code is.
1-Does these codes slow down my game (what if i used them 100times or 1000times per click on a button)
//First Code:
GameObject NewCreatedItem = (GameObject)Instantiate(itemPrefab);
//Second Code:
SomeClass accItsScript = NewCreatedItem.GetComponent<SomeClass>();
2-How can i know if this code is slow or fast?
Answer by tanoshimi · Jul 05, 2015 at 06:40 AM
Every line of code that gets executed gives the CPU instructions to perform. Every CPU can only perform a certain number of instructions per second. So, yes, those lines of code will slow your game down just like any other.
Use the profiler - http://docs.unity3d.com/Manual/Profiler.html
Your answer
Follow this Question
Related Questions
all Rigid body's slow down and speed up 1 Answer
Game runs slow on Android... unless profiler is connected? 0 Answers
how to increase speed of unity/allocate more ram? 1 Answer
What's causing scene to slow down? 1 Answer
My objects are falling to slowly when a rigidbody is attached, cab you help? 9 Answers