├── .gitdeployment ├── .github ├── CODE_OF_CONDUCT.md ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md ├── WIKI │ ├── repository-open-graph.png │ ├── repository-readme-splash.png │ └── tween-inspector.png └── workflows │ ├── close-inactive-issues.yml │ └── create-release.yml ├── .gitignore ├── Editor.meta ├── Editor ├── TweensEditorWindow.cs └── TweensEditorWindow.cs.meta ├── LICENSE.md ├── LICENSE.md.meta ├── README.md ├── README.md.meta ├── RELEASE-NOTES.md ├── RELEASE-NOTES.md.meta ├── Runtime.meta ├── Runtime ├── AnchorMaxTween.cs ├── AnchorMaxTween.cs.meta ├── AnchorMinTween.cs ├── AnchorMinTween.cs.meta ├── AnchoredPositionTween.cs ├── AnchoredPositionTween.cs.meta ├── AnchoredPositionXTween.cs ├── AnchoredPositionXTween.cs.meta ├── AnchoredPositionYTween.cs ├── AnchoredPositionYTween.cs.meta ├── AudioSourcePanTween.cs ├── AudioSourcePanTween.cs.meta ├── AudioSourcePitchTween.cs ├── AudioSourcePitchTween.cs.meta ├── AudioSourcePriorityTween.cs ├── AudioSourcePriorityTween.cs.meta ├── AudioSourceReverbZoneTween.cs ├── AudioSourceReverbZoneTween.cs.meta ├── AudioSourceSpatialBlendTween.cs ├── AudioSourceSpatialBlendTween.cs.meta ├── AudioSourceVolumeTween.cs ├── AudioSourceVolumeTween.cs.meta ├── ColorTween.cs ├── ColorTween.cs.meta ├── Core.meta ├── Core │ ├── EaseFunctions.cs │ ├── EaseFunctions.cs.meta │ ├── Nullable.cs │ ├── Nullable.cs.meta │ ├── Tween.cs │ ├── Tween.cs.meta │ ├── TweenEngine.cs │ └── TweenEngine.cs.meta ├── Delegates.cs ├── Delegates.cs.meta ├── EaseType.cs ├── EaseType.cs.meta ├── EulerAnglesTween.cs ├── EulerAnglesTween.cs.meta ├── EulerAnglesXTween.cs ├── EulerAnglesXTween.cs.meta ├── EulerAnglesYTween.cs ├── EulerAnglesYTween.cs.meta ├── EulerAnglesZTween.cs ├── EulerAnglesZTween.cs.meta ├── FillMode.cs ├── FillMode.cs.meta ├── FloatTween.cs ├── FloatTween.cs.meta ├── GraphicAlphaTween.cs ├── GraphicAlphaTween.cs.meta ├── GraphicColorTween.cs ├── GraphicColorTween.cs.meta ├── ImageFillAmountTween.cs ├── ImageFillAmountTween.cs.meta ├── LightColorTween.cs ├── LightColorTween.cs.meta ├── LightIntensityTween.cs ├── LightIntensityTween.cs.meta ├── LightRangeTween.cs ├── LightRangeTween.cs.meta ├── LightSpotAngleTween.cs ├── LightSpotAngleTween.cs.meta ├── LocalEulerAnglesTween.cs ├── LocalEulerAnglesTween.cs.meta ├── LocalEulerAnglesXTween.cs ├── LocalEulerAnglesXTween.cs.meta ├── LocalEulerAnglesYTween.cs ├── LocalEulerAnglesYTween.cs.meta ├── LocalEulerAnglesZTween.cs ├── LocalEulerAnglesZTween.cs.meta ├── LocalPositionTween.cs ├── LocalPositionTween.cs.meta ├── LocalPositionXTween.cs ├── LocalPositionXTween.cs.meta ├── LocalPositionYTween.cs ├── LocalPositionYTween.cs.meta ├── LocalPositionZTween.cs ├── LocalPositionZTween.cs.meta ├── LocalRotationTween.cs ├── LocalRotationTween.cs.meta ├── LocalScaleTween.cs ├── LocalScaleTween.cs.meta ├── LocalScaleXTween.cs ├── LocalScaleXTween.cs.meta ├── LocalScaleYTween.cs ├── LocalScaleYTween.cs.meta ├── LocalScaleZTween.cs ├── LocalScaleZTween.cs.meta ├── PositionTween.cs ├── PositionTween.cs.meta ├── PositionXTween.cs ├── PositionXTween.cs.meta ├── PositionYTween.cs ├── PositionYTween.cs.meta ├── PositionZTween.cs ├── PositionZTween.cs.meta ├── QuaternionTween.cs ├── QuaternionTween.cs.meta ├── RectTween.cs ├── RectTween.cs.meta ├── RotationTween.cs ├── RotationTween.cs.meta ├── SpriteRendererAlphaTween.cs ├── SpriteRendererAlphaTween.cs.meta ├── SpriteRendererColorTween.cs ├── SpriteRendererColorTween.cs.meta ├── TweenExtension.cs ├── TweenExtension.cs.meta ├── TweenInstance.cs ├── TweenInstance.cs.meta ├── Vector2Tween.cs ├── Vector2Tween.cs.meta ├── Vector3Tween.cs ├── Vector3Tween.cs.meta ├── Vector4Tween.cs └── Vector4Tween.cs.meta ├── nl.jeffreylanters.tweens.asmdef ├── nl.jeffreylanters.tweens.asmdef.meta ├── omnisharp.json ├── omnisharp.json.meta ├── package.json └── package.json.meta /.gitdeployment: -------------------------------------------------------------------------------- 1 | Bump the package version and push a tag to deploy -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at jeffreylanters@me.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: jeffreylanters 2 | custom: https://paypal.me/jeffreylanters 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Desktop (please complete the following information):** 24 | - OS: [e.g. iOS] 25 | - Browser [e.g. chrome, safari] 26 | - Version [e.g. 22] 27 | 28 | **Smartphone (please complete the following information):** 29 | - Device: [e.g. iPhone6] 30 | - OS: [e.g. iOS8.1] 31 | - Browser [e.g. stock browser, safari] 32 | - Version [e.g. 22] 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Before submitting a pull request,** please make sure the following is done: 2 | 3 | - Fork the repository and create your branch from `master`. 4 | - If you've fixed a bug or added code make sure it is tested. 5 | - If provided, ensure the test suite passes using on the library. 6 | - Make sure your code lints and is formatted using Omnisharp. 7 | - If you haven't already, complete the CLA. 8 | -------------------------------------------------------------------------------- /.github/WIKI/repository-open-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreylanters/unity-tweens/a9a39fe9d4e8ff8ef655bfcee2912f7af8fa1e90/.github/WIKI/repository-open-graph.png -------------------------------------------------------------------------------- /.github/WIKI/repository-readme-splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreylanters/unity-tweens/a9a39fe9d4e8ff8ef655bfcee2912f7af8fa1e90/.github/WIKI/repository-readme-splash.png -------------------------------------------------------------------------------- /.github/WIKI/tween-inspector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffreylanters/unity-tweens/a9a39fe9d4e8ff8ef655bfcee2912f7af8fa1e90/.github/WIKI/tween-inspector.png -------------------------------------------------------------------------------- /.github/workflows/close-inactive-issues.yml: -------------------------------------------------------------------------------- 1 | name: Close Inactive Issues 2 | 3 | on: 4 | schedule: 5 | - cron: "30 1 * * *" 6 | 7 | jobs: 8 | close-issues: 9 | name: Close Issue 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/stale@v3 15 | with: 16 | days-before-issue-stale: 30 17 | days-before-issue-close: 14 18 | stale-issue-label: "status:stale" 19 | stale-issue-message: "This issue is stale because it has been open for 30 days with no activity." 20 | close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale." 21 | days-before-pr-stale: -1 22 | days-before-pr-close: -1 23 | repo-token: ${{ secrets.GITHUB_TOKEN }} 24 | -------------------------------------------------------------------------------- /.github/workflows/create-release.yml: -------------------------------------------------------------------------------- 1 | name: Create Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v*" 7 | 8 | jobs: 9 | main: 10 | name: Publish to NPM 11 | 12 | runs-on: ubuntu-latest 13 | 14 | environment: 15 | name: Unity Package Registry 16 | url: https://openupm.com 17 | 18 | steps: 19 | - name: Checkout code 20 | uses: actions/checkout@v2 21 | 22 | - name: Create Release 23 | id: create_release 24 | uses: actions/create-release@v1 25 | env: 26 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 27 | with: 28 | tag_name: ${{ github.ref }} 29 | release_name: Release ${{ github.ref }} 30 | draft: false 31 | prerelease: false 32 | body_path: RELEASE-NOTES.md 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f262506c18844460ad78ddcc3d8850e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/TweensEditorWindow.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using UnityEngine; 3 | using UnityEditor; 4 | using Tweens.Core; 5 | 6 | namespace Tweens.Editor { 7 | internal class TweensEditorWindow : EditorWindow, IHasCustomMenu { 8 | const string baseKey = "Tweens.Editor.TweensEditorWindow"; 9 | const string showDirectionKey = baseKey + ".showDirection"; 10 | const string showIsPausedKey = baseKey + ".showIsPaused"; 11 | const string showPingPongIntervalKey = baseKey + ".showPingPongInterval"; 12 | const string showRepeatIntervalKey = baseKey + ".showRepeatInterval"; 13 | const string showLoopsKey = baseKey + ".showLoops"; 14 | const string autoRepaintKey = baseKey + ".autoRepaint"; 15 | Vector2 scrollPosition; 16 | string searchQuery; 17 | bool showProgress; 18 | bool showDirection; 19 | bool showIsPaused; 20 | bool showPingPongInterval; 21 | bool showRepeatInterval; 22 | bool showLoops; 23 | bool autoRepaint = true; 24 | 25 | [MenuItem("Window/Analysis/Tweens", false, 1000)] 26 | internal static void ShowWindow() { 27 | var window = GetWindow("Tweens"); 28 | window.titleContent = new GUIContent("Tweens", EditorGUIUtility.IconContent("d_PlayButton").image); 29 | window.showDirection = EditorPrefs.GetBool(showDirectionKey, false); 30 | window.showIsPaused = EditorPrefs.GetBool(showIsPausedKey, false); 31 | window.showPingPongInterval = EditorPrefs.GetBool(showPingPongIntervalKey, false); 32 | window.showRepeatInterval = EditorPrefs.GetBool(showRepeatIntervalKey, false); 33 | window.showLoops = EditorPrefs.GetBool(showLoopsKey, false); 34 | window.autoRepaint = EditorPrefs.GetBool(autoRepaintKey, true); 35 | } 36 | 37 | void IHasCustomMenu.AddItemsToMenu(GenericMenu menu) { 38 | menu.AddItem(new GUIContent("Auto repaint"), autoRepaint, () => EditorPrefs.SetBool(autoRepaintKey, autoRepaint = !autoRepaint)); 39 | menu.AddItem(new GUIContent("Documentation"), false, () => Application.OpenURL("https://github.com/jeffreylanters/unity-tweens")); 40 | } 41 | 42 | void OnGUI() { 43 | var wasEnabled = GUI.enabled; 44 | GUI.enabled = Application.isPlaying; 45 | EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); 46 | if (GUILayout.Button(new GUIContent("Cancel all", "Cancels all of the instantiated tweens."), EditorStyles.toolbarButton)) { 47 | TweenEngine.instances.ForEach(tweenInstance => tweenInstance.Cancel()); 48 | } 49 | if (GUILayout.Button(new GUIContent("Pause all", "Pauses all of the instantiated tweens."), EditorStyles.toolbarButton)) { 50 | TweenEngine.instances.ForEach(tweenInstance => tweenInstance.isPaused = true); 51 | } 52 | if (GUILayout.Button(new GUIContent("Unpause all", "Unpauses all of the instantiated tweens."), EditorStyles.toolbarButton)) { 53 | TweenEngine.instances.ForEach(tweenInstance => tweenInstance.isPaused = false); 54 | } 55 | GUILayout.FlexibleSpace(); 56 | GUI.enabled = true; 57 | searchQuery = EditorGUILayout.TextField(searchQuery, EditorStyles.toolbarSearchField); 58 | if (GUILayout.Button(new GUIContent(EditorGUIUtility.IconContent("d_SceneViewVisibility@2x").image, "Toggle the visibility of various columns."), EditorStyles.toolbarDropDown)) { 59 | var menu = new GenericMenu(); 60 | menu.AddItem(new GUIContent("Show Progress"), showProgress, () => EditorPrefs.SetBool(baseKey + ".showProgress", showProgress = !showProgress)); 61 | menu.AddItem(new GUIContent("Show Direction"), showDirection, () => EditorPrefs.SetBool(showDirectionKey, showDirection = !showDirection)); 62 | menu.AddItem(new GUIContent("Show Paused"), showIsPaused, () => EditorPrefs.SetBool(showIsPausedKey, showIsPaused = !showIsPaused)); 63 | menu.AddItem(new GUIContent("Show Ping Pong Interval"), showPingPongInterval, () => EditorPrefs.SetBool(showPingPongIntervalKey, showPingPongInterval = !showPingPongInterval)); 64 | menu.AddItem(new GUIContent("Show Repeat Interval"), showRepeatInterval, () => EditorPrefs.SetBool(showRepeatIntervalKey, showRepeatInterval = !showRepeatInterval)); 65 | menu.AddItem(new GUIContent("Show Loops"), showLoops, () => EditorPrefs.SetBool(showLoopsKey, showLoops = !showLoops)); 66 | menu.ShowAsContext(); 67 | } 68 | GUI.enabled = Application.isPlaying; 69 | EditorGUILayout.EndHorizontal(); 70 | scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); 71 | EditorGUILayout.BeginHorizontal(); 72 | GUILayout.Space(10); 73 | EditorGUILayout.LabelField(new GUIContent("Target", "The target gameObject on which the tween is attached."), EditorStyles.miniBoldLabel); 74 | GUILayout.FlexibleSpace(); 75 | if (showProgress) { 76 | EditorGUILayout.LabelField(new GUIContent("Progress", "The progress position of the tween."), EditorStyles.miniLabel, GUILayout.Width(50)); 77 | } 78 | EditorGUILayout.LabelField(new GUIContent("Time", "The current playback position."), EditorStyles.miniLabel, GUILayout.Width(50)); 79 | EditorGUILayout.LabelField(new GUIContent("Duration", "The duration of the Tween."), EditorStyles.miniLabel, GUILayout.Width(50)); 80 | EditorGUILayout.LabelField(new GUIContent("Halt", "A timer indicating how long the tween is halted."), EditorStyles.miniLabel, GUILayout.Width(50)); 81 | if (showLoops) { 82 | EditorGUILayout.LabelField(new GUIContent("Loops", "The number of loops the tween has to go though left."), EditorStyles.miniLabel, GUILayout.Width(50)); 83 | } 84 | if (showDirection) { 85 | EditorGUILayout.LabelField(new GUIContent("Direction", "The playback direction of the tween."), EditorStyles.miniLabel, GUILayout.Width(50)); 86 | } 87 | if (showIsPaused) { 88 | EditorGUILayout.LabelField(new GUIContent("Paused", "Whether the tween is paused."), EditorStyles.miniLabel, GUILayout.Width(50)); 89 | } 90 | if (showPingPongInterval) { 91 | EditorGUILayout.LabelField(new GUIContent("PingPong", "The interval between PingPong playbacks."), EditorStyles.miniLabel, GUILayout.Width(50)); 92 | } 93 | if (showRepeatInterval) { 94 | EditorGUILayout.LabelField(new GUIContent("Repeat", "The interval between playbacks."), EditorStyles.miniLabel, GUILayout.Width(50)); 95 | } 96 | GUILayout.Space(10); 97 | EditorGUILayout.EndHorizontal(); 98 | if (!Application.isPlaying || TweenEngine.instances.Count == 0) { 99 | GUILayout.Space(20); 100 | GUILayout.Label("No tweens running", EditorStyles.centeredGreyMiniLabel); 101 | EditorGUILayout.EndScrollView(); 102 | return; 103 | } 104 | for (var i = TweenEngine.instances.Count - 1; i >= 0; i -= 1) { 105 | var tweenInstance = TweenEngine.instances[i]; 106 | if (tweenInstance.isDecommissioned || tweenInstance.target == null) { 107 | continue; 108 | } 109 | if (!string.IsNullOrEmpty(searchQuery) && !tweenInstance.target.name.Contains(searchQuery)) { 110 | continue; 111 | } 112 | EditorGUILayout.BeginHorizontal(); 113 | GUILayout.Space(10); 114 | if (GUILayout.Button($"{tweenInstance.target.name} ({tweenInstance.@tweenTypeName})", EditorStyles.linkLabel)) { 115 | if (Event.current.button == 1) { 116 | var menu = new GenericMenu(); 117 | menu.AddItem(new GUIContent("Pause"), tweenInstance.isPaused, () => tweenInstance.isPaused = !tweenInstance.isPaused); 118 | menu.AddItem(new GUIContent("Cancel"), false, () => tweenInstance.Cancel()); 119 | menu.ShowAsContext(); 120 | } 121 | else { 122 | EditorGUIUtility.PingObject(tweenInstance.target); 123 | } 124 | } 125 | GUILayout.FlexibleSpace(); 126 | if (showProgress) { 127 | EditorGUILayout.LabelField("Progress", GUILayout.Width(50)); 128 | EditorGUI.ProgressBar(GUILayoutUtility.GetLastRect(), tweenInstance.time / tweenInstance.duration, $"{Mathf.Round(tweenInstance.time / tweenInstance.duration * 100)}%"); 129 | } 130 | EditorGUILayout.LabelField($"{tweenInstance.time:0.00}s", GUILayout.Width(50)); 131 | EditorGUILayout.LabelField($"{tweenInstance.duration:0.00}s", GUILayout.Width(50)); 132 | EditorGUILayout.LabelField(tweenInstance.haltTime != null ? $"{tweenInstance.haltTime:0.00}s" : "-", GUILayout.Width(50)); 133 | if (showLoops) { 134 | EditorGUILayout.LabelField(tweenInstance.loops != null ? $"{tweenInstance.loops}" : "-", GUILayout.Width(50)); 135 | } 136 | if (showDirection) { 137 | EditorGUILayout.LabelField(tweenInstance.isForwards ? "Forwards" : "Backwards", GUILayout.Width(50)); 138 | } 139 | if (showIsPaused) { 140 | EditorGUILayout.LabelField(tweenInstance.isPaused ? "Paused" : "Playing", GUILayout.Width(50)); 141 | } 142 | if (showPingPongInterval) { 143 | EditorGUILayout.LabelField(tweenInstance.pingPongInterval != null ? $"{tweenInstance.pingPongInterval:0.00}s" : "-", GUILayout.Width(50)); 144 | } 145 | if (showRepeatInterval) { 146 | EditorGUILayout.LabelField(tweenInstance.repeatInterval != null ? $"{tweenInstance.repeatInterval:0.00}s" : "-", GUILayout.Width(50)); 147 | } 148 | GUILayout.Space(10); 149 | EditorGUILayout.EndHorizontal(); 150 | } 151 | EditorGUILayout.EndScrollView(); 152 | GUI.enabled = wasEnabled; 153 | } 154 | 155 | void Update() { 156 | if (!autoRepaint || !EditorApplication.isPlaying || EditorApplication.isPaused) { 157 | return; 158 | } 159 | Repaint(); 160 | } 161 | } 162 | } 163 | #endif -------------------------------------------------------------------------------- /Editor/TweensEditorWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d24f1f88fc8dd4caba8ff9ccd1e589a0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Jeffrey Lanters 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e1aa551b12b8740a2a63a06c9e94dc35 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | ![readme splash](https://raw.githubusercontent.com/jeffreylanters/unity-tweens/master/.github/WIKI/repository-readme-splash.png) 4 | 5 | [![license](https://img.shields.io/badge/mit-license-red.svg?style=for-the-badge)](https://github.com/jeffreylanters/unity-tweens/blob/master/LICENSE.md) 6 | [![openupm](https://img.shields.io/npm/v/nl.jeffreylanters.tweens?label=UPM®istry_uri=https://package.openupm.com&style=for-the-badge&color=232c37)](https://openupm.com/packages/nl.jeffreylanters.tweens/) 7 | [![build](https://img.shields.io/badge/build-passing-brightgreen.svg?style=for-the-badge)](https://github.com/jeffreylanters/unity-tweens/actions) 8 | [![deployment](https://img.shields.io/badge/state-success-brightgreen.svg?style=for-the-badge)](https://github.com/jeffreylanters/unity-tweens/deployments) 9 | [![stars](https://img.shields.io/github/stars/jeffreylanters/unity-tweens.svg?style=for-the-badge&color=fe8523&label=stargazers)](https://github.com/jeffreylanters/unity-tweens/stargazers) 10 | [![downloads](https://img.shields.io/badge/dynamic/json?color=40AA72&style=for-the-badge&label=downloads&query=%24.downloads&url=https%3A%2F%2Fpackage.openupm.com%2Fdownloads%2Fpoint%2Fall-time%2Fnl.jeffreylanters.tweens)](https://openupm.com/packages/nl.jeffreylanters.tweens/) 11 | [![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) 12 | [![sponsors](https://img.shields.io/github/sponsors/jeffreylanters?color=E12C9A&style=for-the-badge)](https://github.com/sponsors/jeffreylanters) 13 | [![donate](https://img.shields.io/badge/donate-paypal-F23150?style=for-the-badge)](https://paypal.me/jeffreylanters) 14 | [![awesome](https://img.shields.io/badge/listed-awesome-fc60a8.svg?style=for-the-badge)](https://github.com/jeffreylanters/awesome-unity-packages) 15 | 16 | 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. 17 | 18 | [**Installation**](#installation) · 19 | [**Documentation**](#documentation) · 20 | [**License**](./LICENSE.md) 21 | 22 | **Made with ♥ by Jeffrey Lanters** 23 | 24 |
25 | 26 | # Installation 27 | 28 | ### Using the Unity Package Manager 29 | 30 | Install 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. 31 | 32 | ```json 33 | "nl.jeffreylanters.tweens": "git+https://github.com/jeffreylanters/unity-tweens" 34 | ``` 35 | 36 | ### Using OpenUPM 37 | 38 | The 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. 39 | 40 | ```sh 41 | openupm add nl.jeffreylanters.tweens 42 | ``` 43 | 44 | # Documentation 45 | 46 | Tweens 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. 47 | 48 | - [Getting Started](#getting-started) - Code examples on how to create your first Tween 49 | - [Tween Types](#tween-types) - A list of all available Tween types 50 | - [Tween Options](#tween-options) - A list of all available Tween options 51 | - [Tween Instances](#tween-instances) - Methods available on Tween instances 52 | - [Extensions](#extensions) - Extensions available by the Tween module 53 | - [Advanced Examples](#advanced-examples) - Advanced examples on how to use the Tween module 54 | 55 | Still using version 2 of Tweens? View the [documentation here](https://github.com/jeffreylanters/unity-tweens/tree/v2.1.0)! 56 | 57 | ## Getting Started 58 | 59 | To 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. 60 | 61 | ```cs 62 | var tween = new PositionTween { 63 | to = new Vector3(10, 5, 20), 64 | duration = 5, 65 | }; 66 | gameObject.AddTween(tween); 67 | ``` 68 | 69 | The 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. 70 | 71 | ```cs 72 | var tween = new PositionTween { 73 | to = new Vector3(10, 5, 20), 74 | duration = 5, 75 | }; 76 | gameObject.AddTween(tween); 77 | differentGameObject.AddTween(tween); 78 | tween.to.x = 20; 79 | otherGameObject.AddTween(tween); 80 | ``` 81 | 82 | When 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. 83 | 84 | ```cs 85 | var tween = new PositionTween { }; 86 | var instance = gameObject.AddTween(tween); 87 | instance.Cancel(); 88 | ``` 89 | 90 | Use the built-in Tween Inspector to analyze and debug Tweens. The Tween Inspector can be found in the Window menu under the Analysis category. 91 | 92 | ![Tween Inspector Window](https://raw.githubusercontent.com/jeffreylanters/unity-tweens/master/.github/WIKI/tween-inspector.png) 93 | 94 | These 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. 95 | 96 | Happy Tweening! 97 | 98 | ## Tween Types 99 | 100 | To 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. 101 | 102 | ### Transform 103 | 104 | The 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`. 105 | 106 | ### Rect Transform 107 | 108 | The following Tween Types can be used to alter values of a Rect Transform Component; `AnchoredPositionTween`, `AnchoredPositionXTween`, `AnchoredPositionYTween`, `AnchorMinTween`, `AnchorMaxTween`. 109 | 110 | ### Sprite Renderer 111 | 112 | The following Tween Types can be used to alter values of a Sprite Renderer Component; `SpriteRendererAlphaTween`, `SpriteRendererColorTween`. 113 | 114 | ### Image 115 | 116 | The 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`. 117 | 118 | ### Graphic 119 | 120 | The 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`. 121 | 122 | ### Audio Source 123 | 124 | The following Tween Types can be used to alter values of an Audio Source Component; `AudioSourceVolumeTween`, `AudioSourcePitchTween`, `AudioSourcePanTween`, `AudioSourcePriorityTween`, `AudioSourceReverbZoneMixTween`, `AudioSourceSpatialBlendTween`. 125 | 126 | ### Light 127 | 128 | The following Tween Types can be used to alter values of a Light Component; `LightColorTween`, `LightIntensityTween`, `LightRangeTween`, `LightSpotAngleTween`. 129 | 130 | ### Generic 131 | 132 | The following Tween Types can be used to alter values of any property; `FloatTween`, `Vector2Tween`, `Vector3Tween`, `Vector4Tween`, `ColorTween`, `QuaternionTween`, `RectTween`. 133 | 134 | ## Tween Options 135 | 136 | While 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. 137 | 138 | ### From 139 | 140 | The 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. 141 | 142 | ```cs 143 | DataType from; 144 | ``` 145 | 146 | ```cs 147 | var tween = new ExampleTween { 148 | from = new Vector3(10, 5, 20), 149 | }; 150 | ``` 151 | 152 | ### To 153 | 154 | The 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. 155 | 156 | ```cs 157 | DataType to; 158 | ``` 159 | 160 | ```cs 161 | var tween = new ExampleTween { 162 | to = new Vector3(10, 5, 20), 163 | }; 164 | ``` 165 | 166 | ### Duration 167 | 168 | The 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. 169 | 170 | ```cs 171 | float duration; 172 | ``` 173 | 174 | ```cs 175 | var tween = new ExampleTween { 176 | duration = 5, 177 | }; 178 | ``` 179 | 180 | ### Delay 181 | 182 | The 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. 183 | 184 | ```cs 185 | float delay; 186 | ``` 187 | 188 | ```cs 189 | var tween = new ExampleTween { 190 | delay = 5, 191 | }; 192 | ``` 193 | 194 | ### Loops 195 | 196 | The 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. 197 | 198 | ```cs 199 | int loops; 200 | ``` 201 | 202 | ```cs 203 | var tween = new ExampleTween { 204 | loops = 5, 205 | }; 206 | ``` 207 | 208 | ### Infinite 209 | 210 | The 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. 211 | 212 | ```cs 213 | bool isInfinite; 214 | ``` 215 | 216 | ```cs 217 | var tween = new ExampleTween { 218 | isInfinite = true, 219 | }; 220 | ``` 221 | 222 | ### Ping Pong 223 | 224 | The 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. 225 | 226 | ```cs 227 | bool usePingPong; 228 | ``` 229 | 230 | ```cs 231 | var tween = new ExampleTween { 232 | usePingPong = true, 233 | }; 234 | ``` 235 | 236 | ### Ping Pong Interval 237 | 238 | The 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. 239 | 240 | ```cs 241 | float pingPongInterval; 242 | ``` 243 | 244 | ```cs 245 | var tween = new ExampleTween { 246 | pingPongInterval = 5, 247 | }; 248 | ``` 249 | 250 | ### Repeat Interval 251 | 252 | The 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. 253 | 254 | ```cs 255 | float repeatInterval; 256 | ``` 257 | 258 | ```cs 259 | var tween = new ExampleTween { 260 | repeatInterval = 5, 261 | }; 262 | ``` 263 | 264 | ### Offset 265 | 266 | The offset defines on which time the Tween will start. When the offset is not set, the Tween will start at the beginning. 267 | 268 | ```cs 269 | float offset; 270 | ``` 271 | 272 | ```cs 273 | var tween = new ExampleTween { 274 | offset = 5, 275 | }; 276 | ``` 277 | 278 | ### Ease Type 279 | 280 | The 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. 281 | 282 | The 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`. 283 | 284 | ```cs 285 | EaseType easeType; 286 | ``` 287 | 288 | ```cs 289 | var tween = new ExampleTween { 290 | easeType = EaseType.QuadInOut, 291 | }; 292 | ``` 293 | 294 | ### Animation Curve 295 | 296 | The 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). 297 | 298 | ```cs 299 | AnimationCurve animationCurve; 300 | ``` 301 | 302 | ```cs 303 | var tween = new ExampleTween { 304 | animationCurve = AnimationCurve.EaseInOut(0, 0, 1, 1), 305 | }; 306 | ``` 307 | 308 | ### Use Unscaled Time 309 | 310 | The 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. 311 | 312 | ```cs 313 | bool useUnscaledTime; 314 | ``` 315 | 316 | ```cs 317 | var tween = new ExampleTween { 318 | useUnscaledTime = true, 319 | }; 320 | ``` 321 | 322 | ### Fill Mode 323 | 324 | The 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`. 325 | 326 | - `None` - The animation will not be applied before the Tween has started, and will return to its original state after the Tween has ended. 327 | - `Forward` - The animation will be applied before the Tween has started, but will return to its original state after the Tween has ended. 328 | - `Backward` - The animation will not be applied before the Tween has started, but will remain in its final state after the Tween has ended. 329 | - `Both` - The animation will be applied before the Tween has started, and will remain in its final state after the Tween has ended. 330 | 331 | ```cs 332 | FillMode fillMode; 333 | ``` 334 | 335 | ```cs 336 | var tween = new ExampleTween { 337 | fillMode = FillMode.Both, 338 | }; 339 | ``` 340 | 341 | ### On Add 342 | 343 | The on add delegate will be invoked when the Tween has been added to a GameObject. 344 | 345 | ```cs 346 | OnAddDelegate onAdd; 347 | ``` 348 | 349 | ```cs 350 | var tween = new ExampleTween { 351 | onAdd = (instance) => { 352 | Debug.Log("Tween has been added"); 353 | }, 354 | }; 355 | ``` 356 | 357 | ### On Start 358 | 359 | The on start delegate will be invoked when the Tween has started. 360 | 361 | ```cs 362 | OnStartDelegate onStart; 363 | ``` 364 | 365 | ```cs 366 | var tween = new ExampleTween { 367 | onStart = (instance) => { 368 | Debug.Log("Tween has started"); 369 | }, 370 | }; 371 | ``` 372 | 373 | ### On Update 374 | 375 | The on update delegate will be invoked when the Tween has updated. 376 | 377 | ```cs 378 | OnUpdateDelegate onUpdate; 379 | ``` 380 | 381 | ```cs 382 | var tween = new ExampleTween { 383 | onUpdate = (instance, value) => { 384 | Debug.Log("Tween has updated"); 385 | }, 386 | }; 387 | ``` 388 | 389 | ### on End 390 | 391 | The on end delegate will be invoked when the Tween has ended. 392 | 393 | ```cs 394 | OnEndDelegate onEnd; 395 | ``` 396 | 397 | ```cs 398 | var tween = new ExampleTween { 399 | onEnd = (instance) => { 400 | Debug.Log("Tween has ended"); 401 | }, 402 | }; 403 | ``` 404 | 405 | ### On Cancel 406 | 407 | The on cancel delegate will be invoked when the Tween has been cancelled. 408 | 409 | ```cs 410 | OnCancelDelegate onCancel; 411 | ``` 412 | 413 | ```cs 414 | var tween = new ExampleTween { 415 | onCancel = (instance) => { 416 | Debug.Log("Tween has been cancelled"); 417 | }, 418 | }; 419 | ``` 420 | 421 | ### On Finally 422 | 423 | The on finally delegate will be invoked when the Tween has ended or has been cancelled. 424 | 425 | ```cs 426 | OnFinallyDelegate onFinally; 427 | ``` 428 | 429 | ```cs 430 | var tween = new ExampleTween { 431 | onFinally = (instance) => { 432 | Debug.Log("Tween has ended or has been cancelled"); 433 | }, 434 | }; 435 | ``` 436 | 437 | ### Dont Invoke When Destroyed 438 | 439 | The 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. 440 | 441 | ```cs 442 | bool dontInvokeWhenDestroyed; 443 | ``` 444 | 445 | ```cs 446 | var tween = new ExampleTween { 447 | dontInvokeWhenDestroyed = true 448 | }; 449 | ``` 450 | 451 | ## Tween Instances 452 | 453 | When 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. 454 | 455 | ### Cancel 456 | 457 | The 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. 458 | 459 | ```cs 460 | void Cancel(); 461 | ``` 462 | 463 | ```cs 464 | var tween = new ExampleTween { }; 465 | var instance = gameObject.AddTween(tween); 466 | instance.Cancel(); 467 | ``` 468 | 469 | ### Is Paused 470 | 471 | The is paused property will return whether the Tween is paused while also allowing you to pause the Tween. 472 | 473 | ```cs 474 | bool isPaused; 475 | ``` 476 | 477 | ```cs 478 | var tween = new ExampleTween { }; 479 | var instance = gameObject.AddTween(tween); 480 | instance.isPaused = true; 481 | ``` 482 | 483 | ### Target 484 | 485 | The target property defines the target GameObject on which the Tween is running. 486 | 487 | ```cs 488 | readonly GameObject target; 489 | ``` 490 | 491 | ```cs 492 | var tween = new ExampleTween { }; 493 | var instance = gameObject.AddTween(tween); 494 | Debug.Log(instance.target); 495 | ``` 496 | 497 | ### Await Decommission 498 | 499 | The 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. 500 | 501 | ```cs 502 | IEnumerator AwaitDecommission(); 503 | ``` 504 | 505 | ```cs 506 | var tween = new ExampleTween { }; 507 | var instance = gameObject.AddTween(tween); 508 | yield return instance.AwaitDecommission(); 509 | ``` 510 | 511 | ### Await Decommission Async 512 | 513 | The 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. 514 | 515 | ```cs 516 | Awaitable AwaitDecommissionAsync(); 517 | ``` 518 | 519 | ```cs 520 | var tween = new ExampleTween { }; 521 | var instance = gameObject.AddTween(tween); 522 | await instance.AwaitDecommissionAsync(); 523 | ``` 524 | 525 | ## Extensions 526 | 527 | Tweens also provides extension methods that can be used to control the Tween module. 528 | 529 | ### Add Tween 530 | 531 | The 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. 532 | 533 | ```cs 534 | TweenInstance AddTween(this GameObject target, Tween tween) where ComponentType : Component; 535 | ``` 536 | 537 | ```cs 538 | var tween = new ExampleTween { }; 539 | var instance = gameObject.AddTween(tween); 540 | ``` 541 | 542 | ### Cancel Tweens 543 | 544 | The 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. 545 | 546 | ```cs 547 | void CancelTweens(this GameObject target, bool includeChildren = false); 548 | ``` 549 | 550 | ```cs 551 | gameObject.CancelTweens(); 552 | ``` 553 | 554 | ## Advanced Examples 555 | 556 | Besides 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. 557 | 558 | ### Tweening Custom Values 559 | 560 | The 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. 561 | 562 | ```cs 563 | var enemy = GetComponent(); 564 | var tween = new FloatTween { 565 | from = enemy.health, 566 | to = 23, 567 | duration = 1, 568 | easeType = EaseType.SineOut, 569 | onUpdate = (_, value) => enemy.health = value, 570 | }; 571 | enemy.gameObject.AddTween(tween); 572 | ``` 573 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 834371813d9c84f3eab8ce178dff2e09 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /RELEASE-NOTES.md: -------------------------------------------------------------------------------- 1 | - Resolved an issue where delegates will be invoked when explicitly asked not to [#46] 2 | -------------------------------------------------------------------------------- /RELEASE-NOTES.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 705d6bb8f65bc40b88691758bd5ef07c 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bca4a1f58693f42219fa6a2a6d2fff22 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/AnchorMaxTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class AnchorMaxTween : Tween { 6 | internal sealed override Vector2 Current(RectTransform component) { 7 | return component.anchorMax; 8 | } 9 | 10 | internal sealed override Vector2 Lerp(Vector2 from, Vector2 to, float time) { 11 | return Vector2.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(RectTransform component, Vector2 value) { 15 | component.anchorMax = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/AnchorMaxTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4245d7d63b286425d878d23d218b58a5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/AnchorMinTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class AnchorMinTween : Tween { 6 | internal sealed override Vector2 Current(RectTransform component) { 7 | return component.anchorMin; 8 | } 9 | 10 | internal sealed override Vector2 Lerp(Vector2 from, Vector2 to, float time) { 11 | return Vector2.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(RectTransform component, Vector2 value) { 15 | component.anchorMin = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/AnchorMinTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad5e68eee49d6418ab74603e6190873c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/AnchoredPositionTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class AnchoredPositionTween : Tween { 6 | internal sealed override Vector2 Current(RectTransform component) { 7 | return component.anchoredPosition; 8 | } 9 | 10 | internal sealed override Vector2 Lerp(Vector2 from, Vector2 to, float time) { 11 | return Vector2.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(RectTransform component, Vector2 value) { 15 | component.anchoredPosition = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/AnchoredPositionTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3bb0d580cca3a43c9a56941ffed36f5c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/AnchoredPositionXTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class AnchoredPositionXTween : Tween { 6 | internal sealed override float Current(RectTransform component) { 7 | return component.anchoredPosition.x; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(RectTransform component, float value) { 15 | var anchoredPosition = component.anchoredPosition; 16 | anchoredPosition.x = value; 17 | component.anchoredPosition = anchoredPosition; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/AnchoredPositionXTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e12e1d489d9947e7b359819a8c468c0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/AnchoredPositionYTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class AnchoredPositionYTween : Tween { 6 | internal sealed override float Current(RectTransform component) { 7 | return component.anchoredPosition.y; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(RectTransform component, float value) { 15 | var anchoredPosition = component.anchoredPosition; 16 | anchoredPosition.y = value; 17 | component.anchoredPosition = anchoredPosition; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/AnchoredPositionYTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bf553a93a4dfe4073b200be653db2478 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/AudioSourcePanTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class AudioSourcePanTween : Tween { 6 | internal sealed override float Current(AudioSource component) { 7 | return component.panStereo; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(AudioSource component, float value) { 15 | component.panStereo = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/AudioSourcePanTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d07b1428dca64e65a3322c682e0c4be 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/AudioSourcePitchTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class AudioSourcePitchTween : Tween { 6 | internal sealed override float Current(AudioSource component) { 7 | return component.pitch; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(AudioSource component, float value) { 15 | component.pitch = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/AudioSourcePitchTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ed20cae2b35a4eb28cd69fbd95d745b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/AudioSourcePriorityTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class AudioSourcePriorityTween : Tween { 6 | internal sealed override int Current(AudioSource component) { 7 | return component.priority; 8 | } 9 | 10 | internal sealed override int Lerp(int from, int to, float time) { 11 | return Mathf.RoundToInt(Mathf.LerpUnclamped(from, to, time)); 12 | } 13 | 14 | internal sealed override void Apply(AudioSource component, int value) { 15 | component.priority = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/AudioSourcePriorityTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dfd571a7a958d4fa7a5f9e85266f9aa7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/AudioSourceReverbZoneTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class AudioSourceReverbZoneMixTween : Tween { 6 | internal sealed override float Current(AudioSource component) { 7 | return component.reverbZoneMix; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(AudioSource component, float value) { 15 | component.reverbZoneMix = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/AudioSourceReverbZoneTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2fdeb5bafb83342a09e3435169b2ab8d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/AudioSourceSpatialBlendTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class AudioSourceSpatialBlendTween : Tween { 6 | internal sealed override float Current(AudioSource component) { 7 | return component.spatialBlend; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(AudioSource component, float value) { 15 | component.spatialBlend = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/AudioSourceSpatialBlendTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c42aeb76fc036445fba2f13f5ddf8683 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/AudioSourceVolumeTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class AudioSourceVolumeTween : Tween { 6 | internal sealed override float Current(AudioSource component) { 7 | return component.volume; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(AudioSource component, float value) { 15 | component.volume = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/AudioSourceVolumeTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83c535c4994ea4a0baa0ddef8a732e76 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/ColorTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class ColorTween : Tween { 6 | internal sealed override Color Current(Transform component) { 7 | return Color.clear; 8 | } 9 | 10 | internal sealed override Color Lerp(Color from, Color to, float time) { 11 | return Color.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, Color value) { } 15 | } 16 | } -------------------------------------------------------------------------------- /Runtime/ColorTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ab9672e1552247fa86d5fb830b753ab 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Core.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6726de8cf303a4cb2a806f152b9cc90a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Core/EaseFunctions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace Tweens.Core { 5 | internal static class EaseFunctions { 6 | const float ConstantA = 1.70158f; 7 | const float ConstantB = ConstantA * 1.525f; 8 | const float ConstantC = ConstantA + 1f; 9 | const float ConstantD = 2f * Mathf.PI / 3f; 10 | const float ConstantE = 2f * Mathf.PI / 4.5f; 11 | const float ConstantF = 7.5625f; 12 | const float ConstantG = 2.75f; 13 | 14 | internal static EaseFunctionDelegate GetFunction(EaseType easeType) { 15 | return easeType switch { 16 | EaseType.Linear => Linear, 17 | EaseType.SineIn => SineIn, 18 | EaseType.SineOut => SineOut, 19 | EaseType.SineInOut => SineInOut, 20 | EaseType.QuadIn => QuadIn, 21 | EaseType.QuadOut => QuadOut, 22 | EaseType.QuadInOut => QuadInOut, 23 | EaseType.CubicIn => CubicIn, 24 | EaseType.CubicOut => CubicOut, 25 | EaseType.CubicInOut => CubicInOut, 26 | EaseType.QuartIn => QuartIn, 27 | EaseType.QuartOut => QuartOut, 28 | EaseType.QuartInOut => QuartInOut, 29 | EaseType.QuintIn => QuintIn, 30 | EaseType.QuintOut => QuintOut, 31 | EaseType.QuintInOut => QuintInOut, 32 | EaseType.ExpoIn => ExpoIn, 33 | EaseType.ExpoOut => ExpoOut, 34 | EaseType.ExpoInOut => ExpoInOut, 35 | EaseType.CircIn => CircIn, 36 | EaseType.CircOut => CircOut, 37 | EaseType.CircInOut => CircInOut, 38 | EaseType.BackIn => BackIn, 39 | EaseType.BackOut => BackOut, 40 | EaseType.BackInOut => BackInOut, 41 | EaseType.ElasticIn => ElasticIn, 42 | EaseType.ElasticOut => ElasticOut, 43 | EaseType.ElasticInOut => ElasticInOut, 44 | EaseType.BounceIn => BounceIn, 45 | EaseType.BounceOut => BounceOut, 46 | EaseType.BounceInOut => BounceInOut, 47 | _ => throw new NotImplementedException($"EaseType {easeType} not implemented"), 48 | }; 49 | } 50 | 51 | static float Linear(float time) { 52 | return time; 53 | } 54 | 55 | static float SineIn(float time) { 56 | return 1f - Mathf.Cos((time * Mathf.PI) / 2f); 57 | } 58 | 59 | static float SineOut(float time) { 60 | return Mathf.Sin((time * Mathf.PI) / 2f); 61 | } 62 | 63 | static float SineInOut(float time) { 64 | return -(Mathf.Cos(Mathf.PI * time) - 1f) / 2f; 65 | } 66 | 67 | static float QuadIn(float time) { 68 | return time * time; 69 | } 70 | 71 | static float QuadOut(float time) { 72 | return 1 - (1 - time) * (1 - time); 73 | } 74 | 75 | static float QuadInOut(float time) { 76 | return time < 0.5f ? 2 * time * time : 1 - Mathf.Pow(-2 * time + 2, 2) / 2; 77 | } 78 | 79 | static float CubicIn(float time) { 80 | return time * time * time; 81 | } 82 | 83 | static float CubicOut(float time) { 84 | return 1 - Mathf.Pow(1 - time, 3); 85 | } 86 | 87 | static float CubicInOut(float time) { 88 | return time < 0.5f ? 4 * time * time * time : 1 - Mathf.Pow(-2 * time + 2, 3) / 2; 89 | } 90 | 91 | static float QuartIn(float time) { 92 | return time * time * time * time; 93 | } 94 | 95 | static float QuartOut(float time) { 96 | return 1 - Mathf.Pow(1 - time, 4); 97 | } 98 | 99 | static float QuartInOut(float time) { 100 | return time < 0.5 ? 8 * time * time * time * time : 1 - Mathf.Pow(-2 * time + 2, 4) / 2; 101 | } 102 | 103 | static float QuintIn(float time) { 104 | return time * time * time * time * time; 105 | } 106 | 107 | static float QuintOut(float time) { 108 | return 1 - Mathf.Pow(1 - time, 5); 109 | } 110 | 111 | static float QuintInOut(float time) { 112 | return time < 0.5f ? 16 * time * time * time * time * time : 1 - Mathf.Pow(-2 * time + 2, 5) / 2; 113 | } 114 | 115 | static float ExpoIn(float time) { 116 | return time == 0 ? 0 : Mathf.Pow(2, 10 * time - 10); 117 | } 118 | 119 | static float ExpoOut(float time) { 120 | return time == 1 ? 1 : 1 - Mathf.Pow(2, -10 * time); 121 | } 122 | 123 | static float ExpoInOut(float time) { 124 | return time == 0 ? 0 : time == 1 ? 1 : time < 0.5 ? Mathf.Pow(2, 20 * time - 10) / 2 : (2 - Mathf.Pow(2, -20 * time + 10)) / 2; 125 | } 126 | 127 | static float CircIn(float time) { 128 | return 1 - Mathf.Sqrt(1 - Mathf.Pow(time, 2)); 129 | } 130 | 131 | static float CircOut(float time) { 132 | return Mathf.Sqrt(1 - Mathf.Pow(time - 1, 2)); 133 | } 134 | 135 | static float CircInOut(float time) { 136 | return time < 0.5 ? (1 - Mathf.Sqrt(1 - Mathf.Pow(2 * time, 2))) / 2 : (Mathf.Sqrt(1 - Mathf.Pow(-2 * time + 2, 2)) + 1) / 2; 137 | } 138 | 139 | static float BackIn(float time) { 140 | return ConstantC * time * time * time - ConstantA * time * time; 141 | } 142 | 143 | static float BackOut(float time) { 144 | return 1f + ConstantC * Mathf.Pow(time - 1, 3) + ConstantA * Mathf.Pow(time - 1, 2); 145 | } 146 | 147 | static float BackInOut(float time) { 148 | return time < 0.5 ? 149 | Mathf.Pow(2 * time, 2) * ((ConstantB + 1) * 2 * time - ConstantB) / 2 : 150 | (Mathf.Pow(2 * time - 2, 2) * ((ConstantB + 1) * (time * 2 - 2) + ConstantB) + 2) / 2; 151 | } 152 | 153 | static float ElasticIn(float time) { 154 | return time == 0 ? 0 : time == 1 ? 1 : -Mathf.Pow(2, 10 * time - 10) * Mathf.Sin((time * 10f - 10.75f) * ConstantD); 155 | } 156 | 157 | static float ElasticOut(float time) { 158 | return time == 0 ? 0 : time == 1 ? 1 : Mathf.Pow(2, -10 * time) * Mathf.Sin((time * 10 - 0.75f) * ConstantD) + 1; 159 | } 160 | 161 | static float ElasticInOut(float time) { 162 | return time == 0 ? 0 : time == 1 ? 1 : time < 0.5 ? -(Mathf.Pow(2, 20 * time - 10) * Mathf.Sin((20 * time - 11.125f) * ConstantE)) / 2 : Mathf.Pow(2, -20 * time + 10) * Mathf.Sin((20 * time - 11.125f) * ConstantE) / 2 + 1; 163 | } 164 | 165 | static float BounceIn(float time) { 166 | return 1 - BounceOut(1 - time); 167 | } 168 | 169 | static float BounceOut(float time) { 170 | if (time < 1 / ConstantG) 171 | return ConstantF * time * time; 172 | else if (time < 2 / ConstantG) 173 | return ConstantF * (time -= 1.5f / ConstantG) * time + 0.75f; 174 | else if (time < 2.5f / ConstantG) 175 | return ConstantF * (time -= 2.25f / ConstantG) * time + 0.9375f; 176 | else 177 | return ConstantF * (time -= 2.625f / ConstantG) * time + 0.984375f; 178 | } 179 | 180 | static float BounceInOut(float time) { 181 | return time < 0.5f ? (1 - BounceOut(1 - 2 * time)) / 2 : (1 + BounceOut(2 * time - 1)) / 2; 182 | } 183 | } 184 | } -------------------------------------------------------------------------------- /Runtime/Core/EaseFunctions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c7d87561bd2748bd8330a970de5222f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Core/Nullable.cs: -------------------------------------------------------------------------------- 1 | namespace Tweens.Core { 2 | public class Nullable { 3 | internal Type Value { get; private set; } 4 | internal bool HasValue { get; private set; } 5 | 6 | internal Nullable() { } 7 | 8 | internal Nullable(Type value) { 9 | Value = value; 10 | HasValue = true; 11 | } 12 | 13 | internal Nullable(Nullable nullable) { 14 | Value = nullable.Value; 15 | HasValue = nullable.HasValue; 16 | } 17 | 18 | internal void Unset() { 19 | Value = default; 20 | HasValue = false; 21 | } 22 | 23 | public static implicit operator Type(Nullable test) { 24 | return test.Value; 25 | } 26 | 27 | public static implicit operator Nullable(Type value) { 28 | return new Nullable { Value = value, HasValue = true }; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Runtime/Core/Nullable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 97aa60efc6a9f4cfb9ce802d45b7005b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Core/Tween.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Tweens.Core { 4 | public abstract class Tween { 5 | /// The 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. 6 | public float duration; 7 | /// The 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. When the delay is not set, the Tween will start instantly. 8 | public float? delay; 9 | /// The 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. 10 | public float? pingPongInterval; 11 | /// The 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. 12 | public float? repeatInterval; 13 | /// The 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. 14 | public bool useUnscaledTime; 15 | /// The 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. 16 | public bool usePingPong; 17 | /// The infinite option defines whether the Tween will loop forever. When the Tween is set to loop forever, the Loops option will be ignored. When the infinite option is not set, the Tween will not loop forever. 18 | public bool isInfinite; 19 | /// The amount of times the Tween will loop defines how many times the Tween will repeat itself. When the Tween is using a Ping Pong loop type, the Tween has to play both the forward and backward animation to count as one loop. When 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. 20 | public int? loops; 21 | /// The offset defines on which time the Tween will start. When the offset is not set, the Tween will start at the beginning. 22 | public float? offset; 23 | /// The ease type defines how the Tween will animate. If an Animation Curve is set, the Ease Type won't be used. When the ease type is not set, the Tween will animate linearly. 24 | public EaseType easeType; 25 | /// The 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. 26 | public FillMode fillMode = FillMode.Backwards; 27 | /// The 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. 28 | public AnimationCurve animationCurve; 29 | /// The 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. 30 | public bool dontInvokeWhenDestroyed; 31 | } 32 | 33 | public abstract class Tween : Tween where ComponentType : Component { 34 | /// The 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. 35 | public Nullable from; 36 | /// The 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. 37 | public Nullable to; 38 | /// The on add delegate will be invoked when the Tween has been added to a GameObject. 39 | public OnAddDelegate onAdd; 40 | /// The on start delegate will be invoked when the Tween has started. 41 | public OnStartDelegate onStart; 42 | /// The on update delegate will be invoked when the Tween has updated. 43 | public OnUpdateDelegate onUpdate; 44 | /// The on end delegate will be invoked when the Tween has ended. 45 | public OnEndDelegate onEnd; 46 | /// The on cancel delegate will be invoked when the Tween has been cancelled. 47 | public OnCancelDelegate onCancel; 48 | /// The on finally delegate will be invoked when the Tween has ended or has been cancelled. 49 | public OnFinallyDelegate onFinally; 50 | 51 | internal abstract DataType Current(ComponentType component); 52 | internal abstract DataType Lerp(DataType from, DataType to, float time); 53 | internal abstract void Apply(ComponentType component, DataType value); 54 | } 55 | } -------------------------------------------------------------------------------- /Runtime/Core/Tween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f748a0935feb14400a02bab6f42c6c1d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Core/TweenEngine.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | namespace Tweens.Core { 5 | static class TweenEngine { 6 | readonly internal static List instances = new(); 7 | 8 | [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] 9 | internal static void Initialize() { 10 | Object.DontDestroyOnLoad(new GameObject("TweenBehaviour").AddComponent()); 11 | } 12 | 13 | class TweenBehaviour : MonoBehaviour { 14 | void LateUpdate() => Update(); 15 | void OnDestroy() => instances.Clear(); 16 | } 17 | 18 | internal static void Update() { 19 | for (var i = 0; i < instances.Count; i += 1) { 20 | var instance = instances[i]; 21 | if (instance.isDecommissioned) { 22 | instances.Remove(instance); 23 | i -= 1; 24 | continue; 25 | } 26 | instance.Update(); 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Runtime/Core/TweenEngine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99e272aeefa514254a49a42dab4a9f00 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Delegates.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Tweens { 4 | internal delegate DataType LerpDelegate(DataType from, DataType to, float time); 5 | internal delegate void ApplyDelegate(ComponentType component, DataType value); 6 | internal delegate float EaseFunctionDelegate(float time); 7 | public delegate void OnUpdateDelegate(TweenInstance instance, DataType value) where ComponentType : Component; 8 | public delegate void OnAddDelegate(TweenInstance instance) where ComponentType : Component; 9 | public delegate void OnStartDelegate(TweenInstance instance) where ComponentType : Component; 10 | public delegate void OnEndDelegate(TweenInstance instance) where ComponentType : Component; 11 | public delegate void OnCancelDelegate(TweenInstance instance) where ComponentType : Component; 12 | public delegate void OnFinallyDelegate(TweenInstance instance) where ComponentType : Component; 13 | } -------------------------------------------------------------------------------- /Runtime/Delegates.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1093d63847ee646f1ab006049bbb7fc0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/EaseType.cs: -------------------------------------------------------------------------------- 1 | namespace Tweens { 2 | public enum EaseType { 3 | Linear = 0, 4 | SineIn = 10, 5 | SineOut = 11, 6 | SineInOut = 12, 7 | QuadIn = 20, 8 | QuadOut = 21, 9 | QuadInOut = 22, 10 | CubicIn = 30, 11 | CubicOut = 31, 12 | CubicInOut = 32, 13 | QuartIn = 40, 14 | QuartOut = 41, 15 | QuartInOut = 42, 16 | QuintIn = 50, 17 | QuintOut = 51, 18 | QuintInOut = 52, 19 | ExpoIn = 60, 20 | ExpoOut = 61, 21 | ExpoInOut = 62, 22 | CircIn = 70, 23 | CircOut = 71, 24 | CircInOut = 72, 25 | BackIn = 80, 26 | BackOut = 81, 27 | BackInOut = 82, 28 | ElasticIn = 90, 29 | ElasticOut = 91, 30 | ElasticInOut = 92, 31 | BounceIn = 100, 32 | BounceOut = 101, 33 | BounceInOut = 102, 34 | } 35 | } -------------------------------------------------------------------------------- /Runtime/EaseType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa2af596656b54e9a854312de6040cd6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/EulerAnglesTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class EulerAnglesTween : Tween { 6 | internal sealed override Vector3 Current(Transform component) { 7 | return component.eulerAngles; 8 | } 9 | 10 | internal sealed override Vector3 Lerp(Vector3 from, Vector3 to, float time) { 11 | return Vector3.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, Vector3 value) { 15 | component.eulerAngles = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/EulerAnglesTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53921f5599ed7457b9311dcb38b7a8d2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/EulerAnglesXTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class EulerAnglesXTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return component.eulerAngles.x; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { 15 | var eulerAngles = component.eulerAngles; 16 | eulerAngles.x = value; 17 | component.eulerAngles = eulerAngles; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/EulerAnglesXTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1aeea36e496b04b35a1efaeee2701fa2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/EulerAnglesYTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class EulerAnglesYTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return component.eulerAngles.y; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { 15 | var eulerAngles = component.eulerAngles; 16 | eulerAngles.y = value; 17 | component.eulerAngles = eulerAngles; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/EulerAnglesYTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 621edabea416440bda987760f3746cbc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/EulerAnglesZTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class EulerAnglesZTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return component.eulerAngles.z; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { 15 | var eulerAngles = component.eulerAngles; 16 | eulerAngles.z = value; 17 | component.eulerAngles = eulerAngles; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/EulerAnglesZTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26eb8f4c97ac3484da32ae4ea3b1c50f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/FillMode.cs: -------------------------------------------------------------------------------- 1 | namespace Tweens { 2 | public enum FillMode { 3 | /// The animation will not be applied before the Tween has started, and will return to its original state after the Tween has ended. 4 | None, 5 | /// The animation will be applied before the Tween has started, but will return to its original state after the Tween has ended. 6 | Forwards, 7 | /// The animation will not be applied before the Tween has started, but will remain in its final state after the Tween has ended. 8 | Backwards, 9 | /// The animation will be applied before the Tween has started, and will remain in its final state after the Tween has ended. 10 | Both, 11 | } 12 | } -------------------------------------------------------------------------------- /Runtime/FillMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 841202a98ca594a7294e776a38bcdb5f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/FloatTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class FloatTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return 0; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { } 15 | } 16 | } -------------------------------------------------------------------------------- /Runtime/FloatTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a55d8fd8530f4300891f1d72e2e62d1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/GraphicAlphaTween.cs: -------------------------------------------------------------------------------- 1 | #if TWEENS_DEFINED_COM_UNITY_UGUI 2 | using Tweens.Core; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | namespace Tweens { 7 | public sealed class GraphicAlphaTween : Tween { 8 | internal sealed override float Current(Graphic component) { 9 | return component.color.a; 10 | } 11 | 12 | internal sealed override float Lerp(float from, float to, float time) { 13 | return Mathf.LerpUnclamped(from, to, time); 14 | } 15 | 16 | internal sealed override void Apply(Graphic component, float value) { 17 | var color = component.color; 18 | color.a = value; 19 | component.color = color; 20 | } 21 | } 22 | } 23 | #endif -------------------------------------------------------------------------------- /Runtime/GraphicAlphaTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 705b5115e2f514c509404e89261ef672 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/GraphicColorTween.cs: -------------------------------------------------------------------------------- 1 | #if TWEENS_DEFINED_COM_UNITY_UGUI 2 | using Tweens.Core; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | namespace Tweens { 7 | public sealed class GraphicColorTween : Tween { 8 | internal sealed override Color Current(Graphic component) { 9 | return component.color; 10 | } 11 | 12 | internal sealed override Color Lerp(Color from, Color to, float time) { 13 | return Color.LerpUnclamped(from, to, time); 14 | } 15 | 16 | internal sealed override void Apply(Graphic component, Color value) { 17 | component.color = value; 18 | } 19 | } 20 | } 21 | #endif -------------------------------------------------------------------------------- /Runtime/GraphicColorTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e91be354d91c74d0a812521dbe0c9920 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/ImageFillAmountTween.cs: -------------------------------------------------------------------------------- 1 | #if TWEENS_DEFINED_COM_UNITY_UGUI 2 | using Tweens.Core; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | namespace Tweens { 7 | public sealed class ImageFillAmountTween : Tween { 8 | internal sealed override float Current(Image component) { 9 | return component.fillAmount; 10 | } 11 | 12 | internal sealed override float Lerp(float from, float to, float time) { 13 | return Mathf.LerpUnclamped(from, to, time); 14 | } 15 | 16 | internal sealed override void Apply(Image component, float value) { 17 | component.fillAmount = value; 18 | } 19 | } 20 | } 21 | #endif -------------------------------------------------------------------------------- /Runtime/ImageFillAmountTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9980a9d094f724d2992e4f4e233a74a9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LightColorTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LightColorTween : Tween { 6 | internal sealed override Color Current(Light component) { 7 | return component.color; 8 | } 9 | 10 | internal sealed override Color Lerp(Color from, Color to, float time) { 11 | return Color.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Light component, Color value) { 15 | component.color = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/LightColorTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 27667b4ef266441eb848234bdb97f840 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LightIntensityTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LightIntensityTween : Tween { 6 | internal sealed override float Current(Light component) { 7 | return component.intensity; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Light component, float value) { 15 | component.intensity = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/LightIntensityTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81bc8588c143242bc98918534e730585 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LightRangeTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LightRangeTween : Tween { 6 | internal sealed override float Current(Light component) { 7 | return component.range; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Light component, float value) { 15 | component.range = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/LightRangeTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b594b7c45e5854ce9a08727b8e1fbc1f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LightSpotAngleTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LightSpotAngleTween : Tween { 6 | internal sealed override float Current(Light component) { 7 | return component.spotAngle; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Light component, float value) { 15 | component.spotAngle = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/LightSpotAngleTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44de095f06a654d18a0f25d8b095a9eb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LocalEulerAnglesTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LocalEulerAnglesTween : Tween { 6 | internal sealed override Vector3 Current(Transform component) { 7 | return component.localEulerAngles; 8 | } 9 | 10 | internal sealed override Vector3 Lerp(Vector3 from, Vector3 to, float time) { 11 | return Vector3.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, Vector3 value) { 15 | component.localEulerAngles = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/LocalEulerAnglesTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76fa9dd971440421faca4c9be4a41be8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LocalEulerAnglesXTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LocalEulerAnglesXTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return component.localEulerAngles.x; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { 15 | var localEulerAngles = component.localEulerAngles; 16 | localEulerAngles.x = value; 17 | component.localEulerAngles = localEulerAngles; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/LocalEulerAnglesXTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 573e638ce7e544baaa2e08c9ff7d5bba 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LocalEulerAnglesYTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LocalEulerAnglesYTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return component.localEulerAngles.y; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { 15 | var localEulerAngles = component.localEulerAngles; 16 | localEulerAngles.y = value; 17 | component.localEulerAngles = localEulerAngles; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/LocalEulerAnglesYTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8aa155e19f47b46b993d88032977ae0f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LocalEulerAnglesZTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LocalEulerAnglesZTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return component.localEulerAngles.z; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { 15 | var localEulerAngles = component.localEulerAngles; 16 | localEulerAngles.z = value; 17 | component.localEulerAngles = localEulerAngles; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/LocalEulerAnglesZTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49361e6a976e241b48be8bba9bcbdc2e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LocalPositionTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LocalPositionTween : Tween { 6 | internal sealed override Vector3 Current(Transform component) { 7 | return component.localPosition; 8 | } 9 | 10 | internal sealed override Vector3 Lerp(Vector3 from, Vector3 to, float time) { 11 | return Vector3.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, Vector3 value) { 15 | component.localPosition = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/LocalPositionTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9651fd684f7794843bdaab4f3660f288 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LocalPositionXTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LocalPositionXTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return component.localPosition.x; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { 15 | var localPosition = component.localPosition; 16 | localPosition.x = value; 17 | component.localPosition = localPosition; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/LocalPositionXTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73979a11202cd4e64b7fef9928580425 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LocalPositionYTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LocalPositionYTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return component.localPosition.y; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { 15 | var localPosition = component.localPosition; 16 | localPosition.y = value; 17 | component.localPosition = localPosition; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/LocalPositionYTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8eb3081d5f154f04bf4ee8e29e137a7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LocalPositionZTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LocalPositionZTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return component.localPosition.z; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { 15 | var localPosition = component.localPosition; 16 | localPosition.z = value; 17 | component.localPosition = localPosition; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/LocalPositionZTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf2ac0b9beace474db11fa04fd9eb98b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LocalRotationTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LocalRotationTween : Tween { 6 | internal sealed override Quaternion Current(Transform component) { 7 | return component.localRotation; 8 | } 9 | 10 | internal sealed override Quaternion Lerp(Quaternion from, Quaternion to, float time) { 11 | return Quaternion.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, Quaternion value) { 15 | component.localRotation = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/LocalRotationTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea46d9bdf41f24b41a54c123ce154557 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LocalScaleTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LocalScaleTween : Tween { 6 | internal sealed override Vector3 Current(Transform component) { 7 | return component.localScale; 8 | } 9 | 10 | internal sealed override Vector3 Lerp(Vector3 from, Vector3 to, float time) { 11 | return Vector3.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, Vector3 value) { 15 | component.localScale = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/LocalScaleTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae83fd2b9609e48979ac0baaa63336af 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LocalScaleXTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LocalScaleXTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return component.localScale.x; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { 15 | var localScale = component.localScale; 16 | localScale.x = value; 17 | component.localScale = localScale; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/LocalScaleXTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 585249d6cdc7f48dbab86f4f3deaaef7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LocalScaleYTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LocalScaleYTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return component.localScale.y; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { 15 | var localScale = component.localScale; 16 | localScale.y = value; 17 | component.localScale = localScale; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/LocalScaleYTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db54a728ab9c3432d8068361b8801b56 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/LocalScaleZTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class LocalScaleZTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return component.localScale.z; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { 15 | var localScale = component.localScale; 16 | localScale.z = value; 17 | component.localScale = localScale; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/LocalScaleZTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6695e1b64869b44b5ae2025090e91e0e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/PositionTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class PositionTween : Tween { 6 | internal sealed override Vector3 Current(Transform component) { 7 | return component.position; 8 | } 9 | 10 | internal sealed override Vector3 Lerp(Vector3 from, Vector3 to, float time) { 11 | return Vector3.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, Vector3 value) { 15 | component.position = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/PositionTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bfb1662453fc04c7ba455130cbaf8003 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/PositionXTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class PositionXTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return component.position.x; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { 15 | var position = component.position; 16 | position.x = value; 17 | component.position = position; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/PositionXTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ccc484e8bf1f48eeba3b29486cc94d5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/PositionYTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class PositionYTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return component.position.y; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { 15 | var position = component.position; 16 | position.y = value; 17 | component.position = position; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/PositionYTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 11ff018407e124b82badc8055b7e0f59 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/PositionZTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class PositionZTween : Tween { 6 | internal sealed override float Current(Transform component) { 7 | return component.position.z; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, float value) { 15 | var position = component.position; 16 | position.z = value; 17 | component.position = position; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/PositionZTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 257c288cdfd9046a9935abf43f25acf4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/QuaternionTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class QuaternionTween : Tween { 6 | internal sealed override Quaternion Current(Transform component) { 7 | return Quaternion.identity; 8 | } 9 | 10 | internal sealed override Quaternion Lerp(Quaternion from, Quaternion to, float time) { 11 | return Quaternion.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, Quaternion value) { } 15 | } 16 | } -------------------------------------------------------------------------------- /Runtime/QuaternionTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb8bcf9f6a8764810a0f9b0b005c96f5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/RectTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class RectTween : Tween { 6 | internal sealed override Rect Current(Transform component) { 7 | return Rect.zero; 8 | } 9 | 10 | internal sealed override Rect Lerp(Rect from, Rect to, float time) { 11 | var x = Mathf.LerpUnclamped(from.x, to.x, time); 12 | var y = Mathf.LerpUnclamped(from.y, to.y, time); 13 | var width = Mathf.LerpUnclamped(from.width, to.width, time); 14 | var height = Mathf.LerpUnclamped(from.height, to.height, time); 15 | return new Rect(x, y, width, height); 16 | } 17 | 18 | internal sealed override void Apply(Transform component, Rect value) { } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/RectTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a417cc844f08040c983471cdd411935f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/RotationTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class RotationTween : Tween { 6 | internal sealed override Quaternion Current(Transform component) { 7 | return component.rotation; 8 | } 9 | 10 | internal sealed override Quaternion Lerp(Quaternion from, Quaternion to, float time) { 11 | return Quaternion.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, Quaternion value) { 15 | component.rotation = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/RotationTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b41646e508c0c473b8c10e24d0c869a9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/SpriteRendererAlphaTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class SpriteRendererAlphaTween : Tween { 6 | internal sealed override float Current(SpriteRenderer component) { 7 | return component.color.a; 8 | } 9 | 10 | internal sealed override float Lerp(float from, float to, float time) { 11 | return Mathf.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(SpriteRenderer component, float value) { 15 | var color = component.color; 16 | color.a = value; 17 | component.color = color; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Runtime/SpriteRendererAlphaTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d814ee7d04a9543048d2e4ed7ebe8972 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/SpriteRendererColorTween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class SpriteRendererColorTween : Tween { 6 | internal sealed override Color Current(SpriteRenderer component) { 7 | return component.color; 8 | } 9 | 10 | internal sealed override Color Lerp(Color from, Color to, float time) { 11 | return Color.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(SpriteRenderer component, Color value) { 15 | component.color = value; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Runtime/SpriteRendererColorTween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1446c029d1aaa455e8ef3f27aaa7349b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/TweenExtension.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Tweens.Core; 3 | 4 | namespace Tweens { 5 | public static class TweenExtension { 6 | public static TweenInstance AddTween(this GameObject target, Tween tween) where ComponentType : Component { 7 | var instance = new TweenInstance(target, tween); 8 | TweenEngine.instances.Add(instance); 9 | return instance; 10 | } 11 | 12 | public static TweenInstance[] AddTween(this GameObject target, Tween tween1, Tween tween2) where ComponentType1 : Component where ComponentType2 : Component { 13 | var instances = new TweenInstance[] { 14 | new TweenInstance(target, tween1), 15 | new TweenInstance(target, tween2), 16 | }; 17 | TweenEngine.instances.AddRange(instances); 18 | return instances; 19 | } 20 | 21 | public static TweenInstance[] AddTween(this GameObject target, Tween tween1, Tween tween2, Tween tween3) where ComponentType1 : Component where ComponentType2 : Component where ComponentType3 : Component { 22 | var instances = new TweenInstance[] { 23 | new TweenInstance(target, tween1), 24 | new TweenInstance(target, tween2), 25 | new TweenInstance(target, tween3), 26 | }; 27 | TweenEngine.instances.AddRange(instances); 28 | return instances; 29 | } 30 | 31 | public static GameObject CancelTweens(this GameObject target, bool includeChildren = false) { 32 | var instances = TweenEngine.instances.FindAll(instance => { 33 | if (instance.target == target) { 34 | return true; 35 | } 36 | if (includeChildren) { 37 | return instance.target.transform.IsChildOf(target.transform); 38 | } 39 | return false; 40 | }); 41 | foreach (var instance in instances) { 42 | instance.Cancel(); 43 | } 44 | return target; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Runtime/TweenExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d35bdae7dd9ba433291558403dad6112 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/TweenInstance.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using Tweens.Core; 3 | using System.Collections; 4 | 5 | namespace Tweens { 6 | public abstract class TweenInstance { 7 | readonly internal float duration; 8 | readonly internal float? pingPongInterval; 9 | readonly internal float? repeatInterval; 10 | readonly internal bool useUnscaledTime; 11 | readonly internal bool usePingPong; 12 | readonly internal FillMode fillMode = FillMode.Backwards; 13 | internal float? haltTime; 14 | internal int? loops; 15 | internal bool isDecommissioned; 16 | internal float time; 17 | internal bool dontInvokeWhenDestroyed; 18 | internal bool isForwards = true; 19 | internal bool didReachEnd; 20 | internal EaseFunctionDelegate easeFunction; 21 | /// The target property defines the target GameObject on which the Tween is running. 22 | readonly public GameObject target; 23 | /// The is paused property will return whether the Tween is paused while also allowing you to pause the Tween. 24 | public bool isPaused; 25 | #if UNITY_EDITOR 26 | readonly internal string @tweenTypeName; 27 | #endif 28 | 29 | internal abstract void Update(); 30 | /// The cancel method will cancel the Tween. When the Tween is cancelled, the OnCancel and OnFinally delegates will be invoked. 31 | public abstract void Cancel(); 32 | 33 | internal TweenInstance(GameObject target, Tween tween) { 34 | this.target = target; 35 | duration = tween.duration > 0 ? tween.duration : 0.001f; 36 | pingPongInterval = tween.pingPongInterval; 37 | repeatInterval = tween.repeatInterval; 38 | useUnscaledTime = tween.useUnscaledTime; 39 | usePingPong = tween.usePingPong; 40 | fillMode = tween.fillMode; 41 | time = tween.offset ?? 0; 42 | dontInvokeWhenDestroyed = tween.dontInvokeWhenDestroyed; 43 | #if UNITY_EDITOR 44 | @tweenTypeName = tween.GetType().Name; 45 | #endif 46 | } 47 | } 48 | 49 | public class TweenInstance : TweenInstance where ComponentType : Component { 50 | readonly ComponentType component; 51 | readonly OnAddDelegate onAdd; 52 | OnStartDelegate onStart; 53 | readonly OnUpdateDelegate onUpdate; 54 | readonly OnEndDelegate onEnd; 55 | internal OnCancelDelegate onCancel; 56 | internal OnFinallyDelegate onFinally; 57 | readonly ApplyDelegate apply; 58 | readonly LerpDelegate lerp; 59 | readonly DataType initial; 60 | readonly DataType from; 61 | readonly DataType to; 62 | 63 | internal TweenInstance(GameObject target, Tween tween) : base(target, tween) { 64 | component = target.GetComponent(); 65 | initial = tween.Current(component); 66 | from = tween.from != null ? tween.from : tween.Current(component); 67 | to = tween.to != null ? tween.to : tween.Current(component); 68 | onStart = tween.onStart; 69 | onAdd = tween.onAdd; 70 | onEnd = tween.onEnd; 71 | onCancel = tween.onCancel; 72 | onFinally = tween.onFinally; 73 | haltTime = tween.delay; 74 | loops = tween.isInfinite ? -1 : tween.loops; 75 | onUpdate = tween.onUpdate; 76 | apply = tween.Apply; 77 | lerp = tween.Lerp; 78 | easeFunction = tween.animationCurve != null ? new AnimationCurve(tween.animationCurve.keys).Evaluate : EaseFunctions.GetFunction(tween.easeType); 79 | onAdd?.Invoke(this); 80 | if (haltTime > 0 && (fillMode == FillMode.Both || fillMode == FillMode.Forwards)) { 81 | apply(component, from); 82 | onUpdate?.Invoke(this, from); 83 | } 84 | } 85 | 86 | internal sealed override void Update() { 87 | if (component == null) { 88 | Cancel(); 89 | return; 90 | } 91 | if (isPaused) { 92 | return; 93 | } 94 | var deltaTime = useUnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime; 95 | if (haltTime.HasValue) { 96 | haltTime -= deltaTime; 97 | if (haltTime <= 0) { 98 | haltTime = null; 99 | } 100 | else { 101 | return; 102 | } 103 | } 104 | if (onStart != null) { 105 | onStart.Invoke(this); 106 | onStart = null; 107 | } 108 | time += isForwards ? deltaTime : -deltaTime; 109 | if (time >= duration) { 110 | time = duration; 111 | if (usePingPong) { 112 | isForwards = false; 113 | haltTime = pingPongInterval ?? haltTime; 114 | } 115 | else { 116 | didReachEnd = true; 117 | haltTime = repeatInterval ?? haltTime; 118 | } 119 | } 120 | else if (usePingPong && time < 0) { 121 | time = 0; 122 | isForwards = true; 123 | didReachEnd = true; 124 | haltTime = repeatInterval ?? haltTime; 125 | } 126 | var easedTime = easeFunction(time / duration); 127 | var value = lerp(from, to, easedTime); 128 | apply(component, value); 129 | onUpdate?.Invoke(this, value); 130 | if (didReachEnd) { 131 | if (loops > 1 || loops == -1) { 132 | didReachEnd = false; 133 | time = 0; 134 | if (loops > 1) { 135 | loops -= 1; 136 | } 137 | } 138 | else { 139 | if (fillMode == FillMode.Forwards || fillMode == FillMode.None) { 140 | apply(component, initial); 141 | onUpdate?.Invoke(this, initial); 142 | } 143 | onEnd?.Invoke(this); 144 | onFinally?.Invoke(this); 145 | isDecommissioned = true; 146 | } 147 | } 148 | } 149 | 150 | /// The cancel method will cancel the Tween. When the Tween is cancelled, the OnCancel and OnFinally delegates will be invoked. 151 | public sealed override void Cancel() { 152 | if (!dontInvokeWhenDestroyed || component != null) { 153 | onCancel?.Invoke(this); 154 | onFinally?.Invoke(this); 155 | } 156 | isDecommissioned = true; 157 | } 158 | 159 | /// The 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. 160 | public IEnumerator AwaitDecommission() { 161 | while (!isDecommissioned) { 162 | yield return null; 163 | } 164 | } 165 | 166 | #if UNITY_2023_1_OR_NEWER 167 | /// The 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. 168 | public async Awaitable AwaitDecommissionAsync() { 169 | while (!isDecommissioned) { 170 | await Awaitable.EndOfFrameAsync(); 171 | } 172 | } 173 | #endif 174 | } 175 | } -------------------------------------------------------------------------------- /Runtime/TweenInstance.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d13e503f0f7524c6d932f7d9818ebb6b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Vector2Tween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class Vector2Tween : Tween { 6 | internal sealed override Vector2 Current(Transform component) { 7 | return Vector2.zero; 8 | } 9 | 10 | internal sealed override Vector2 Lerp(Vector2 from, Vector2 to, float time) { 11 | return Vector2.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, Vector2 value) { } 15 | } 16 | } -------------------------------------------------------------------------------- /Runtime/Vector2Tween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4fc9e593d48ed468daf8380355085fda 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Vector3Tween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class Vector3Tween : Tween { 6 | internal sealed override Vector3 Current(Transform component) { 7 | return Vector3.zero; 8 | } 9 | 10 | internal sealed override Vector3 Lerp(Vector3 from, Vector3 to, float time) { 11 | return Vector3.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, Vector3 value) { } 15 | } 16 | } -------------------------------------------------------------------------------- /Runtime/Vector3Tween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c21bca82b95024ad0a1316967b4e5650 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Vector4Tween.cs: -------------------------------------------------------------------------------- 1 | using Tweens.Core; 2 | using UnityEngine; 3 | 4 | namespace Tweens { 5 | public sealed class Vector4Tween : Tween { 6 | internal sealed override Vector4 Current(Transform component) { 7 | return Vector4.zero; 8 | } 9 | 10 | internal sealed override Vector4 Lerp(Vector4 from, Vector4 to, float time) { 11 | return Vector4.LerpUnclamped(from, to, time); 12 | } 13 | 14 | internal sealed override void Apply(Transform component, Vector4 value) { } 15 | } 16 | } -------------------------------------------------------------------------------- /Runtime/Vector4Tween.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 599feee8594bd4be0ad3b6e2c2bd22b7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /nl.jeffreylanters.tweens.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nl.jeffreylanters.tweens", 3 | "references": [ 4 | "GUID:df380645f10b7bc4b97d4f5eb6303d95", 5 | "GUID:6055be8ebefd69e48b49212b09b47b2f" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [ 15 | { 16 | "name": "com.unity.render-pipelines.core", 17 | "expression": "0.0.0", 18 | "define": "TWEENS_DEFINED_COM_UNITY_RENDERPIPELINES_CORE" 19 | }, 20 | { 21 | "name": "com.unity.textmeshpro", 22 | "expression": "0.0.0", 23 | "define": "TWEENS_DEFINED_COM_UNITY_TEXTMESHPRO" 24 | }, 25 | { 26 | "name": "com.unity.ugui", 27 | "expression": "0.0.0", 28 | "define": "TWEENS_DEFINED_COM_UNITY_UGUI" 29 | } 30 | ], 31 | "noEngineReferences": false 32 | } -------------------------------------------------------------------------------- /nl.jeffreylanters.tweens.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f0786a5bbd4d44b992c72105d6500fe 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /omnisharp.json: -------------------------------------------------------------------------------- 1 | { 2 | "FormattingOptions": { 3 | "NewLine": "\n", 4 | "UseTabs": false, 5 | "TabSize": 2, 6 | "IndentationSize": 2, 7 | "SpacingAfterMethodDeclarationName": true, 8 | "SpaceWithinMethodDeclarationParenthesis": false, 9 | "SpaceBetweenEmptyMethodDeclarationParentheses": false, 10 | "SpaceAfterMethodCallName": true, 11 | "SpaceWithinMethodCallParentheses": false, 12 | "SpaceBetweenEmptyMethodCallParentheses": false, 13 | "SpaceAfterControlFlowStatementKeyword": true, 14 | "SpaceWithinExpressionParentheses": false, 15 | "SpaceWithinCastParentheses": false, 16 | "SpaceWithinOtherParentheses": false, 17 | "SpaceAfterCast": false, 18 | "SpacesIgnoreAroundVariableDeclaration": false, 19 | "SpaceBeforeOpenSquareBracket": false, 20 | "SpaceBetweenEmptySquareBrackets": false, 21 | "SpaceWithinSquareBrackets": false, 22 | "SpaceAfterColonInBaseTypeDeclaration": true, 23 | "SpaceAfterComma": true, 24 | "SpaceAfterDot": false, 25 | "SpaceAfterSemicolonsInForStatement": true, 26 | "SpaceBeforeColonInBaseTypeDeclaration": true, 27 | "SpaceBeforeComma": false, 28 | "SpaceBeforeDot": false, 29 | "SpaceBeforeSemicolonsInForStatement": false, 30 | "SpacingAroundBinaryOperator": "single", 31 | "IndentBraces": false, 32 | "IndentBlock": true, 33 | "IndentSwitchSection": true, 34 | "IndentSwitchCaseSection": true, 35 | "LabelPositioning": "oneLess", 36 | "WrappingPreserveSingleLine": true, 37 | "WrappingKeepStatementsOnSingleLine": true, 38 | "NewLinesForBracesInTypes": false, 39 | "NewLinesForBracesInMethods": false, 40 | "NewLinesForBracesInProperties": false, 41 | "NewLinesForBracesInAccessors": false, 42 | "NewLinesForBracesInAnonymousMethods": false, 43 | "NewLinesForBracesInControlBlocks": false, 44 | "NewLinesForBracesInAnonymousTypes": false, 45 | "NewLinesForBracesInObjectCollectionArrayInitializers": false, 46 | "NewLinesForBracesInLambdaExpressionBody": false, 47 | "NewLineForElse": false, 48 | "NewLineForCatch": false, 49 | "NewLineForFinally": false, 50 | "NewLineForMembersInObjectInit": false, 51 | "NewLineForMembersInAnonymousTypes": false, 52 | "NewLineForClausesInQuery": false 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /omnisharp.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c532fc3611e2141e7864fb541eb5a78c 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nl.jeffreylanters.tweens", 3 | "displayName": "Tweens", 4 | "version": "3.4.1", 5 | "unity": "2020.1", 6 | "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.", 7 | "type": "library", 8 | "keywords": [ 9 | "Tweens", 10 | "Animation" 11 | ], 12 | "hideInEditor": false, 13 | "documentationUrl": "https://github.com/jeffreylanters/unity-tweens", 14 | "changelogUrl": "https://github.com/jeffreylanters/unity-tweens/releases", 15 | "licensesUrl": "https://github.com/jeffreylanters/unity-tweens/blob/master/LICENSE.md", 16 | "repository": "https://github.com/jeffreylanters/unity-tweens.git", 17 | "author": { 18 | "name": "Jeffrey Lanters", 19 | "email": "hallo@jeffreylanters.nl", 20 | "url": "https://github.com/jeffreylanters" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a62a50b702ea49b7b2d1a297c90efb4 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------