void OnGUI() { DGUtils.BeginGUI(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Play All")) { Debug.Log("Played tweens: " + DOTween.PlayAll()); } if (GUILayout.Button("Pause All")) { Debug.Log("Paused tweens: " + DOTween.PauseAll()); } if (GUILayout.Button("Kill All")) { Debug.Log("Killed tweens: " + DOTween.KillAll()); } if (GUILayout.Button("Complete+Kill All")) { Debug.Log("Killed tweens: " + DOTween.KillAll(true)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Rewind All")) { Debug.Log("Rewinded tweens: " + DOTween.RewindAll()); } if (GUILayout.Button("Restart All")) { Debug.Log("Restarted tweens: " + DOTween.RestartAll()); } if (GUILayout.Button("Complete All")) { Debug.Log("Completed tweens: " + DOTween.CompleteAll()); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("PlayForward All")) { Debug.Log("PlayForwarded tweens: " + DOTween.PlayForwardAll()); } if (GUILayout.Button("PlayBackwards All")) { Debug.Log("PlayBackwarded tweens: " + DOTween.PlayBackwardsAll()); } if (GUILayout.Button("Flip All")) { Debug.Log("Flipped tweens: " + DOTween.FlipAll()); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Goto 1.5 All")) { Debug.Log("Goto-ed tweens: " + DOTween.GotoAll(1.5f)); } if (GUILayout.Button("Goto 3 All")) { Debug.Log("Goto-ed tweens: " + DOTween.GotoAll(3)); } if (GUILayout.Button("Goto 4.5 All")) { Debug.Log("Goto-ed tweens: " + DOTween.GotoAll(4.5f)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Play by Id")) { Debug.Log("Played tweens: " + DOTween.Play(intId)); } if (GUILayout.Button("Play by StringId")) { Debug.Log("Played tweens: " + DOTween.Play(stringId)); } if (GUILayout.Button("Play by UnityObjectId")) { Debug.Log("Played tweens: " + DOTween.Play(this)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Pause by Id")) { Debug.Log("Paused tweens: " + DOTween.Pause(intId)); } if (GUILayout.Button("Pause by StringId")) { Debug.Log("Paused tweens: " + DOTween.Pause(stringId)); } if (GUILayout.Button("Pause by UnityObjectId")) { Debug.Log("PlaPausedyed tweens: " + DOTween.Pause(this)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Kill by Id")) { Debug.Log("Killed tweens: " + DOTween.Kill(intId)); } if (GUILayout.Button("Complete+Kill by Id")) { Debug.Log("Killed tweens: " + DOTween.Kill(intId, true)); } if (GUILayout.Button("Kill by StringId")) { Debug.Log("Killed tweens: " + DOTween.Kill(stringId)); } if (GUILayout.Button("Kill by UnityObjectId")) { Debug.Log("Killed tweens: " + DOTween.Kill(this)); } if (GUILayout.Button("Clear")) { Debug.Log(":::::::::::: CLEAR"); DOTween.Clear(); } if (GUILayout.Button("Clear & Reload")) { Debug.Log(":::::::::::: CLEAR AND RELOAD"); int level = Application.loadedLevel; DOTween.Clear(); Application.LoadLevel(level); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); foreach (Tween t in tweens) { if (GUILayout.Button("Direct Kill")) { t.Kill(); } } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.Label("Global DOTween Timescale"); GUILayout.BeginHorizontal(); DOTween.timeScale = GUILayout.HorizontalSlider(DOTween.timeScale, 0.0f, 20.0f); if (GUILayout.Button("Reset", GUILayout.Width(80))) { DOTween.timeScale = 1; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); for (int i = 0; i < tweens.Length; ++i) { GUILayout.Label("Single Timescale"); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); foreach (Tween t in tweens) { t.timeScale = GUILayout.HorizontalSlider(t.timeScale, 0.0f, 20.0f, GUILayout.Width(60)); if (GUILayout.Button("Reset", GUILayout.Width(80))) { t.timeScale = 1; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); foreach (Tween t in tweens) { GUILayout.Label("Elapsed: " + t.Elapsed(false) + "\nFullElapsed: " + t.Elapsed() + "\nElapsed %: " + t.ElapsedPercentage(false) + "\nFullElapsed %: " + t.ElapsedPercentage() + "\nCompleted Loops: " + t.CompletedLoops() ); } GUILayout.EndHorizontal(); DGUtils.EndGUI(); }
public static int DOPause(this Material target) { return(DOTween.Pause(target)); }
public static int DOPause(this Component target) { return(DOTween.Pause(target)); }
public int Pause(object targetOrId) { return(DOTween.Pause(targetOrId)); }
public void Pause() { DOTween.Pause(target.gameObject); }
void Update() { if (isHoldingJump) { if (Input.GetButton("Jump")) { if (!DOTween.IsTweening(555)) { DOTween.To(() => jumpGravityTween, x => jumpGravityTween = x, jumpGravityMultiplier, 0.9f).SetId(555).SetEase(Ease.OutCubic); } } else { DOTween.Kill(555); jumpGravityTween = 1f; isHoldingJump = false; } } var tempMoveInput = moveInput; var dt = Time.deltaTime; float tempSpeed = moveSpeed; var groundCheckOffset = DoComplicatedCollisionGroundCheck(); transform.position += groundCheckOffset; CalculateDirectionVectors(); var moveDir = (sideways * tempMoveInput.x + forward * tempMoveInput.y); if (!isGroundSettled) { if (isJumping && velocity.y <= 0) { isJumping = false; } coyoteDelta += dt; velocity += isJumping ? Gravity.Down * (gravityStrength * jumpGravityTween * dt) : Gravity.Down * (gravityStrength * gravityFallingMultiplier * dt); float tempAirControl = airControl; momentum += moveDir * tempAirControl; var tempMaxAirSpeed = cacheGroundSpeed > moveSpeed && momentum.magnitude > moveSpeed ? cacheGroundSpeed : moveSpeed; if (tempMaxAirSpeed == moveSpeed && isDashing) { DOTween.Kill(75); if (!DOTween.IsTweening(1001)) { cameraSettings.DOFieldOfView(FOV, dashTweenSpeed).SetId(1001); } } momentum = Vector3.ClampMagnitude(momentum, tempMaxAirSpeed); } else { coyoteDelta = 0f; if (!isVelocityDecelTweening) { velocityMagnitudeCache = Mathf.Clamp(velocity.magnitude * 0.012f, 0f, 1f); } velocity.y = 0f; if (velocity != Vector3.zero) { isVelocityDecelTweening = true; if (!DOTween.IsTweening(900)) { DOTween.To(() => velocity.x, x => velocity.x = x, 0f, velocityMagnitudeCache).SetId(900).SetEase(Ease.OutFlash); } if (!DOTween.IsTweening(910)) { DOTween.To(() => velocity.z, x => velocity.z = x, 0f, velocityMagnitudeCache).SetId(910).SetEase(Ease.OutFlash); } } else { isVelocityDecelTweening = false; } if (moveInput != Vector2.zero) { DOTween.Pause(1000); momentum += isDashing ? moveDir * (groundAccel * 1f) : moveDir * groundAccel; if (isDashing) { if (!DOTween.IsTweening(75)) { cameraSettings.DOFieldOfView(FOV + dashFOVOffset, dashTweenSpeed).SetId(75); } } } else { if (isDashing) { DOTween.Kill(75); if (!DOTween.IsTweening(1001)) { cameraSettings.DOFieldOfView(FOV, dashTweenSpeed).SetId(1001); } } if (momentum != Vector3.zero) { if (!DOTween.IsTweening(1000)) { DOTween.Rewind(1000); } DOTween.Rewind(1001); DOTween.To(() => momentum, x => momentum = x, Vector3.zero, groundDecelSpeed).SetId(1000).SetEase(Ease.OutCubic); } } if (Input.GetButton("Fire3")) { isDashing = true; cacheGroundSpeed = dashSpeed; } else { DOTween.Kill(75); if (!DOTween.IsTweening(1001)) { cameraSettings.DOFieldOfView(FOV, dashTweenSpeed * 0.5f).SetId(1001); } cacheGroundSpeed = moveSpeed; isDashing = false; } momentum = Vector3.ClampMagnitude(momentum, cacheGroundSpeed); } if (Input.GetButtonDown("Jump")) { jumpBufferDelta = 0f; } if (jumpBufferDelta < jumpBuffer) { jumpBufferDelta += dt; if (isGrounded || coyoteDelta < coyoteTime && velocity.y <= 0) { if (!moveAudioSource.isPlaying) { moveAudioSource.PlayOneShot(jumpSound, 0.2f); } velocity.y = Mathf.Sqrt(jumpHeight * -2f * -gravityStrength); isJumping = true; isHoldingJump = true; } } combinedVelocity = ((transform.rotation * momentum) + velocity); var displacement = combinedVelocity * dt; if (displacement.magnitude > collisionVolume.radius) { displacement = ClampDisplacement(velocity + momentum, displacement, transform.position); } transform.position += displacement; velocityInLastFrame = velocity; var collisionDisplacement = ResolveCollisions(); transform.position += collisionDisplacement; DoMouselook(); }