private void Update() { if (progressContainer != null) { // Show/hide progress modal float prev = progressContainer.AnimationProgress; UIAnimator.Animate(progressContainer, Time.unscaledDeltaTime * (progressModalVisible ? 1 : -1)); // If just closed, call ModalClosed if ((prev > 0) && (progressContainer.AnimationProgress <= 0)) { progressContainer.gameObject.SetActive(false); ModalClosed(); } } if (progressInfiniteContainer != null) { // Show/hide infinite progress float prev = progressInfiniteContainer.AnimationProgress; UIAnimator.Animate(progressInfiniteContainer, Time.unscaledDeltaTime * (progressInfiniteVisible ? 1 : -1)); // If just closed, call ModalClosed if ((prev > 0) && (progressInfiniteContainer.AnimationProgress <= 0)) { progressInfiniteContainer.gameObject.SetActive(false); ModalClosed(); } } }
private void Update() { // Update tabs lock (idxLock) { for (int i = 0; i < tabPages.Length; i++) { if (i == currentIdx) { tabPages[i].gameObject.SetActive(true); UIAnimator.Animate(tabPages[i], Time.unscaledDeltaTime); } else { if (tabPages[i].AnimationProgress <= 0) { tabPages[i].gameObject.SetActive(false); } else { UIAnimator.Animate(tabPages[i], -Time.unscaledDeltaTime); } } } } // Prev/next if (WindowManager.Instance.HasPrevNextButtons()) { if (Input.GetButtonDown(WindowManager.Instance.PreviousUIButton)) { ShowPrevious(); } if (Input.GetButtonDown(WindowManager.Instance.NextUIButton)) { ShowNext(); } } }
private void Awake() { // Check if toggles have a group ValidateToggleGroup(); // Show an error if pages & toggles are mismatched int count = Mathf.Min(toggles.Length, tabPages.Length); if ((toggles.Length > 0) && (toggles.Length != tabPages.Length)) { Debug.LogWarning("Warning: tab page count and toggle count mismatch"); } // Toggle events for (int i = 0; i < count; i++) { int closure = i; toggles[i].onValueChanged.AddListener((value) => { if (value) { ShowTab(closure); } }); } // Show the first tab, no anim for (int i = 1; i < tabPages.Length; i++) { UIAnimator.Animate(tabPages[i], -1); } UIAnimator.Animate(tabPages[0], 1); if (OnTabSelected != null) { OnTabSelected.Invoke(0); } }
private void Update() { Window top = null; // Update window showing/hiding lock (windowStackLock) { // Always try to show the top window if (windowStack.Count > 0) { top = windowStack[windowStack.Count - 1]; top.gameObject.SetActive(true); UIAnimator.Animate(top, Time.unscaledDeltaTime); } // All other windows should be hidden foreach (var wnd in registeredWindows.Values) { if (wnd != top) { UIAnimator.Animate(wnd, -Time.unscaledDeltaTime); if (wnd.AnimationProgress == 0) { wnd.gameObject.SetActive(false); } } } } // Update background deniers if (top != currentTopWindow) { // Disable old denier if ((currentTopWindow != null) && (currentTopWindow.BackgroundDenier != null)) { currentTopWindow.BackgroundDenier.gameObject.SetActive(false); } // Enable background denier and move it in the hierarchy if ((top != null) && (top.BackgroundDenier != null)) { // Get sibling index -- make sure to count the denier itself if they have the same parent int siblingIndex = top.transform.GetSiblingIndex(); if (top.transform.parent == top.BackgroundDenier.parent) { int denierIdx = top.BackgroundDenier.GetSiblingIndex(); if (denierIdx < siblingIndex) { siblingIndex--; } } else { top.BackgroundDenier.SetParent(top.transform.parent); } top.BackgroundDenier.SetSiblingIndex(siblingIndex); top.BackgroundDenier.gameObject.SetActive(true); } currentTopWindow = top; if ((currentTopWindow != null) && (currentTopWindow.OnActivated != null)) { currentTopWindow.OnActivated.Invoke(); } } // Play changed sound when the current selection changed if ((audioSource != null) && (selectionChangedSound != null)) { var newSelected = EventSystem.current.currentSelectedGameObject; if (selectedUIObject != newSelected) { audioSource.PlayOneShot(selectionChangedSound); selectedUIObject = newSelected; } } // Prev/next buttons if ((CurrentWindow != null) && HasPrevNextButtons()) { if (Input.GetButtonDown(PreviousUIButton) && (CurrentWindow.OnPreviousWindow != null)) { CurrentWindow.OnPreviousWindow.Invoke(); } if (Input.GetButtonDown(NextUIButton) && (CurrentWindow.OnNextWindow != null)) { CurrentWindow.OnNextWindow.Invoke(); } } }