123456789101112131415161718192021222324252627282930313233343536373839 |
- using UnityEngine;
- using XGame.Framework.Asset;
- using XGame.Framework.Quality;
- using XGame.Framework.Time;
- namespace XGame.Framework.UI
- {
- public class UIModuleBuilder
- {
- protected IUIModule product;
- public IUIModule Product => product;
- protected IUITree uiTree;
- protected IAssetModule assetModule;
- public void Build(IQualityModule qualityModule, ITimeModule timeModule)
- {
- assetModule = new AssetModule();
- CreateUITree();
- CreateProduct();
- var context = new UIContext(qualityModule, timeModule, product);
- (product as IUIContextSetter).Context = context;
- }
- protected virtual void CreateUITree()
- {
- const string uiTreeName = "UITree";
- var instance = Object.Instantiate(Resources.Load<UITree>(uiTreeName));
- Assert.IsNotNull(instance, "UITree不能为空.");
- instance.gameObject.name = uiTreeName;
- instance.transform.SetParent(AppManager.Root, false);
- uiTree = instance;
- }
- protected virtual void CreateProduct()
- {
- product = new UIModule(assetModule, uiTree);
- }
- }
- }
|