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) | |
triggerOnEnd (Boolean) | (Optional) If |
mode (CompletionMode) | (Optional) The completion mode defines the end values to apply. Default value is |
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 |
mode (CompletionMode) | (Optional) The completion mode defines the end values to apply. Default value is |
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) | |
triggerOnEnd (Boolean) | (Optional) If |
mode (CompletionMode) | (Optional) The completion mode defines the end values to apply. Default value is |
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 |
easingFunction (EasingFunction) | The easing function represents the type of easing. |
duration (Float) | Total tween duration (in seconds). |
killOnEnd (Boolean) | (Optional) If |
Returns
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 |
easingFunction (EasingFunction) | The easing function represents the type of easing. |
duration (Float) | Total tween duration (in seconds). |
killOnEnd (Boolean) | (Optional) If |
Returns
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 |
easingFunction (EasingFunction) | The easing function represents the type of easing. |
duration (Float) | Total tween duration (in seconds). |
killOnEnd (Boolean) | (Optional) If |
Returns
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 |
easingFunction (EasingFunction) | The easing function represents the type of easing. |
duration (Float) | Total tween duration (in seconds). |
killOnEnd (Boolean) | (Optional) If |
Returns
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 |
easingFunction (EasingFunction) | The easing function represents the type of easing. |
duration (Float) | Total tween duration (in seconds). |
killOnEnd (Boolean) | (Optional) If |
Returns
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 |
easingFunction (EasingFunction) | The easing function represents the type of easing. |
duration (Float) | Total tween duration (in seconds). |
killOnEnd (Boolean) | (Optional) If |
Returns
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
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) |
Returns
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) |
Returns
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()
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) |
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)
Parameters
id (String) |
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 |
easingFunction (EasingFunction) | The easing function represents the type of easing. |
duration (Float) | Total tween duration (in seconds). |
killOnEnd (Boolean) | (Optional) If |
Returns
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()
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) |
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)
Parameters
id (String) |
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()
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) |
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)
Parameters
id (String) |
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()
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) |
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) |
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 |
easingFunction (EasingFunction) | The easing function represents the type of easing. |
duration (Float) | Total tween duration (in seconds). |
killOnEnd (Boolean) | (Optional) If |
Returns
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 |
easingFunction (EasingFunction) | The easing function represents the type of easing. |
duration (Float) | Total tween duration (in seconds). |
killOnEnd (Boolean) | (Optional) If |
Returns
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) | |
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) | |
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");
}
}