Example #1
0
        public UI Create(int type)
        {
            try
            {
                UI ui = this.UiTypes[type].Create(this.GetOwner <Scene>(), type, this.Root);
                this.uis.Add(type, ui);

                // 假如UI有配置行为树,执行之
                UIConfig uiConfig = ui.GameObject.GetComponent <UIConfig>();
                if (uiConfig != null)
                {
                    BehaviorTree behaviorTree = Game.Scene.GetComponent <BehaviorTreeComponent>().CreateTree(this.GetOwner <Scene>(), uiConfig.CreateBT);
                    BTEnv        env          = new BTEnv
                    {
                        { "UI", ui }
                    };
                    behaviorTree.Run(env);
                }

                return(ui);
            }
            catch (Exception e)
            {
                throw new Exception($"{type} UI 错误: {e}");
            }
        }