- Home /
Does enabling/disabling Scripts have a high performance cost?
Was just wondering if the approach of enabling/disabling scripts on a prefab gameobject would have a high overhead in unity? I was going use this approach to having damage to the ship. IE: If say the sensor pod of the ship was damaged, the sensor script would be disabled. Is there a better approach to such things if the enable/disable scripts is too costly in terms of game overhead/performance?
Answer by getyour411 · Feb 05, 2014 at 08:05 AM
Your approach sounds fine. The 'costly' stuff won't be a factor for a small number of GameObjects.
Thanks for the reply getyour411! Actually, we also planned to make the game into a multiplayer internet connected game. The ships would be the main prefabs having script enabled/disable but there are a lot of enemy ships too. If there are a lot of game objects, does the enable/disable scripts route get expensive and require too much overhead? If so, is there a better way than script enable/disable to code the on/offing of features such as combat system damage, movement control, automatic orbiting, sensory, auto fuel filling, etc..??
$$anonymous$$ore info here too http://wiki.unity3d.com/index.php?title=General_Performance_Tips
Your answer
Follow this Question
Related Questions
Number of objects in scene and performance 2 Answers
How would I change the value of one prefab's variable via script without changing all of them? 1 Answer
Objects flickering between dark and light 7 Answers
Get the name of an instance's prefab at runtime? 0 Answers
performance between disable renderer and disable gameObject 2 Answers