[Zenject]Installers学习笔记
来源:互联网 发布:在线app打包网站源码 编辑:程序博客网 时间:2024/06/05 21:30
MonoBehaviour
1、需要继承MonoInstaller
2、MonoInstaller是继承于MonoBechaviou
3、通过重写InstallBindings方法添加依赖关系
4、Installer必须添加在Context(通常指SceneContext)
eg:
public class ClassName: MonoInstaller{ public override viod InstallBindings() { \\依赖关系 }}
Non-MonoBehaviour
1、需要继承Installer
2、通过重写InstallBindings方法添加依赖关系
3、无需添加到Scene
eg:
public class ClassName : Installer<ClassName>{ public override viod InstallBindings() { \\依赖关系 }}
Scriptable Object Installer
1、通常用于储存游戏配置信息
2、进行调试模式时,其修改后的属性会被保留
3、通过重写InstallBindings方法添加依赖关系
eg:
public class Settings : ScriptableObjectInstaller{ public Something.Settings Something; public override viod InstallBindings() { Container.BindInstance(Something); }}public class Something{ readonly Settings _settings; public Something(Settings settings) { _settings = settings; } [Serializable] public class Settings { public int number; }
问题集
how would we re-use a MonoInstaller in multiple scenes?
There are three ways to do this.
Prefab instances within the scene. After attaching your MonoInstaller to a gameobject in your scene, you can then create a prefab out of it. This is nice because it allows you to share any configuration that you’ve done in the inspector on the MonoInstaller across scenes (and also have per-scene overrides if you want). After adding it in your scene you can then drag and drop it on to the Installers property of a Context
Prefabs. You can also directly drag your installer prefab from the Project tab into the InstallerPrefabs property of SceneContext. Note that in this case you cannot have per-scene overrides like you can when having the prefab instantiated in your scene, but can be nice to avoid clutter in the scene.
Prefabs within Resources folder. You can also place your installer prefabs underneath a Resoures folder and install them directly from code by using the Resources path. For details on usage see here.
- [Zenject]Installers学习笔记
- Zenject
- Basic Radar Altimetry Toolbox Installers download
- Zenject——轻量级依赖注入框架 for Unity
- Automation for the people: Wielding wizard-based installers
- Deploying a VSTO 3.0 solution for the Office 2007 using Windows Installers
- Ubuntu中使用GitLab Installers一键傻瓜式安装gitlab
- 学习笔记?
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- 学习笔记
- Android样式的开发(三):layer-list篇
- Android布局之LinearLayout
- uploadify 插件
- linux之mini2440内核移植
- Yii 数据库重连告别General error: 2006 MySQL server has gone away
- [Zenject]Installers学习笔记
- SpringMVC和Spring struts
- 如何部署SPDY
- oracle函数trim() ltrim rtrim 使用方法
- Go以及LiteIDE安装
- 如何导入外部Git仓库到中国源代码托管平台(Git@OSC)
- Mysql几种索引方式的区别及适用情况
- Android Studio查找SHA1
- FileReader+canvas实现等比例压缩上传