/// <summary> /// Executes the UIElement Show command in realtime. /// </summary> IEnumerator iShow(bool instantAction) { yield return(null); if (loopAnimationsArePlaying) { UIAnimator.StopLoops(RectTransform, LOOP_ANIMATIONS_ID); } ToggleCanvasAndGraphicRaycaster(true); ResetBeforeShow(!inAnimations.move.enabled, !inAnimations.fade.enabled); UIAnimator.Move(RectTransform, useCustomStartAnchoredPosition ? customStartAnchoredPosition : startPosition, inAnimations, StartMoveIn, FinishMoveIn, instantAction, false); UIAnimator.Rotate(RectTransform, startRotation, inAnimations, StartRotateIn, FinishRotateIn, instantAction, false); UIAnimator.Scale(RectTransform, startScale, inAnimations, StartScaleIn, FinishScaleIn, instantAction, false); UIAnimator.Fade(RectTransform, startAlpha, inAnimations, StartFadeIn, FinishFadeIn, instantAction, false); StartCoroutine(iSetSelectedGameObject()); if (inAnimations.TotalDuration >= 0 && !instantAction) { yield return(new WaitForSecondsRealtime(inAnimations.TotalDuration)); } if (childButtons != null && childButtons.Length > 0) { for (int i = 0; i < childButtons.Length; i++) { childButtons[i].ResetAnimations(); } } ResetRectTransform(); PlayLoopAnimations(); cShow = null; }
/// <summary> /// Hides the element. /// </summary> /// <param name="instantAction">If set to <c>true</c> it will execute the animations in 0 seconds and with 0 delay</param> public void Hide(bool instantAction, bool shouldDisable) { if (cShow != null) { isVisible = true; StopCoroutine(cShow); cShow = null; } if (!OutAnimationsEnabled) { Debug.LogWarning("[DoozyUI] [" + name + "] You are trying to HIDE the " + elementName + " UIElement, but you didn't enable any OUT animations. To fix this warning you should enable at least one OUT animation."); return; } if (isVisible) { if (!instantAction) { TriggerOutAnimationsEvents(); } //we do this check so that the events are not triggered onEnable when we have startHidden set as true UIAnimator.StopAnimations(RectTransform, Anim.AnimationType.In); cHide = StartCoroutine(iHide(instantAction, shouldDisable)); isVisible = false; if (!instantAction) { DisableButtonClicks(outAnimations.TotalDuration); } } }
/// <summary> /// Initializes this instance. /// </summary> public void Initialize() { // Initialize text m_scoreText.Initialize(); m_topScoreText.Initialize(); // Initialize score text positions m_scoreContainer.UpdateScreenPosition(); // Initialize animators // Score // State 1: Normal size (during normal play) // State 2: Larger size (when reaching multiples of 50 score or when in results) m_scoreAnimator = new UIAnimator(m_scoreText.transform); m_scoreAnimator.SetScaleAnimation(Vector3.one * m_scoreTextSize1, Vector3.one * m_scoreTextSize2); m_scoreAnimator.SetAnimSpeed(m_scoreTextAnimSpeed); m_scoreAnimator.ResetToState(UIAnimator.UIAnimationState.STATE1); // Top score // State 1: Hidden at the left edge of the screen (during normal play) // State 2: Below score text (when in results) m_topScoreAnimator = new UIAnimator(m_topScoreText.transform); Vector3 state2Pos = m_topScoreText.transform.localPosition; Vector3 state1Pos = new Vector3(m_topScoreHiddenPos, state2Pos.y, state2Pos.z); m_topScoreAnimator.SetPositionAnimation(state1Pos, state2Pos); m_topScoreAnimator.SetAnimateLocal(true); m_topScoreAnimator.SetAnimSpeed(m_topScoreTextAnimSpeed); m_topScoreAnimator.ResetToState(UIAnimator.UIAnimationState.STATE1); // Set the initialized flag m_isInitialized = true; }
/// <summary> /// Shows the element. /// </summary> /// <param name="instantAction">If set to <c>true</c> it will execute the animations in 0 seconds and with 0 delay</param> public void Show(bool instantAction) { if (cHide != null) { isVisible = false; StopCoroutine(cHide); cHide = null; } if (!InAnimationsEnabled) { Debug.LogWarning("[DoozyUI] [" + name + "] You are trying to SHOW the " + elementName + " UIElement, but you didn't enable any IN animations. To fix this warning you should enable at least one IN animation."); return; } if (isVisible == false) { TriggerInAnimationsEvents(); UIAnimator.StopAnimations(RectTransform, Anim.AnimationType.Out); cShow = StartCoroutine(iShow(instantAction)); isVisible = true; if (instantAction == false) { DisableButtonClicks(inAnimations.TotalDuration); } if (disableWhenHidden && containsChildUIElements) { StartCoroutine(TriggerShowInTheNextFrame(instantAction)); } ExecuteLayoutFix(); } }
/// <summary> /// Start this instance. /// </summary> private void Start() { m_creditsAnimator = new UIAnimator(this.transform); m_creditsAnimator.SetPositionAnimation(m_creditsAnimStartPos.position, m_creditsAnimEndPos.position); m_creditsAnimator.SetAnimSpeed(0.1f); m_creditsAnimator.AnimateToState2(); }
void OnEnable() { canvasWidth = canvas.GetComponent <RectTransform> ().sizeDelta.x; container1 = TemplateContainer.Init(this, 0); container2 = TemplateContainer.Init(this, 1); anim = UIAnimator.AttachTo(gameObject); }
/// <summary> /// Initializes this instance. /// </summary> public void Initialize(System.EventHandler <System.EventArgs> screenshotScreenTouchDelegate) { // Initialize screenshot screen (giant button) m_screenshotScreen.Initialize(screenshotScreenTouchDelegate, UIButton.TriggerType.ON_PRESS); // Create animator instances m_scaleUpAnimator = new UIAnimator(m_screenshotImageRoot.transform); m_slideAnimator = new UIAnimator(m_screenshotImageRoot.transform); m_scaleDownAnimator = new UIAnimator(m_screenshotImageRoot.transform); m_stillShotAnimator = new UIAnimator(m_screenshotImageRoot.transform); // Initialize scale animators // State 1: Zero scale (at the start when screenshot is just taken, // and at the end when screenshot is hidden in the share button) // State 2: Normal scale m_scaleUpAnimator.SetScaleAnimation(Vector3.zero, Vector3.one * m_animatedScreenshotScale); m_scaleUpAnimator.SetAnimTime(m_scaleAnimTime); // [States are the reverse of scale up animator's] m_scaleDownAnimator.SetScaleAnimation(Vector3.one * m_animatedScreenshotScale, Vector3.zero); m_scaleDownAnimator.SetAnimTime(m_scaleAnimTime); // Initialize position and rotation animator m_slideAnimator.SetAnimTime(m_slideAnimTime); // Start and end values are set when the animation is started // Set the initialized flag m_isInitialized = true; }
IEnumerator FadeOutRoutine(FadeCallBack fadeCallBack) { isFading = true; yield return(UIAnimator.Color(coverObj, Vector4.zero, Color.black, fadeSpeed * 2)); fadeCallBack(); }
/// <summary> /// Initializes this instance. /// </summary> public void Initialize(CoinWinAnimator coinWinUI, float initialSpeed, float initialRotSpeed, Vector3 moveDir, float deceleration) { m_coinWinUI = coinWinUI; m_speed = initialSpeed; m_rotSpeed = initialRotSpeed; m_moveDir = moveDir; m_deceleration = deceleration; // Initialize coin animator // State 1: Zero scale // State 2: Normal scale m_coinScaleAnimator = new UIAnimator(m_coinSprite.transform); m_coinScaleAnimator.SetScaleAnimation(Vector3.zero, m_coinSprite.transform.localScale); m_coinScaleAnimator.SetAnimSpeed(m_coinScaleAnimSpeed); // Initialize collect animator // State 1: Original scale // State 2: Zero scale m_collectAnimator = new UIAnimator(m_collectSprite.transform); m_collectAnimator.SetScaleAnimation(m_collectSprite.transform.localScale, Vector3.zero); m_collectAnimator.SetAnimSpeed(m_collectAnimSpeed); Reset(); // Start coin scale animation m_coinScaleAnimator.AnimateToState2(); // Set the initialized flag m_isInitialized = true; }
/// <summary> /// Shows the element. /// </summary> /// <param name="instantAction">If set to <c>true</c> it will execute the animations in 0 seconds and with 0 delay</param> public void Show(bool instantAction) { if (outAnimationsCoroutine != null) { isVisible = false; StopCoroutine(outAnimationsCoroutine); outAnimationsCoroutine = null; } if (AreInAnimationsEnabled) { if (isVisible == false) { inAnimationsFinishTime = GetInAnimationsFinishTime(); TriggerInAnimationsEvents(); UIAnimator.StopOutAnimations(GetRectTransform, GetInitialData); inAnimationsCoroutine = StartCoroutine(InAnimationsEnumerator(instantAction)); isVisible = true; if (instantAction == false) { DisableButtonClicks(inAnimationsFinishTime); } if (disableWhenHidden && containsChildUIElements) { StartCoroutine(TriggerShowInTheNextFrame(instantAction)); } ExecuteFixForLayouts(); } } else if (AreInAnimationsEnabled == false) { Debug.LogWarning("[DoozyUI] [" + name + "] You are trying to SHOW the " + elementName + " UIElement, but you didn't enable any IN animations. To fix this warning you should enable at least one IN animation."); } }
void Awake() { gearScript = transform.GetComponent <GearPlacer>(); dimensionManager = transform.GetComponent <DimensionManager>(); uIAnimator = GCodeSettings.AddComponent <UIAnimator>(); colonyJob = gameObject.AddComponent <AntColonyProgram>(); }
public override void OnDisable() { base.OnDisable(); UIAnimator.StopAnimations(RectTransform, AnimationType.Punch); UIAnimator.StopAnimations(RectTransform, AnimationType.State); StopSelectedLoopAnimation(); StopNormalLoopAnimation(); ResetToStartValues(); OnPointerEnter.Ready = true; OnPointerExit.Ready = true; OnPointerUp.Ready = true; OnPointerDown.Ready = true; OnClick.Ready = true; OnDoubleClick.Ready = true; OnLongClick.Ready = true; OnSelected.Ready = true; OnDeselected.Ready = true; if (m_disableButtonCoroutine == null) { return; } StopCoroutine(m_disableButtonCoroutine); m_disableButtonCoroutine = null; EnableButton(); }
/// <summary> /// Loads the Loop Animations Preset that is set to load at runtime and performs the inital setup of the loop animations. /// </summary> /// <param name="forced"></param> void InitLoopAnimations(bool forced = false) { if (loopAnimationsArePlaying) { return; } if (loadLoopAnimationsPresetAtRuntime) { Loop presetLoop = UIAnimatorUtil.GetLoop(loopAnimationsPresetCategoryName, loopAnimationsPresetName); if (presetLoop != null) { bool autoStart = loopAnimations.autoStart; //save the autoStart setting from the inspector (the value set by the developer) loopAnimations = presetLoop.Copy(); //load the preset settings loopAnimations.autoStart = autoStart; //override the autoStart setting (that the preset came with) so that autoStart is set to the value the developer set it to } } if (loopAnimations == null || !loopAnimations.Enabled) { return; } ResetRectTransform(); UIAnimator.SetupLoops(RectTransform, startPosition, startRotation, startScale, startAlpha, loopAnimations, null, null, null, null, null, null, null, null, LOOP_ANIMATIONS_ID, true, forced); if (loopAnimations.autoStart) { PlayLoopAnimations(); } }
/// <summary> /// Loads the Loop Animations Preset that is set to load at runtime and performs the inital setup of the loop animations. /// </summary> /// <param name="forced"></param> void InitLoopAnimations(bool forced = false) { if (loopAnimationsArePlaying) { return; } if (loadLoopAnimationsPresetAtRuntime) { Loop presetLoop = UIAnimatorUtil.GetLoop(loopAnimationsPresetCategoryName, loopAnimationsPresetName); if (presetLoop != null) { loopAnimations = presetLoop.Copy(); } } if (loopAnimations == null || !loopAnimations.Enabled) { return; } ResetRectTransform(); UIAnimator.SetupLoops(RectTransform, startPosition, startRotation, startScale, startAlpha, loopAnimations, null, null, null, null, null, null, null, null, LOOP_ANIMATIONS_ID, true, forced); if (loopAnimations.autoStart) { loopAnimationsArePlaying = true; } }
public IEnumerator MoveRoutine(Vector3 _movePos) { Debug.Log("이동 시작"); yield return(StartCoroutine(UIAnimator.Move( gameObject, transform.position, _movePos, 2.0f))); // 뒷타일들 벽상태로 만든다 // ... // 타일 인덱스의 이벤트 실행 Debug.Log("타일 도착"); DungeonTile.EventState eventState = dcm.GetSpawner().GetTileState(nowIndex); Debug.Log("이벤트 감지"); switch (eventState) { case DungeonTile.EventState.BATTLE: Debug.Log("전투 이벤트"); break; case DungeonTile.EventState.GATHERING: Debug.Log("채집 이벤트"); break; case DungeonTile.EventState.TRAP: Debug.Log("함정 이벤트"); break; } yield break; }
public void OnManaChange() { manaText.text = GameManager.Instance.Mana.ToString("00000"); foreach (var UIAnimator in UIAnimators) { UIAnimator.OnManaChanged(); } }
/// <summary> /// Initialize this instance. /// </summary> public void Initialize() { m_playAgainButton.Initialize(PlayAgainHandler, UIButton.TriggerType.ON_RELEASE); m_mainMenuButton.Initialize(MainMenuHandler, UIButton.TriggerType.ON_RELEASE); m_pledgeButton.Initialize(PledgeHandler, UIButton.TriggerType.ON_RELEASE); m_promiseButton.Initialize(PromiseHandler, UIButton.TriggerType.ON_RELEASE); m_cancelButton.Initialize(CancelHandler, UIButton.TriggerType.ON_RELEASE); // TODO: Delegates should not be in Main // Button sound delegates m_playAgainButton.AddSoundDelegates(Main.Instance.UIButtonPressHandler, Main.Instance.UIButtonReleaseHandler); m_mainMenuButton.AddSoundDelegates(Main.Instance.UIButtonPressHandler, Main.Instance.UIButtonReleaseHandler); m_pledgeButton.AddSoundDelegates(Main.Instance.UIButtonPressHandler, Main.Instance.UIButtonReleaseHandler); m_promiseButton.AddSoundDelegates(Main.Instance.UIButtonPressHandler, Main.Instance.UIButtonReleaseHandler); m_cancelButton.AddSoundDelegates(Main.Instance.UIButtonPressHandler, Main.Instance.UIButtonReleaseHandler); // Safety Pledge UI Animator // State 1 - hidden in pledge button position // State 2 - normal display m_pledgeUIAnimator = new UIAnimator(m_pledgeRoot.transform); m_pledgeUIAnimator.SetPositionAnimation(m_pledgeButton.transform.position, m_pledgeRoot.transform.position); m_pledgeUIAnimator.SetScaleAnimation(Vector3.zero, m_pledgeRoot.transform.localScale); // Overlay UI Animator // State 1 - transparent (invisible) // State 2 - black overlay over the results UI m_pledgeOverlayAnimator = new UIAnimator(m_pledgeOverlay); m_pledgeOverlayAnimator.SetAlphaAnimation(0.0f, m_pledgeOverlay.color.a); // Pledge Thanks Animator // State 1 - hidden in pledge button position // State 2 - normal display m_pledgeThanksAnimator = new UIAnimator(m_pledgeThanks.transform); m_pledgeThanksAnimator.SetPositionAnimation(m_pledgeButton.transform.position, m_pledgeThanks.transform.position); m_pledgeThanksAnimator.SetScaleAnimation(Vector3.zero, m_pledgeThanks.transform.localScale); // Set animation speed m_pledgeUIAnimator.SetAnimSpeed(m_pledgePopupSpeed); m_pledgeOverlayAnimator.SetAnimSpeed(m_pledgePopupSpeed); // Start safety pledge UI disabled and "minimized" at the position of the pledge button m_pledgeRoot.SetActive(false); m_pledgeRoot.transform.position = m_pledgeButton.transform.position; m_pledgeRoot.transform.localScale = Vector3.zero; // Start pledge overlay at 0 alpha (transparent) m_pledgeOverlay.SetAlpha(0.0f); // Start safety pledge UI disabled and "minimized" at the position of the pledge button m_pledgeThanks.SetActive(false); m_pledgeThanks.transform.position = m_pledgeButton.transform.position; m_pledgeThanks.transform.localScale = Vector3.zero; // If player has already pledged, lock pledge button in "pressed" state if (Locator.GetGameManager() != null && Locator.GetGameManager().HasPledged) { LockPledgeButton(); } // Set the initialized flag m_isInitialized = true; }
IEnumerator LoopAnimationsEnumerator() { yield return(null); UIAnimator.DoMoveLoop(moveLoop, GetRectTransform, GetInitialData); UIAnimator.DoRotationLoop(rotationLoop, GetRectTransform, GetInitialData); UIAnimator.DoScaleLoop(scaleLoop, GetRectTransform, GetInitialData); UIAnimator.DoFadeLoop(fadeLoop, GetRectTransform, GetInitialData); }
void OnEnable () { canvasWidth = canvas.GetComponent<RectTransform> ().sizeDelta.x; container1 = TemplateContainer.Init (this, 0); container2 = TemplateContainer.Init (this, 1); anim = UIAnimator.AttachTo (gameObject); }
public void Animate (UIAnimator.UIAnimation animation, RectTransform rect=null) { Anim.Animate (animation, rect); }