### Transform Movement and Restart Source: http://dotween.demigiant.com/documentation.php Examples of starting a transform movement and restarting a tween using DOTween prefixes. ```csharp transform.DOMoveX(100, 1); transform.DORestart(); ``` -------------------------------- ### DOTweenTMPAnimator - Setup Methods Source: http://dotween.demigiant.com/documentation.php Methods for setting up and managing the DOTweenTMPAnimator. ```APIDOC ## DOTweenTMPAnimator Refresh() ### Description Refreshes the animator text data and resets all transformation data. Automatically called every time you change the text inside your `TMP_Text` object. ### Method DOTweenTMPAnimator Method ``` ```APIDOC ## DOTweenTMPAnimator Reset() ### Description Resets all deformations. ### Method DOTweenTMPAnimator Method ``` -------------------------------- ### Tween Callbacks: Start and Complete Source: http://dotween.demigiant.com/documentation.php Attaching callback functions to the start and completion of a tween. ```csharp myTween.OnStart(myStartFunction).OnComplete(myCompleteFunction); ``` -------------------------------- ### OnStart Callback Source: http://dotween.demigiant.com/documentation.php Sets a callback that will be fired once when the tween starts for the first time. ```APIDOC ## OnStart(TweenCallback callback) ### Description Sets a callback that will be fired once when the tween starts (meaning when the tween is set in a playing state the first time, after any eventual delay). ### Method Chained method call ### Parameters #### Callback Parameter - **callback** (TweenCallback) - The function to execute when the tween starts. ### Request Example ```csharp transform.DOMoveX(4, 1).OnStart(MyCallback); ``` ``` -------------------------------- ### From() - Value, Boolean Parameters Source: http://dotween.demigiant.com/documentation.php Allows setting the starting value of a tween directly, instead of relying on the target's value when the tween starts. ```APIDOC ## From(T fromValue, bool setImmediately = true, bool isRelative = false) ### Description Allows setting the starting value of a tween directly, instead of relying on the target's value when the tween starts. Must be chained before any other setting, except tween specific options. ### Method Chained method call ### Parameters #### Path Parameters - **fromValue** (T) - Required - The value from which the tween will start. - **setImmediately** (bool) - Optional - If TRUE, the target will be immediately set to the `fromValue`. Otherwise, it will wait for the tween to start. - **isRelative** (bool) - Optional - If TRUE, sets the tween as relative. The FROM value will be calculated as `currentValue + fromValue` instead of being used directly. ### Request Example ```csharp // Example usage (assuming T is float for DOMoveX) transform.DOMoveX(2, 1).From(5.0f, true, false); ``` ``` -------------------------------- ### Prepend a Callback to the Beginning of a DOTween Sequence Source: http://dotween.demigiant.com/documentation.php Adds a callback function to the start of the sequence, shifting subsequent elements forward in time. Ensure the sequence is not yet started. ```csharp mySequence.PrependCallback(MyCallback); ``` -------------------------------- ### DOTweenEditorPreview.Start Source: http://dotween.demigiant.com/documentation.php Starts the update loop for tweens in the editor. This method has no effect during play mode. ```APIDOC ## DOTweenEditorPreview.Start ### Description Starts the update loop of tweens in the editor. Has no effect during playMode. Before calling this method you must add tweens to the preview loop via DOTweenEditorPreview.PrepareTweenForPreview. ### Method Signature static DOTweenEditorPreview.Start(Action onPreviewUpdated = null) ### Parameters #### onPreviewUpdated (Action) - Optional - Eventual callback to call after every update (while in editor preview). ``` -------------------------------- ### DOTween Global Play Source: http://dotween.demigiant.com/documentation.php Starts all active tweens managed by DOTween. ```csharp DOTween.Play(); ``` -------------------------------- ### Set DOTween Delay Source: http://dotween.demigiant.com/documentation.php Use SetDelay to introduce a delay before a tween starts. This has no effect if the tween has already started. ```csharp transform.DOMoveX(4, 1).SetDelay(1); ``` -------------------------------- ### Blendable Move By Example Source: http://dotween.demigiant.com/documentation.php Demonstrates how to use DOBlendableMoveBy to tween a target's position by a given value. This allows multiple move tweens to operate concurrently on the same target. ```csharp transform.DOBlendableMoveBy(new Vector3(3, 3, 0), 3); transform.DOBlendableMoveBy(new Vector3(-3, 0, 0), 1f).SetLoops(3, LoopType.Yoyo); ``` -------------------------------- ### Create a DOTween FROM Tween Source: http://dotween.demigiant.com/documentation.php Use the From() method to create a tween that starts from a specified value and tweens to its previous value. This must be chained before other settings. ```csharp // Regular TO tween transform.DOMoveX(2, 1); // FROM tween transform.DOMoveX(2, 1).From(); // FROM tween but with relative FROM value transform.DOMoveX(2, 1).From(true); ``` -------------------------------- ### Prepend a Tween to the Beginning of a DOTween Sequence Source: http://dotween.demigiant.com/documentation.php Adds a tween to the start of the sequence, shifting subsequent elements forward in time. Ensure the sequence is not yet started. ```csharp mySequence.Prepend(transform.DOMoveX(45, 1)); ``` -------------------------------- ### OnPlay Source: http://dotween.demigiant.com/documentation.php Sets a callback that fires when the tween starts playing or resumes from a paused state. ```APIDOC ## OnPlay(TweenCallback callback) ### Description Sets a callback that will be fired when the tween is set in a playing state, after any eventual delay. Also called each time the tween resumes playing from a paused state. ### Parameters #### Path Parameters - **callback** (TweenCallback) - Required - The function to call when the tween plays. ### Request Example ```csharp transform.DOMoveX(4, 1).OnPlay(MyCallback); ``` ``` -------------------------------- ### Get Playing Tweens (DOTween) Source: http://dotween.demigiant.com/documentation.php Returns a list of all tweens that are currently playing. Be aware that this method allocates garbage memory with each call. ```csharp List playingTweens = DOTween.PlayingTweens(); ``` -------------------------------- ### DOVirtual.Int Source: http://dotween.demigiant.com/documentation.php Tweens a virtual integer value from a starting value to an ending value over a specified duration. ```APIDOC ## DOVirtual.Int ### Description Tweens a virtual integer. You can add regular settings to the generated tween, but do not use `OnUpdate` or you will overwrite the onVirtualUpdate parameter. ### Method Signature static Tweener DOVirtual.Int(int from, int to, float duration, TweenCallback onVirtualUpdate) ### Parameters #### from (int) - The value to start from. #### to (int) - The value to tween to. #### duration (float) - The duration of the tween. #### onVirtualUpdate (TweenCallback) - A callback which must accept a parameter of type `int`, called at each update. ``` -------------------------------- ### Wait for Tween Start in Coroutine Source: http://dotween.demigiant.com/documentation.php Use WaitForStart() in a Coroutine to pause execution until the tween begins playing for the first time, after any initial delay. This is useful for synchronizing actions that must occur exactly when an animation begins. ```csharp IEnumerator SomeCoroutine() { Tween myTween = transform.DOMoveX(45, 1); yield return myTween.WaitForStart(); // This log will happen when the tween starts Debug.Log("Tween started!"); } ``` -------------------------------- ### Set OnPlay Callback Source: http://dotween.demigiant.com/documentation.php Attaches a callback function to be executed when the tween starts playing or resumes from a paused state. ```csharp transform.DOMoveX(4, 1).OnPlay(MyCallback); ``` -------------------------------- ### Async Wait for Tween Start Source: http://dotween.demigiant.com/documentation.php Use AsyncWaitForStart() within an async method to wait until a tween begins playing for the first time, after any initial delay. This is essential for synchronizing asynchronous tasks with the exact moment an animation commences. ```csharp await myTween.AsyncWaitForStart(); ``` -------------------------------- ### Get Points for Drawing a DOTween Path Source: http://dotween.demigiant.com/documentation.php Returns an array of points suitable for drawing the path. This method allocates memory. The `subdivisionsXSegment` parameter controls the density of points per segment. ```csharp Vector3[] myPathDrawPoints = myTween.PathGetDrawPoints(); ``` -------------------------------- ### Get Tweens by Target (DOTween) Source: http://dotween.demigiant.com/documentation.php Retrieves all active tweens targeting a specific object. If playingOnly is true, only playing tweens are returned. Note that targets are set automatically with shortcuts. This method allocates garbage memory. ```csharp List tweensByTarget = DOTween.TweensByTarget(myTarget, false); ``` -------------------------------- ### Get Tweens by ID (DOTween) Source: http://dotween.demigiant.com/documentation.php Fetches a list of active tweens associated with a specific ID. If playingOnly is true, only playing tweens are returned. This method allocates garbage memory. ```csharp List tweensWithId = DOTween.TweensById(myId, true); ``` -------------------------------- ### Apply Tween Parameters with SetAs Source: http://dotween.demigiant.com/documentation.php Applies the parameters (id, ease, loops, delay, timeScale, callbacks, etc.) from one tween or a TweenParams object to another. This has no effect if the tween has already started. ```csharp transform.DOMoveX(4, 1).SetAs(myOtherTween); ``` -------------------------------- ### Create and Populate a DOTween Sequence Source: http://dotween.demigiant.com/documentation.php Demonstrates the creation of a DOTween Sequence and the addition of various tweens and intervals. This example shows how to append movement and rotation tweens, prepend a delay, and insert a scaling tween for the entire sequence duration. ```csharp // Grab a free Sequence to use Sequence mySequence = DOTween.Sequence(); // Add a movement tween at the beginning mySequence.Append(transform.DOMoveX(45, 1)); // Add a rotation tween as soon as the previous one is finished mySequence.Append(transform.DORotate(new Vector3(0,180,0), 1)); // Delay the whole Sequence by 1 second mySequence.PrependInterval(1); // Insert a scale tween for the whole duration of the Sequence mySequence.Insert(0, transform.DOScale(new Vector3(3,3,3), mySequence.Duration())); ``` -------------------------------- ### Chaining Multiple Settings Source: http://dotween.demigiant.com/documentation.php Demonstrates how to chain multiple settings onto a single tween for concise code. ```APIDOC ## Chaining Multiple Settings ### Description Chain multiple settings onto a single tween instead of chaining one at a time. ### Request Example ```csharp transform.DOMoveX(45, 1).SetDelay(2).SetEase(Ease.OutQuad).OnComplete(MyCallback); ``` ``` -------------------------------- ### Set Tween as Relative Source: http://dotween.demigiant.com/documentation.php Makes the tween's end value relative to its start value. This setting has no effect on tweens that have already started or on From tweens. ```csharp transform.DOMoveX(4, 1).SetRelative(); ``` -------------------------------- ### Create DOTween Sequence with Chaining Source: http://dotween.demigiant.com/documentation.php Illustrates creating a DOTween Sequence using method chaining for a more concise syntax. This approach chains append, prepend interval, and insert operations on a single line after sequence initialization. ```csharp Sequence mySequence = DOTween.Sequence(); mySequence.Append(transform.DOMoveX(45, 1)) .Append(transform.DORotate(new Vector3(0,180,0), 1)) .PrependInterval(1) .Insert(0, transform.DOScale(new Vector3(3,3,3), mySequence.Duration())); ``` -------------------------------- ### Move a Rigidbody (Shortcut with From) Source: http://dotween.demigiant.com/documentation.php Use the DOTween shortcut DOMove with the From() method to animate a Rigidbody's position from a specified Vector3 to its current position over a duration. Note: The target immediately jumps to the FROM position. ```csharp rigidbody.DOMove(new Vector3(2,3,4), 1).From(); ``` -------------------------------- ### Tween LineRenderer Color Source: http://dotween.demigiant.com/documentation.php Changes the LineRenderer's color over a duration, requiring both start and end Color2 values. Color2 stores two colors for the start and end. ```csharp DOColor(Color2 startValue, Color2 endValue, float duration) ``` ```csharp myLineRenderer.DOColor(new Color2(Color.white, Color.white), new Color2(Color.green, Color.black), 1); ``` -------------------------------- ### Set OnStart Callback for DOTween Source: http://dotween.demigiant.com/documentation.php Use OnStart to execute a function once when the tween begins playing. ```csharp transform.DOMoveX(4, 1).OnStart(MyCallback); ``` -------------------------------- ### Get Elapsed Time of a DOTween Tween Source: http://dotween.demigiant.com/documentation.php Retrieve the elapsed time of a tween. Use `includeLoops = false` to get the time within the current loop cycle, or `true` (default) for the total elapsed time including all loops. ```csharp float loopCycleElapsed = myTween.Elapsed(false); float fullElapsed = myTween.Elapsed(); ```