{"id":13663201,"url":"https://github.com/jeffreylanters/unity-tweens","last_synced_at":"2025-04-13T07:48:04.728Z","repository":{"id":39830205,"uuid":"258036137","full_name":"jeffreylanters/unity-tweens","owner":"jeffreylanters","description":"An extremely light weight, extendable and customisable tweening engine made for strictly typed script-based animations for user-interfaces and world-space objects optimised for all platforms.","archived":false,"fork":false,"pushed_at":"2024-06-26T10:28:37.000Z","size":2490,"stargazers_count":673,"open_issues_count":1,"forks_count":44,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-13T07:47:57.881Z","etag":null,"topics":["animation","easing","tweens","unity"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeffreylanters.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jeffreylanters","custom":"https://paypal.me/jeffreylanters"}},"created_at":"2020-04-22T22:39:42.000Z","updated_at":"2025-04-10T02:00:32.000Z","dependencies_parsed_at":"2024-04-11T15:48:00.843Z","dependency_job_id":null,"html_url":"https://github.com/jeffreylanters/unity-tweens","commit_stats":null,"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffreylanters%2Funity-tweens","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffreylanters%2Funity-tweens/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffreylanters%2Funity-tweens/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffreylanters%2Funity-tweens/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeffreylanters","download_url":"https://codeload.github.com/jeffreylanters/unity-tweens/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681494,"owners_count":21144700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["animation","easing","tweens","unity"],"created_at":"2024-08-02T05:02:20.951Z","updated_at":"2025-04-13T07:48:04.693Z","avatar_url":"https://github.com/jeffreylanters.png","language":"C#","funding_links":["https://github.com/sponsors/jeffreylanters","https://paypal.me/jeffreylanters"],"categories":["Animation","C\\#","C#","Animation and Tweening","Easing","Open Source Packages"],"sub_categories":["Tweening"],"readme":"\u003cdiv align=\"center\"\u003e\n\n![readme splash](https://raw.githubusercontent.com/jeffreylanters/unity-tweens/master/.github/WIKI/repository-readme-splash.png)\n\n[![license](https://img.shields.io/badge/mit-license-red.svg?style=for-the-badge)](https://github.com/jeffreylanters/unity-tweens/blob/master/LICENSE.md)\n[![openupm](https://img.shields.io/npm/v/nl.jeffreylanters.tweens?label=UPM\u0026registry_uri=https://package.openupm.com\u0026style=for-the-badge\u0026color=232c37)](https://openupm.com/packages/nl.jeffreylanters.tweens/)\n[![build](https://img.shields.io/badge/build-passing-brightgreen.svg?style=for-the-badge)](https://github.com/jeffreylanters/unity-tweens/actions)\n[![deployment](https://img.shields.io/badge/state-success-brightgreen.svg?style=for-the-badge)](https://github.com/jeffreylanters/unity-tweens/deployments)\n[![stars](https://img.shields.io/github/stars/jeffreylanters/unity-tweens.svg?style=for-the-badge\u0026color=fe8523\u0026label=stargazers)](https://github.com/jeffreylanters/unity-tweens/stargazers)\n[![downloads](https://img.shields.io/badge/dynamic/json?color=40AA72\u0026style=for-the-badge\u0026label=downloads\u0026query=%24.downloads\u0026url=https%3A%2F%2Fpackage.openupm.com%2Fdownloads%2Fpoint%2Fall-time%2Fnl.jeffreylanters.tweens)](https://openupm.com/packages/nl.jeffreylanters.tweens/)\n[![size](https://img.shields.io/github/languages/code-size/jeffreylanters/unity-tweens?style=for-the-badge)](https://github.com/jeffreylanters/unity-tweens/blob/master/Runtime)\n[![sponsors](https://img.shields.io/github/sponsors/jeffreylanters?color=E12C9A\u0026style=for-the-badge)](https://github.com/sponsors/jeffreylanters)\n[![donate](https://img.shields.io/badge/donate-paypal-F23150?style=for-the-badge)](https://paypal.me/jeffreylanters)\n[![awesome](https://img.shields.io/badge/listed-awesome-fc60a8.svg?style=for-the-badge)](https://github.com/jeffreylanters/awesome-unity-packages)\n\nAn extremely light weight, extendable and customisable tweening engine made for strictly typed script-based animations for user-interfaces and world-space objects optimised for all platforms.\n\n[**Installation**](#installation) \u0026middot;\n[**Documentation**](#documentation) \u0026middot;\n[**License**](./LICENSE.md)\n\n**Made with \u0026hearts; by Jeffrey Lanters**\n\n\u003c/div\u003e\n\n# Installation\n\n### Using the Unity Package Manager\n\nInstall the latest stable release using the Unity Package Manager by adding the following line to your `manifest.json` file located within your project's Packages directory, or by adding the Git URL to the Package Manager Window inside of Unity.\n\n```json\n\"nl.jeffreylanters.tweens\": \"git+https://github.com/jeffreylanters/unity-tweens\"\n```\n\n### Using OpenUPM\n\nThe module is availble on the OpenUPM package registry, you can install the latest stable release using the OpenUPM Package manager's Command Line Tool using the following command.\n\n```sh\nopenupm add nl.jeffreylanters.tweens\n```\n\n# Documentation\n\nTweens focuses on providing a simple and easy to use API for creating and managing tween animations. The module is designed to be as lightweight as possible, while still providing a wide range of features. The module is also designed to be as extendable as possible, allowing you to create your own custom Tweens and Tweens while keeping typings strict.\n\n- [Getting Started](#getting-started) - Code examples on how to create your first Tween\n- [Tween Types](#tween-types) - A list of all available Tween types\n- [Tween Options](#tween-options) - A list of all available Tween options\n- [Tween Instances](#tween-instances) - Methods available on Tween instances\n- [Extensions](#extensions) - Extensions available by the Tween module\n- [Advanced Examples](#advanced-examples) - Advanced examples on how to use the Tween module\n\nStill using version 2 of Tweens? View the [documentation here](https://github.com/jeffreylanters/unity-tweens/tree/v2.1.0)!\n\n## Getting Started\n\nTo get started, create a new instance of one of the many available Tween types and add it to a GameObject. The following example shows how to create a new PositionTween and add it to a GameObject in order to move a GameObject from its current position to a new position.\n\n```cs\nvar tween = new PositionTween {\n  to = new Vector3(10, 5, 20),\n  duration = 5,\n};\ngameObject.AddTween(tween);\n```\n\nThe PositionTween in this example represents a configuration rather than a running tween, so you can reuse it as many times as you need while it can also be altered during uses.\n\n```cs\nvar tween = new PositionTween {\n  to = new Vector3(10, 5, 20),\n  duration = 5,\n};\ngameObject.AddTween(tween);\ndifferentGameObject.AddTween(tween);\ntween.to.x = 20;\notherGameObject.AddTween(tween);\n```\n\nWhen a Tween is added, an Instance will be returned. This is where the Tween will be running. The Instance can be used to control the Tween, for example to pause, resume or cancel the Tween.\n\n```cs\nvar tween = new PositionTween { };\nvar instance = gameObject.AddTween(tween);\ninstance.Cancel();\n```\n\nUse the built-in Tween Inspector to analyze and debug Tweens. The Tween Inspector can be found in the Window menu under the Analysis category.\n\n![Tween Inspector Window](https://raw.githubusercontent.com/jeffreylanters/unity-tweens/master/.github/WIKI/tween-inspector.png)\n\nThese are just some of the many options available to you, for more information on how to use this Tweens. Not only are there many different types of Tweens, but there are also many different options available to you. For more information on how to use this module, please refer to the rest of the documentation.\n\nHappy Tweening!\n\n## Tween Types\n\nTo start animating a value, you will need to create a new Tween. The following sections will list all available Tween types. When a Tween will animate a specific value within a Component, the Tween will get the required Component from the GameObject automatically. When the Component is not available, the Tween will be cancelled.\n\n### Transform\n\nThe following Tween Types can be used to alter values of a Transform Component; `PositionTween`, `PositionXTween`, `PositionYTween`, `PositionZTween`, `LocalPositionTween`, `LocalPositionXTween`, `LocalPositionYTween`, `LocalPositionZTween`, `RotationTween`, `LocalRotationTween`, `EulerAnglesTween`, `EulerAnglesXTween`, `EulerAnglesYTween`, `EulerAnglesZTween`, `LocalEulerAnglesTween`, `LocalEulerAnglesXTween`, `LocalEulerAnglesYTween`, `LocalEulerAnglesZTween`, `LocalScaleTween`, `LocalScaleXTween`, `LocalScaleTweenY`, `LocalScaleTweenZ`.\n\n### Rect Transform\n\nThe following Tween Types can be used to alter values of a Rect Transform Component; `AnchoredPositionTween`, `AnchoredPositionXTween`, `AnchoredPositionYTween`, `AnchorMinTween`, `AnchorMaxTween`.\n\n### Sprite Renderer\n\nThe following Tween Types can be used to alter values of a Sprite Renderer Component; `SpriteRendererAlphaTween`, `SpriteRendererColorTween`.\n\n### Image\n\nThe following Tween Types can only be used if the `requires com.unity.ugui` package is installed in your project, and can be used to alter values of an Image Component; `ImageFillAmountTween`.\n\n### Graphic\n\nThe following Tween Types can only be used if the `requires com.unity.ugui` package is installed in your project, and can be used to alter values of a Graphic Component; `GraphicAlphaTween`, `GraphicColorTween`.\n\n### Audio Source\n\nThe following Tween Types can be used to alter values of an Audio Source Component; `AudioSourceVolumeTween`, `AudioSourcePitchTween`, `AudioSourcePanTween`, `AudioSourcePriorityTween`, `AudioSourceReverbZoneMixTween`, `AudioSourceSpatialBlendTween`.\n\n### Light\n\nThe following Tween Types can be used to alter values of a Light Component; `LightColorTween`, `LightIntensityTween`, `LightRangeTween`, `LightSpotAngleTween`.\n\n### Generic\n\nThe following Tween Types can be used to alter values of any property; `FloatTween`, `Vector2Tween`, `Vector3Tween`, `Vector4Tween`, `ColorTween`, `QuaternionTween`, `RectTween`.\n\n## Tween Options\n\nWhile the Tween Type defines what the Tween will do, the Tween Options define how the Tween will do it. In the following sections, you will find a list of all available Tween Options.\n\n### From\n\nThe from value defines the starting value of the Tween. When the from value is not set, the Tween will use the current value of the property.\n\n```cs\nDataType from;\n```\n\n```cs\nvar tween = new ExampleTween {\n  from = new Vector3(10, 5, 20),\n};\n```\n\n### To\n\nThe to value defines the end value of the Tween. When the to value is not set, the Tween will use the current value of the property.\n\n```cs\nDataType to;\n```\n\n```cs\nvar tween = new ExampleTween {\n  to = new Vector3(10, 5, 20),\n};\n```\n\n### Duration\n\nThe duration of the Tween in seconds defines how long the Tween will take to complete. When the duration is not set, the Tween will complete instantly.\n\n```cs\nfloat duration;\n```\n\n```cs\nvar tween = new ExampleTween {\n  duration = 5,\n};\n```\n\n### Delay\n\nThe delay of the Tween in seconds defines how long the Tween will wait before starting. To change the behaviour of how to the delay will affect the Tween before it starts, you can change the [Fill Mode](#fill-mode). When the delay is not set, the Tween will start instantly.\n\n```cs\nfloat delay;\n```\n\n```cs\nvar tween = new ExampleTween {\n  delay = 5,\n};\n```\n\n### Loops\n\nThe amount of times the Tween will loop defines how many times the Tween will repeat itself. When the Tween is using a [Ping Pong](#ping-pong) loop type, the Tween has to play both the forward and backward animation to count as one loop. When [Infinite](#infinite) is set, the Tween will loop forever and the loop count will be ignored. When the amount of loops is not set, the Tween will not loop.\n\n```cs\nint loops;\n```\n\n```cs\nvar tween = new ExampleTween {\n  loops = 5,\n};\n```\n\n### Infinite\n\nThe infinite option defines whether the Tween will loop forever. When the Tween is set to loop forever, the [Loops](#loops) option will be ignored. When the infinite option is not set, the Tween will not loop forever.\n\n```cs\nbool isInfinite;\n```\n\n```cs\nvar tween = new ExampleTween {\n  isInfinite = true,\n};\n```\n\n### Ping Pong\n\nThe ping pong option defines whether the Tween will play the animation backwards after the animation has finished. When the ping pong option is not set, the Tween will not play the animation backwards after the animation has finished.\n\n```cs\nbool usePingPong;\n```\n\n```cs\nvar tween = new ExampleTween {\n  usePingPong = true,\n};\n```\n\n### Ping Pong Interval\n\nThe ping pong interval defines how long the Tween will wait before playing the animation backwards after the animation has finished. When the ping pong interval is not set, the Tween will play the animation backwards instantly after the animation has finished.\n\n```cs\nfloat pingPongInterval;\n```\n\n```cs\nvar tween = new ExampleTween {\n  pingPongInterval = 5,\n};\n```\n\n### Repeat Interval\n\nThe repeat interval defines how long the Tween will wait before repeating itself. When the repeat interval is not set, the Tween will repeat itself instantly after the animation has finished.\n\n```cs\nfloat repeatInterval;\n```\n\n```cs\nvar tween = new ExampleTween {\n  repeatInterval = 5,\n};\n```\n\n### Offset\n\nThe offset defines on which time the Tween will start. When the offset is not set, the Tween will start at the beginning.\n\n```cs\nfloat offset;\n```\n\n```cs\nvar tween = new ExampleTween {\n  offset = 5,\n};\n```\n\n### Ease Type\n\nThe ease type defines how the Tween will animate. If an [Animation Curve](#animation-curve) is set, the Ease Type won't be used. When the ease type is not set, the Tween will animate linearly.\n\nThe following Ease Types can be applied; `Linear`, `SineIn`, `SineOut`, `SineInOut`, `QuadIn`, `QuadOut`, `QuadInOut`, `CubicIn`, `CubicOut`, `CubicInOut`, `QuartIn`, `QuartOut`, `QuartInOut`, `QuintIn`, `QuintOut`, `QuintInOut`, `ExpoIn`, `ExpoOut`, `ExpoInOut`, `CircIn`, `CircOut`, `CircInOut`, `BackIn`, `BackOut`, `BackInOut`, `ElasticIn`, `ElasticOut`, `ElasticInOut`, `BounceIn`, `BounceOut`, `BounceInOut`.\n\n```cs\nEaseType easeType;\n```\n\n```cs\nvar tween = new ExampleTween {\n  easeType = EaseType.QuadInOut,\n};\n```\n\n### Animation Curve\n\nThe animation curve defines how the Tween will animate. The animation curve can be used to create custom ease types. When the animation curve is not set, the Tween will animate according to the [Ease Type](#ease-type).\n\n```cs\nAnimationCurve animationCurve;\n```\n\n```cs\nvar tween = new ExampleTween {\n  animationCurve = AnimationCurve.EaseInOut(0, 0, 1, 1),\n};\n```\n\n### Use Unscaled Time\n\nThe use unscaled time option defines whether the Tween will use the unscaled time. When the use unscaled time option is not set, the Tween will use the scaled time.\n\n```cs\nbool useUnscaledTime;\n```\n\n```cs\nvar tween = new ExampleTween {\n  useUnscaledTime = true,\n};\n```\n\n### Fill Mode\n\nThe fill mode defines how the Tween will behave before the Tween has started and after the Tween has ended. When the fill mode is not set, the fill mode will be set to `Backward`.\n\n- `None` - The animation will not be applied before the Tween has started, and will return to its original state after the Tween has ended.\n- `Forward` - The animation will be applied before the Tween has started, but will return to its original state after the Tween has ended.\n- `Backward` - The animation will not be applied before the Tween has started, but will remain in its final state after the Tween has ended.\n- `Both` - The animation will be applied before the Tween has started, and will remain in its final state after the Tween has ended.\n\n```cs\nFillMode fillMode;\n```\n\n```cs\nvar tween = new ExampleTween {\n  fillMode = FillMode.Both,\n};\n```\n\n### On Add\n\nThe on add delegate will be invoked when the Tween has been added to a GameObject.\n\n```cs\nOnAddDelegate\u003cComponentType, DataType\u003e onAdd;\n```\n\n```cs\nvar tween = new ExampleTween {\n  onAdd = (instance) =\u003e {\n    Debug.Log(\"Tween has been added\");\n  },\n};\n```\n\n### On Start\n\nThe on start delegate will be invoked when the Tween has started.\n\n```cs\nOnStartDelegate\u003cComponentType, DataType\u003e onStart;\n```\n\n```cs\nvar tween = new ExampleTween {\n  onStart = (instance) =\u003e {\n    Debug.Log(\"Tween has started\");\n  },\n};\n```\n\n### On Update\n\nThe on update delegate will be invoked when the Tween has updated.\n\n```cs\nOnUpdateDelegate\u003cComponentType, DataType\u003e onUpdate;\n```\n\n```cs\nvar tween = new ExampleTween {\n  onUpdate = (instance, value) =\u003e {\n    Debug.Log(\"Tween has updated\");\n  },\n};\n```\n\n### on End\n\nThe on end delegate will be invoked when the Tween has ended.\n\n```cs\nOnEndDelegate\u003cComponentType, DataType\u003e onEnd;\n```\n\n```cs\nvar tween = new ExampleTween {\n  onEnd = (instance) =\u003e {\n    Debug.Log(\"Tween has ended\");\n  },\n};\n```\n\n### On Cancel\n\nThe on cancel delegate will be invoked when the Tween has been cancelled.\n\n```cs\nOnCancelDelegate\u003cComponentType, DataType\u003e onCancel;\n```\n\n```cs\nvar tween = new ExampleTween {\n  onCancel = (instance) =\u003e {\n    Debug.Log(\"Tween has been cancelled\");\n  },\n};\n```\n\n### On Finally\n\nThe on finally delegate will be invoked when the Tween has ended or has been cancelled.\n\n```cs\nOnFinallyDelegate\u003cComponentType, DataType\u003e onFinally;\n```\n\n```cs\nvar tween = new ExampleTween {\n  onFinally = (instance) =\u003e {\n    Debug.Log(\"Tween has ended or has been cancelled\");\n  },\n};\n```\n\n### Dont Invoke When Destroyed\n\nThe don't invoke when destroyed option defines whether the Tween should invoke the delegates when the component is no longer present in the scene. When not set, all delegates will be invoked even when the component is destroyed.\n\n```cs\nbool dontInvokeWhenDestroyed;\n```\n\n```cs\nvar tween = new ExampleTween {\n  dontInvokeWhenDestroyed = true\n};\n```\n\n## Tween Instances\n\nWhen a Tween is added to a GameObject, an Instance will be returned. This is where the Tween will be running. The Instance can be used to control the Tween, for example to pause, resume or cancel the Tween.\n\n### Cancel\n\nThe cancel method will cancel the Tween. When the Tween is cancelled, the [On Cancel](#on-cancel) and [On Finally](#on-finally) delegates will be invoked.\n\n```cs\nvoid Cancel();\n```\n\n```cs\nvar tween = new ExampleTween { };\nvar instance = gameObject.AddTween(tween);\ninstance.Cancel();\n```\n\n### Is Paused\n\nThe is paused property will return whether the Tween is paused while also allowing you to pause the Tween.\n\n```cs\nbool isPaused;\n```\n\n```cs\nvar tween = new ExampleTween { };\nvar instance = gameObject.AddTween(tween);\ninstance.isPaused = true;\n```\n\n### Target\n\nThe target property defines the target GameObject on which the Tween is running.\n\n```cs\nreadonly GameObject target;\n```\n\n```cs\nvar tween = new ExampleTween { };\nvar instance = gameObject.AddTween(tween);\nDebug.Log(instance.target);\n```\n\n### Await Decommission\n\nThe await decommission method will return an enumerator that will await the decommission of the Tween. This can be used in coroutines to wait for the Tween to finish or be cancelled.\n\n```cs\nIEnumerator AwaitDecommission();\n```\n\n```cs\nvar tween = new ExampleTween { };\nvar instance = gameObject.AddTween(tween);\nyield return instance.AwaitDecommission();\n```\n\n### Await Decommission Async\n\nThe await decommission async method will return an awaitable that will await the decommission of the Tween. This can be used in async methods to wait for the Tween to finish or be cancelled.\n\n```cs\nAwaitable AwaitDecommissionAsync();\n```\n\n```cs\nvar tween = new ExampleTween { };\nvar instance = gameObject.AddTween(tween);\nawait instance.AwaitDecommissionAsync();\n```\n\n## Extensions\n\nTweens also provides extension methods that can be used to control the Tween module.\n\n### Add Tween\n\nThe add tween method will add a new Tween to the target GameObject. When the Tween is added, an Instance will be returned. This is where the Tween will be running. The Instance can be used to control the Tween, for example to pause, resume or cancel the Tween.\n\n```cs\nTweenInstance\u003cComponentType, DataType\u003e AddTween\u003cComponentType, DataType\u003e(this GameObject target, Tween\u003cComponentType, DataType\u003e tween) where ComponentType : Component;\n```\n\n```cs\nvar tween = new ExampleTween { };\nvar instance = gameObject.AddTween(tween);\n```\n\n### Cancel Tweens\n\nThe cancel tweens method will cancel all Tweens on the target GameObject. When a Tween is cancelled, the [On Cancel](#on-cancel) and [On Finally](#on-finally) delegates will be invoked. When the include children option is set, all Tweens on the children of the target GameObject will also be cancelled, otherwise only the Tweens on the target GameObject will be cancelled.\n\n```cs\nvoid CancelTweens(this GameObject target, bool includeChildren = false);\n```\n\n```cs\ngameObject.CancelTweens();\n```\n\n## Advanced Examples\n\nBesides the many different types of Tweens and Tween Options, Tweens also provides a wide range of features that can be used to create advanced animations. The following sections will show you how to implemented some of these features to create advanced animation logic.\n\n### Tweening Custom Values\n\nThe following example shows how to create a custom Tween that can be used to animate a value of an enemy Component. The Tween will animate the value of the Component from the current value to the new value.\n\n```cs\nvar enemy = GetComponent\u003cEnemy\u003e();\nvar tween = new FloatTween {\n  from = enemy.health,\n  to = 23,\n  duration = 1,\n  easeType = EaseType.SineOut,\n  onUpdate = (_, value) =\u003e enemy.health = value,\n};\nenemy.gameObject.AddTween(tween);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeffreylanters%2Funity-tweens","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeffreylanters%2Funity-tweens","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeffreylanters%2Funity-tweens/lists"}