Is there a difference in performance between an application (on the Unity engine) using one script (one class) or several scripts (several classes)? PS In the case of using several scripts, only one MonoBehaviour (the other classes connected to it)
1 answer
If each script calls Start () or Update (), yes, the load increases. In the Unity blog, there was an article on this topic, they recommend, for optimization, to create one script manager in which to call the Update function and from it to call the internal Updates for each script. However, it is absolutely impossible to write all the logic of the game in one file!
By the way, the article has already been translated into Russian.
создать один скрипт-менеджер в котором вызывать функцию Update и из нее вызывать внутренние Update'ыdepends on the game. If I write tetris, then the performance is unlikely to fall so much that the bricks will hang in the air for a second)) ... and by the way, the article saysЕсли быть честным, этот тест не полностью корректен.bla bla blaВ реальной ситуации управляющий скрипт был бы гораздо сложнее, и его исполнение проходило бы медленнее...... so something more serious is needed for the test - Alexey Shimansky- Did I say a word about hard hangs or something like that? I simply refer to the article as an answer to a specific question. Even if the performance gain in a real test is less, what does it change? Unity's recommendation to use the manager for optimization. If you don’t talk about the tests, you yourself saw that the most part of the tact is occupied by the Update call. - Vasiliy Rusin
|