Str8lines
Search Results for

    Show / Hide Table of Contents

    Class Str8Tween

    Str8Tween is a tween engine. This class is meant to instantiate tweens and manage their lifecycle. It provides additional methods to manipulate every tweens created.

    Methods

    complete(GameObject, Boolean, CompletionMode)

    Completes every tween associated to the given GameObject.

    Parameters
    target (GameObject)

    The target of the tweens to complete.

    triggerOnEnd (Boolean)

    (Optional) If true, triggers tween's end event. Default value is true

    mode (CompletionMode)

    (Optional) The completion mode defines the end values to apply. Default value is STATIC

    Examples

    Press space to complete target's tweens :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public GameObject target;
    
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.complete(target);
        }
    }

    complete(Boolean, CompletionMode)

    Completes every tween alive. See also complete(Boolean, CompletionMode).

    Parameters
    triggerOnEnd (Boolean)

    (Optional) If true, triggers tween's end event. Default value is true

    mode (CompletionMode)

    (Optional) The completion mode defines the end values to apply. Default value is STATIC

    Examples

    Press space to complete every tween :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.complete();
        }
    }

    complete(String, Boolean, CompletionMode)

    Completes the tween associated to the given uuid. See also complete(Boolean, CompletionMode).

    Parameters
    id (String)

    The id of the tween to complete.

    triggerOnEnd (Boolean)

    (Optional) If true, triggers tween's end event. Default value is true

    mode (CompletionMode)

    (Optional) The completion mode defines the end values to apply. Default value is STATIC

    Examples

    Press space to complete a tween :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.complete("7aac6207-107f-4ddc-8761-122f669d3e3b");
        }
    }

    fade(CanvasRenderer, Single, EasingFunction, Single, Boolean)

    Instantiates a new tween which changes canvasRenderer's alpha to a given value.

    Parameters
    canvasRenderer (CanvasRenderer)

    The CanvasRenderer which will have its alpha changed.

    toValue (Float)

    A float that represents canvasRenderer's final alpha value.

    easingFunction (EasingFunction)

    The easing function represents the type of easing.

    duration (Float)

    Total tween duration (in seconds).

    killOnEnd (Boolean)

    (Optional) If true, the tween will be destroyed on end.

    Returns
    Tween ➜

    The tween created.

    Examples

    Changes the CanvasRenderer's alpha during 3 seconds with a linear easing.

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public CanvasRenderer canvasRenderer;
    
        private void Start()
        {
            Str8Tween.fade(canvasRenderer, 0f, EasingFunction.Linear, 3f);
        }
    }

    fade(Graphic, Single, EasingFunction, Single, Boolean)

    Instantiates a new tween which changes graphic's alpha to a given value.

    Parameters
    graphic (Graphic)

    The Graphic which will have its alpha changed.

    toValue (Float)

    A float that represents graphic's final alpha value.

    easingFunction (EasingFunction)

    The easing function represents the type of easing.

    duration (Float)

    Total tween duration (in seconds).

    killOnEnd (Boolean)

    (Optional) If true, the tween will be destroyed on end.

    Returns
    Tween ➜

    The tween created.

    Examples

    Changes the Graphic's alpha during 3 seconds with a linear easing.

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public Graphic graphic;
    
        private void Start()
        {
            Str8Tween.fade(graphic, 0f, EasingFunction.Linear, 3f);
        }
    }

    fade(Image, Single, EasingFunction, Single, Boolean)

    Instantiates a new tween which changes image's alpha to a given value.

    Parameters
    image (Image)

    The Image which will have its alpha changed.

    toValue (Float)

    A float that represents image's final alpha value.

    easingFunction (EasingFunction)

    The easing function represents the type of easing.

    duration (Float)

    Total tween duration (in seconds).

    killOnEnd (Boolean)

    (Optional) If true, the tween will be destroyed on end.

    Returns
    Tween ➜

    The tween created.

    Examples

    Changes the Image's alpha during 3 seconds with a linear easing.

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public Image image;
    
        private void Start()
        {
            Str8Tween.fade(image, 0f, EasingFunction.Linear, 3f);
        }
    }

    fade(RawImage, Single, EasingFunction, Single, Boolean)

    Instantiates a new tween which changes rawImage's alpha to a given value.

    Parameters
    rawImage (RawImage)

    The RawImage which will have its alpha changed.

    toValue (Float)

    A float that represents rawImage's final alpha value.

    easingFunction (EasingFunction)

    The easing function represents the type of easing.

    duration (Float)

    Total tween duration (in seconds).

    killOnEnd (Boolean)

    (Optional) If true, the tween will be destroyed on end.

    Returns
    Tween ➜

    The tween created.

    Examples

    Changes the RawImage's alpha during 3 seconds with a linear easing.

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public RawImage rawImage;
    
        private void Start()
        {
            Str8Tween.fade(rawImage, 0f, EasingFunction.Linear, 3f);
        }
    }

    fade(SpriteRenderer, Single, EasingFunction, Single, Boolean)

    Instantiates a new tween which changes spriteRenderer's alpha to a given value.

    Parameters
    spriteRenderer (SpriteRenderer)

    The SpriteRenderer which will have its alpha changed.

    toValue (Float)

    A float that represents spriteRenderer's final alpha value.

    easingFunction (EasingFunction)

    The easing function represents the type of easing.

    duration (Float)

    Total tween duration (in seconds).

    killOnEnd (Boolean)

    (Optional) If true, the tween will be destroyed on end.

    Returns
    Tween ➜

    The tween created.

    Examples

    Changes the SpriteRenderer's alpha during 3 seconds with a linear easing.

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public SpriteRenderer spriteRenderer;
    
        private void Start()
        {
            Str8Tween.fade(spriteRenderer, 0f, EasingFunction.Linear, 3f);
        }
    }

    fade(Text, Single, EasingFunction, Single, Boolean)

    Instantiates a new tween which changes text's alpha to a given value.

    Parameters
    text (Text)

    The Text which will have its alpha changed.

    toValue (Float)

    A float that represents text's final alpha value.

    easingFunction (EasingFunction)

    The easing function represents the type of easing.

    duration (Float)

    Total tween duration (in seconds).

    killOnEnd (Boolean)

    (Optional) If true, the tween will be destroyed on end.

    Returns
    Tween ➜

    The tween created.

    Examples

    Changes the Text's alpha during 3 seconds with a linear easing.

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public Text text;
    
        private void Start()
        {
            Str8Tween.fade(text, 0f, EasingFunction.Linear, 3f);
        }
    }

    get()

    Returns the tweens which are still alive.

    Returns
    Tween[] ➜

    An Array of tweens.

    Examples

    Displays the ids of every existing tween in console :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        private void Start()
        {
            Tween[] tweens = Str8Tween.get();
            if(tweens.Length > 0){
                foreach(Tween t in tweens){
                    UnityEngine.Debug.Log(t.id)
                }
            }
        }
    }

    get(GameObject)

    Returns the tweens associated to the given GameObject.

    Parameters
    target (GameObject)

    The target of the tweens to retrieve.

    Returns
    Tween[] ➜

    An Array of tweens.

    Examples

    Displays target's tweens ids in console :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public GameObject target;
    
        private void Start()
        {
            Tween[] tweens = Str8Tween.get(target);
            if(tweens.Length > 0){
                foreach(Tween t in tweens){
                    UnityEngine.Debug.Log(t.id)
                }
            }
        }
    }

    get(String)

    Returns the tween associated to the given uuid.

    Parameters
    id (String)

    The id of the tween to retrieve.

    Returns
    Tween ➜

    The tween retrieved or null if not found.

    Examples

    Gets a tween from its id :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        private void Start()
        {
            Tween t = Str8Tween.get("7aac6207-107f-4ddc-8761-122f669d3e3b");
        }
    }

    kill()

    Kills every tween alive. See also kill().

    Examples

    Press space to kill every tween :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.kill();
        }
    }

    kill(GameObject)

    Kills every tween associated to the given GameObject.

    Parameters
    target (GameObject)

    The target of the tweens to kill.

    Examples

    Press space to kill target's tweens :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public GameObject target;
    
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.kill(target);
        }
    }

    kill(String)

    Kills the tween associated to the given uuid. See also kill().

    Parameters
    id (String)

    The id of the tween to kill.

    Examples

    Press space to kill a tween :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.kill("7aac6207-107f-4ddc-8761-122f669d3e3b");
        }
    }

    move(RectTransform, Vector3, EasingFunction, Single, Boolean)

    Instantiates a new tween which changes the anchoredPosition3D of the rectTransform.

    Parameters
    rectTransform (RectTransform)

    The RectTransform to move.

    toValue (Vector3)

    A Vector3 that represents rectTransform's final position.

    easingFunction (EasingFunction)

    The easing function represents the type of easing.

    duration (Float)

    Total tween duration (in seconds).

    killOnEnd (Boolean)

    (Optional) If true, the tween will be destroyed on end.

    Returns
    Tween ➜

    The tween created.

    Examples

    Changes the rectTransform's anchoredPosition3D during 3 seconds in a linear motion.

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public RectTransform rectTransform;
    
        private void Start()
        {
            Vector3 destination = new Vector3(0, 500);
            Str8Tween.move(rectTransform, destination, EasingFunction.Linear, 3f);
        }
    }

    pause()

    Pauses every tween alive. See also pause().

    Examples

    Press space to pause existing tweens :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.pause();
        }
    }

    pause(GameObject)

    Pauses every tween associated to the given GameObject.

    Parameters
    target (GameObject)

    The target of the tweens to pause.

    Examples

    Press space to pause target's tweens :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public GameObject target;
    
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.pause(target);
        }
    }

    pause(String)

    Pauses the tween associated to the given uuid. See also pause().

    Parameters
    id (String)

    The id of the tween to pause.

    Examples

    Press space to pause a tween :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.pause("7aac6207-107f-4ddc-8761-122f669d3e3b");
        }
    }

    play()

    Plays every tween alive. See also play().

    Examples

    Press space to play existing tweens :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.play();
        }
    }

    play(GameObject)

    Plays every tween associated to the given GameObject.

    Parameters
    target (GameObject)

    The target of the tweens to play.

    Examples

    Press space to play target's tweens :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public GameObject target;
    
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.play(target);
        }
    }

    play(String)

    Plays the tween associated to the given uuid. See also play().

    Parameters
    id (String)

    The id of the tween to play.

    Examples

    Press space to play a tween :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.play("7aac6207-107f-4ddc-8761-122f669d3e3b");
        }
    }

    reset()

    Reset every tween alive. See also reset().

    Examples

    Press space to reset every tween :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.reset();
        }
    }

    reset(GameObject)

    Reset every tween associated to the given GameObject.

    Parameters
    target (GameObject)

    The target of the tweens to reset.

    Examples

    Press space to reset target's tweens :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public GameObject target;
    
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.reset(target);
        }
    }

    reset(String)

    Resets the tween associated to the given uuid.

    Parameters
    id (String)

    The id of the tween to reset. See also reset()

    Examples

    Press space to reset a tween :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.reset("7aac6207-107f-4ddc-8761-122f669d3e3b");
        }
    }

    rotate(RectTransform, Vector3, EasingFunction, Single, Boolean)

    Instantiates a new tween which changes the localEulerAngles of the rectTransform.

    Parameters
    rectTransform (RectTransform)

    The RectTransform that will rotate.

    toValue (Vector3)

    A Vector3 that represents rectTransform's final rotation.

    easingFunction (EasingFunction)

    The easing function represents the type of easing.

    duration (Float)

    Total tween duration (in seconds).

    killOnEnd (Boolean)

    (Optional) If true, the tween will be destroyed on end.

    Returns
    Tween ➜

    The tween created.

    Remarks

    Due to the way Unity handles rotations, toValue may differ from rectTransform's rotation in the inspector. To learn more about rotations in Unity, please check : Rotation and Orientation in Unity.

    Examples

    Changes the rectTransform's localEulerAngles during 3 seconds in a linear motion.

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public RectTransform rectTransform;
    
        private void Start()
        {
            Vector3 newAngles = new Vector3(90, 180, 0);
            Str8Tween.rotate(rectTransform, newAngles, EasingFunction.Linear, 3f);
        }
    }

    scale(RectTransform, Vector3, EasingFunction, Single, Boolean)

    Instantiates a new tween which changes the localScale of the rectTransform.

    Parameters
    rectTransform (RectTransform)

    The RectTransform to scale.

    toValue (Vector3)

    A Vector3 that represents rectTransform's final scale.

    easingFunction (EasingFunction)

    The easing function represents the type of easing.

    duration (Float)

    Total tween duration (in seconds).

    killOnEnd (Boolean)

    (Optional) If true, the tween will be destroyed on end.

    Returns
    Tween ➜

    The tween created.

    Examples

    Changes rectTransform's localScale during 3 seconds with a linear easing.

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public RectTransform rectTransform;
    
        private void Start()
        {
            Vector3 newScale = new Vector3(2, 2, 2);
            Str8Tween.scale(rectTransform, newScale, EasingFunction.Linear, 3f);
        }
    }

    stop(GameObject, Boolean)

    Stops every tween associated to the given GameObject.

    Parameters
    target (GameObject)

    The target of the tweens to stop.

    triggerOnEnd (Boolean)
    Examples

    Press space to stop target's tweens :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        public GameObject target;
    
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.stop(target);
        }
    }

    stop(Boolean)

    Stops every tween alive. See also stop(Boolean).

    Parameters
    triggerOnEnd (Boolean)
    Examples

    Press space to stop every tween :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.stop();
        }
    }

    stop(String, Boolean)

    Stops the tween associated to the given uuid. See also stop(Boolean).

    Parameters
    id (String)

    The id of the tween to stop.

    triggerOnEnd (Boolean)
    Examples

    Press space to stop a tween :

    using UnityEngine;
    using Str8lines.Tweening;
    
    public class MyClass : MonoBehaviour
    {
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space)) Str8Tween.stop("7aac6207-107f-4ddc-8761-122f669d3e3b");
        }
    }
    In This Article

    Geoffrey Lesne (Str8lines) © 2024 - All rights reserved

    • facebook logo
    • linkedin logo
    • discord logo
    contact us / Back to top