
本课程专门介绍 Zenject – 一个专为 Unity 设计的免费开源依赖注入框架。
本课程针对 Zenject 版本 6.1.1 进行了更新。Zenject 由它的创建者不断更新,我会尝试在添加或修改功能后立即更新课程内容。
在我们深入研究依赖注入之前,我将展示您可以在不深入了解其机制的情况下使用 Zenject – 它非常简单!
接下来,我将在依赖注入基础部分继续详细解释依赖注入模式。什么、为什么和如何——这些问题将在本节中得到解答。
注入 MonoBehaviour 类部分解释了如何使用 Zenject 组件正确设置 Unity 场景,并展示了一些基本的绑定示例。
绑定部分深入介绍了使 Zenject 如此灵活和强大的功能,允许其用户创建任何复杂的注入。
将非 MonoBehaviour 类添加到 Unity 生命周期部分解释了如何将非 MonoBehaviour 类集成到 Unity Game Loop 中,使它们能够在此类类中使用 Start、Update 和 OnDestroy 类方法。
在 Container 部分,我将展示一些可能变得有用的附加 DiContainer 方法。我们还将介绍 Zenject 的操作顺序,这将帮助您避免(或至少轻松调试)Zenject 异常。
重构:删除其他模式部分比较了依赖注入、单例和服务定位器模式,并演示了一种轻松重构它们的方法。
在 Factory 部分,您将学习如何在 Factory 类的帮助下动态创建和注入 MonoBehaviour 对象
接下来,我将向您展示如何使用内存池管理和重用创建的对象,这对于移动设备游戏特别有用。
Zenject 还允许对绑定对象进行分组,将 Facade 模式与 Subcontainer 功能相结合。将在子容器部分详细介绍此主题。
在处理多个场景部分中,您将学习如何将依赖关系从一个场景传递到另一个场景,并结合使用依赖注入和 Unity 多场景编辑功能。
本课程还涵盖了信号,这是观察者模式的一种实现。在构建事件系统部分,我将向您展示一个定制事件系统的示例,然后将其与 Zenject 提供的功能进行比较。
最后,在单元和集成测试部分,我将向您展示 Zenject 如何通过其帮助类和 MOQ 库支持来简化单元和集成测试的创建。
Learn Zenject – a powerful, free, open-source, constantly updating dependency injection framework designed for Unity3d
Last Updated 02/2021
MP4 | Video: h264, 1280×720 | Audio: AAC, 44.1 KHz, 2 Ch
Genre: eLearning | Language: English + srt | Duration: 92 lectures (2h 9m) | Size: 1.26 GB
What you’ll learn
Refactor existing and build new Unity projects using the Zenject Framework
Create loosly coupled connections using Zenject Signals
Increate mobile game performance by using the Memory Pool classes provided by Zenject
Create unit tests with Zenject and MOQ
Requirements
Students should be familiar with Unity basics
Intermediate C# programming experience is required
Design Patterns knowledge is a plus, but not mandatory
Description
This course is dedicated to Zenject – a free open-source dependency injection framework designed for Unity.
This course is updated for Zenject Version 6.1.1. Zenject is constantly updated by it’s creator, and I’ll try to update the course content as soon as functionality is added or modified.
Before we dig into the dependency injection, I’ll show that you can use Zenject without deep understanding of its mechanics – it is so easy!
Next, I’ll continue with the detailed explanation of the dependency injection pattern in the Dependency Injections basics section. What, Why and How – those questions will be answered in this section.
Injecting MonoBehaviour classes section explains how to properly setup Unity scene using Zenject components, and shows some basic bindings examples.
The Bindings section deeply covers the functionality that makes Zenject so flexible and powerful, allowing its users to create injections of any complexity.
Adding non-MonoBehaviour classes to the Unity lifecycle section explains how integrate non-MonoBehaviour classes into Unity Game Loop, giving them the ability to use Start, Update and OnDestroy-like methods in such classes.
In the Container section, I’ll show some additional DiContainer methods that might become useful. We’ll also cover Zenject order of operations, which will help you to avoid (or at least easily debug) Zenject exceptions.
Refactoring: Removing other patterns section compares Dependency Injection, Singleton and Service Locator patterns, and demonstrates a painless way to refactor them.
In the Factory section, you will learn how to create and inject MonoBehaviour objects dynamically with a little help from the Factory class
Next, I’ll show you how the manage and reuse created objects using Memory Pools, which can be especially useful for a mobile device game.
Zenject also allows grouping bound objects, combining the Facade pattern with the Subcontainer functionality. Will cover this topics in details in the Subcontainer section.
In the Dealing with multiple scenes section you will learn how to pass dependencies from one scene to another and use dependency injection in conjunction with Unity multi-scene editing feature.
This course also covers Signals, an implementation of the Observer pattern. In the Building an Event System section, I’ll show you an example of a custom made event system and then compare it to the functionality provided by Zenject.
Finally, in the Unit and Integration Testing section, I’ll show you how Zenject simplifies unit and integration test creation with its helper classes and MOQ library support.
Who this course is for
Unity developers that want to refactor their existing projects or create new projects using Dependency Injection
Unity enthusiasts who want to learn the Dependency Injection pattern to use it in the game development.
原创文章,作者:steven,如若转载,请注明出处:https://rr3d.cn/33483.html