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; }
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(); }