Exemplo n.º 1
0
    private void Awake()
    {
        //组件加载
        this.gameObject.AddComponent <IEnumeratorTool>();
        this.gameObject.AddComponent <BResources>();

        var types = Assembly.GetExecutingAssembly().GetTypes();

        //
        mgrList = new List <IMgr>();
        //寻找所有的管理器
        foreach (var t in types)
        {
            if (t.BaseType != null && t.BaseType.GetInterface("IMgr") != null)
            {
                BDeBug.I.Log("加载管理器-" + t, "green");
                var i = t.BaseType.GetProperty("I").GetValue(null, null) as  IMgr;
                mgrList.Add(i);
            }
            //游戏启动器
            else if (this.gameStart == null && t.GetInterface("IGameStart") != null)
            {
                gameStart = Activator.CreateInstance(t) as IGameStart;
            }
        }

        //类型注册
        foreach (var t in types)
        {
            foreach (var iMgr in mgrList)
            {
                iMgr.CheckType(t);
            }
        }

        //管理器唤醒
        foreach (var _imgr in mgrList)
        {
            _imgr.Awake();
        }

        if (gameStart != null)
        {
            gameStart.Awake();
        }
    }
Exemplo n.º 2
0
    private void Awake()
    {
        Debug.Log("start bdframe");

        //组件加载
        this.gameObject.AddComponent <IEnumeratorTool>();
        this.gameObject.AddComponent <BResources>();
        Type[]      frameTypes = Assembly.GetExecutingAssembly().GetTypes();;
        Type[]      logicTypes = null;
        List <Type> allTypes   = new List <Type>();

        //编辑器环境下 寻找dll
        if (Application.isEditor)
        {
            Debug.Log("Edidor Get Types...");
            var assmblies    = new List <Assembly>(AppDomain.CurrentDomain.GetAssemblies());
            var logicAssmbly = assmblies.Find((a) => a.GetName().Name == "Assembly-CSharp");
            logicTypes = logicAssmbly.GetTypes();
        }

        allTypes.AddRange(frameTypes);
        allTypes.AddRange(logicTypes);
        //其他环境用热更模型进行加载

        //
        mgrList = new List <IMgr>();
        //寻找所有的管理器
        foreach (var t in allTypes)
        {
            if (t.BaseType != null && t.BaseType.GetInterface("IMgr") != null)
            {
                BDebug.Log("加载管理器-" + t, "green");
                var i = t.BaseType.GetProperty("Inst").GetValue(null, null) as  IMgr;
                mgrList.Add(i);
            }
            //游戏启动器
            else if (this.gameStart == null && t.GetInterface("IGameStart") != null)
            {
                gameStart = Activator.CreateInstance(t) as IGameStart;
            }
        }

        //类型注册
        foreach (var t in allTypes)
        {
            foreach (var iMgr in mgrList)
            {
                iMgr.CheckType(t);
            }
        }

        //管理器唤醒
        foreach (var _imgr in mgrList)
        {
            _imgr.Awake();
        }

        if (gameStart != null)
        {
            gameStart.Awake();
        }
    }