示例#1
0
        private static void Config()
        {
            var baseType = typeof(IModule);
            var cache    = new DefaultModuleCache();
            var factory  = new DefaultModuleFactory(baseType.Assembly, baseType);

            Container = new ModuleContainer(cache, factory);

            IPoolManager        poolManager        = Container.GetModule <IPoolManager>();
            IPlayerInputManager playerInputManager = Container.GetModule <IPlayerInputManager>();
            IUIManager          uIManager          = Container.GetModule <IUIManager>();
            IMonoManager        monoManager        = Container.GetModule <IMonoManager>();

            IEnumerable <IModule> modules = Container.GetAllModules <IModule>();

            foreach (var module in modules)
            {
                //通过父类接口调用到它的实现类的具体方法
                module.InitModule();
            }
        }
        public static void Open()
        {
            var editorPlatform = GetWindow <EditorModulizationPlatformEditor>();

            editorPlatform.position = new Rect(
                Screen.width / 2,
                Screen.height * 2 / 3,
                600,
                500
                );

            // 组装 Container
            // var cache = new EditorPlatformModuleCache();
            // var factory = new EditorPlatformModuleFactory();
            var moduleType = typeof(IEditorPlatformModule);
            var cache      = new DefaultModuleCache();
            var factory    = new AssemblyModuleFactory(moduleType.Assembly, moduleType);

            editorPlatform.mModuleContainer = new ModuleContainer(cache, factory);

            editorPlatform.Show();
        }
示例#3
0
        void Awake()
        {
            var baseType = typeof(IModule);

            var cache   = new DefaultModuleCache();
            var factory = new AssemblyModuleFactory(baseType.Assembly, baseType);

            Container = new ModuleContainer(cache, factory);

            // 主动去创建对象
            var poolManager  = Container.GetModule <IPoolManager>();
            var fsm          = Container.GetModule <IFSM>();
            var resManager   = Container.GetModule <IResManager>();
            var eventManager = Container.GetModule <IEventManager>();
            var uiManager    = Container.GetModule <IUIManager>();

            var modules = Container.GetAllModules <IModule>();

            // 初始化模块
            foreach (var module in modules)
            {
                module.InitModule();
            }
        }