コード例 #1
0
ファイル: UIModular.cs プロジェクト: firefishes/ShipDock
        public override void Init()
        {
            base.Init();

            ShipDockApp app = ShipDockApp.Instance;

            Datas = app.Datas;
            ABs   = app.ABs;
            UIs   = app.UIs;

            if (mUI == default)
            {
                GameObject prefab = ABs.Get(ABName, UIAssetName);
                GameObject ui     = UnityEngine.Object.Instantiate(prefab, UIs.UIRoot.MainCanvas.transform);

                ParamNotice <MonoBehaviour> notice = Pooling <ParamNotice <MonoBehaviour> > .From();

                int id = ui.GetInstanceID();
                id.Broadcast(notice);

                mUI = (T)notice.ParamValue;
                notice.ToPool();
            }
            else
            {
            }

            UILayer layer = mUI.GetComponent <UILayer>();

            SetUIParent(ref layer);
            mUI.Add(UIModularHandler);
        }
コード例 #2
0
ファイル: UIModular.cs プロジェクト: firefishes/ShipDock
        private void SetUIParent(ref UILayer layer)
        {
            if (layer != default)
            {
                UILayer = layer.UILayerValue;
            }
            else
            {
            }

            Transform parent = default;
            IUIRoot   root   = UIs.UIRoot;

            switch (UILayer)
            {
            case UILayerType.WINDOW:
                parent = root.Windows;
                break;

            case UILayerType.POPUPS:
                parent = root.Popups;
                break;

            case UILayerType.WIDGET:
                parent = root.Widgets;
                break;

            default:
                parent = root.MainCanvas.transform;
                break;
            }

            mUI.transform.SetParent(parent);

            if (UILayer == UILayerType.POPUPS)
            {
                mUI.transform.SetAsLastSibling();
            }
            else
            {
            }
        }