- Unity 2017 Game Optimization(Second Edition)
- Chris Dickinson
- 271字
- 2021-07-02 23:21:09
Message processing
The final requirement for our Messaging System is that this object should have some kind of timing-based mechanism built in to prevent it from choking on too many messages at once. This means that, somewhere in the codebase, we will need to make use of MonoBehaviour event callbacks to tell our Messaging System to perform work during Unity's Update(), essentially enabling it to count time.
This could be achieved with the Static Class Singleton (which we defined earlier), which would require some other MonoBehaviour-based God Class to call into it, informing it that the Scene has been updated. Alternatively, we can use the Singleton Component to achieve the same thing, which has its own means of determining when Update() is called, and hence handle its workload independently of any God Class. The most notable difference between the two approaches is whether or not the system is dependent on the control of other objects and the various pros and cons of managing a Singleton Component (such that it won’t get destroyed between scenes; we don’t want to accidentally recreate it during shutdown).
The Singleton Component approach is probably the best, since there aren't too many occasions where we wouldn't want this system acting independently, even if much of our game logic depends upon it. For example, even if the game was paused, we wouldn't want the game logic to pause our Messaging System. We still want the Messaging System to continue receiving and processing messages so that we can, for example, keep UI-related Components communicating with one another while the gameplay is in a paused state.
- Unity 2020 By Example
- Cassandra Design Patterns(Second Edition)
- 機器人Python青少年編程開發(fā)實例
- GitLab Repository Management
- TypeScript實戰(zhàn)指南
- Learning Unreal Engine Android Game Development
- Java程序設(shè)計與項目案例教程
- RESTful Web Clients:基于超媒體的可復(fù)用客戶端
- 零基礎(chǔ)學(xué)C++(升級版)
- Mastering Embedded Linux Programming
- Mastering Apache Camel
- H5匠人手冊:霸屏H5實戰(zhàn)解密
- Manage Your SAP Projects with SAP Activate
- Mastering PostgreSQL 11(Second Edition)
- JavaScript前端開發(fā)程序設(shè)計教程(微課版)