Ejemplo n.º 1
0
 public PanelViewControllerBase(PanelType type, PanelViewBase view, Action didLoad, Action willAppear, Action didAppear, Action willDisappear, Action didDisappear)
 {
     panelType          = type;
     panelView          = view;
     this.didLoad       = didLoad;
     this.willAppear    = willAppear;
     this.didAppear     = didAppear;
     this.willDisappear = willDisappear;
     this.didDisappear  = didDisappear;
 }
Ejemplo n.º 2
0
        public async Task LoadViewAsync()
        {
            if (IsViewLoaded)
            {
                return;
            }

            var prefab = await panelType.GetPrefabAsync();

            if (prefab == null)
            {
                throw new ArgumentNullException($"PanelType {panelType.name} returned null panel prefab.");
            }

            bool cachedState = prefab.gameObject.activeSelf;

            prefab.gameObject.SetActive(false);
            panelView = Object.Instantiate(prefab, ParentViewContainer?.ParentTransform);
            prefab.gameObject.SetActive(cachedState);
            didLoad?.Invoke();
        }