private IEnumerator InitModules(WindowBase window, System.Action onComplete)
        {
            var resources  = WindowSystem.GetResources();
            var targetData = WindowSystem.GetTargetData();

            for (int i = 0; i < this.modules.Length; ++i)
            {
                var moduleInfo = this.modules[i];
                if (moduleInfo.targets.IsValid(targetData) == false)
                {
                    continue;
                }
                if (moduleInfo.moduleInstance != null)
                {
                    continue;
                }

                var          order    = moduleInfo.order;
                WindowModule instance = null;
                yield return(resources.LoadAsync <WindowModule>(window, moduleInfo.module, (asset) => {
                    instance = WindowSystem.GetPools().Spawn(asset, window.transform);
                    instance.Setup(window);
                    instance.SetCanvasOrder(window.GetCanvasOrder() + order);
                    window.RegisterSubObject(instance);
                }));

                moduleInfo.moduleInstance = instance;
                this.modules[i]           = moduleInfo;
            }

            onComplete.Invoke();
        }
                public void Create(WindowBase window, Transform modulesRoot)
                {
                    this.windowContext = window;

                    if (this.moduleSource.IsInstantiate() == true)
                    {
                        var instance = this.moduleSource.Spawn();
                        instance.transform.SetParent(modulesRoot);
                        instance.transform.localPosition = Vector3.zero;
                        instance.transform.localRotation = Quaternion.identity;
                        instance.transform.localScale    = Vector3.one;

                        var rect = instance.transform as RectTransform;
                        rect.sizeDelta        = (this.moduleSource.transform as RectTransform).sizeDelta;
                        rect.anchoredPosition = (this.moduleSource.transform as RectTransform).anchoredPosition;

                        instance.transform.SetSiblingIndex(this.backgroundLayer == true ? -this.sortingOrder : this.sortingOrder + 1);

                        instance.Setup(window);

                        this.instance = instance;
                    }
                    else
                    {
                        this.instance = this.moduleSource;
                    }
                }
Example #3
0
            public ModuleInfo AddModuleInfo(WindowModule moduleSource, int sortingOrder, bool backgroundLayer)
            {
                var instance = new ModuleInfo(moduleSource, sortingOrder, backgroundLayer);

                var list = this.elements.ToList();

                list.Add(instance);
                this.elements = list.ToArray();

                return(instance);
            }
Example #4
0
 public ModuleInfo(WindowModule moduleSource, int sortingOrder, bool backgroundLayer)
 {
     this.moduleSource    = moduleSource;
     this.sortingOrder    = sortingOrder;
     this.backgroundLayer = backgroundLayer;
 }
Example #5
0
 public virtual void Apply(WindowModule instance)
 {
     instance.SetCanvasOrder(instance.GetWindow().GetCanvasOrder() + this.defaultOrder);
 }