├── .gitattributes
├── .github
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── Editor.meta
├── Editor
├── Juce.Tween.Editor.asmdef
├── Juce.Tween.Editor.asmdef.meta
├── JuceTweenEditor.cs
└── JuceTweenEditor.cs.meta
├── LICENSE
├── LICENSE.meta
├── Misc.meta
├── Misc
├── Logo.png
├── Logo.png.meta
├── Logo.psd
├── Logo.psd.meta
├── LogoShortHeight.png
└── LogoShortHeight.png.meta
├── README.md
├── README.md.meta
├── Runtime.meta
├── Runtime
├── Easing.meta
├── Easing
│ ├── AnimationCurveEaser.cs
│ ├── AnimationCurveEaser.cs.meta
│ ├── Ease.cs
│ ├── Ease.cs.meta
│ ├── EaseDelegate.cs
│ ├── EaseDelegate.cs.meta
│ ├── PresetEaser.cs
│ └── PresetEaser.cs.meta
├── Enums.meta
├── Enums
│ ├── ResetMode.cs
│ ├── ResetMode.cs.meta
│ ├── RotationMode.cs
│ └── RotationMode.cs.meta
├── Extensions.meta
├── Extensions
│ ├── JuceTweenAudioSourceExtensions.cs
│ ├── JuceTweenAudioSourceExtensions.cs.meta
│ ├── JuceTweenCameraExtensions.cs
│ ├── JuceTweenCameraExtensions.cs.meta
│ ├── JuceTweenCanvasGroupExtensions.cs
│ ├── JuceTweenCanvasGroupExtensions.cs.meta
│ ├── JuceTweenGraphicExtensions.cs
│ ├── JuceTweenGraphicExtensions.cs.meta
│ ├── JuceTweenImageExtensions.cs
│ ├── JuceTweenImageExtensions.cs.meta
│ ├── JuceTweenLayoutElementExtensions.cs
│ ├── JuceTweenLayoutElementExtensions.cs.meta
│ ├── JuceTweenLightExtensions.cs
│ ├── JuceTweenLightExtensions.cs.meta
│ ├── JuceTweenLineRendererExtensions.cs
│ ├── JuceTweenLineRendererExtensions.cs.meta
│ ├── JuceTweenMaterialExtensions.cs
│ ├── JuceTweenMaterialExtensions.cs.meta
│ ├── JuceTweenOutlineExtensions.cs
│ ├── JuceTweenOutlineExtensions.cs.meta
│ ├── JuceTweenRectTransformExtensions.cs
│ ├── JuceTweenRectTransformExtensions.cs.meta
│ ├── JuceTweenRigidBody2DExtensions.cs
│ ├── JuceTweenRigidBody2DExtensions.cs.meta
│ ├── JuceTweenRigidbodyExtensions.cs
│ ├── JuceTweenRigidbodyExtensions.cs.meta
│ ├── JuceTweenScrollRectExtensions.cs
│ ├── JuceTweenScrollRectExtensions.cs.meta
│ ├── JuceTweenSpriteRendererExtensions.cs
│ ├── JuceTweenSpriteRendererExtensions.cs.meta
│ ├── JuceTweenTextExtensions.cs
│ ├── JuceTweenTextExtensions.cs.meta
│ ├── JuceTweenTextMeshProExtensions.cs
│ ├── JuceTweenTextMeshProExtensions.cs.meta
│ ├── JuceTweenTrailRendererExtensions.cs
│ ├── JuceTweenTrailRendererExtensions.cs.meta
│ ├── JuceTweenTransformExtensions.cs
│ └── JuceTweenTransformExtensions.cs.meta
├── Interpolators.meta
├── Interpolators
│ ├── ColorInterpolator.cs
│ ├── ColorInterpolator.cs.meta
│ ├── FloatInterpolator.cs
│ ├── FloatInterpolator.cs.meta
│ ├── IInterpolator.cs
│ ├── IInterpolator.cs.meta
│ ├── IntInterpolator.cs
│ ├── IntInterpolator.cs.meta
│ ├── QuaternionInterpolator.cs
│ ├── QuaternionInterpolator.cs.meta
│ ├── RectInterpolator.cs
│ ├── RectInterpolator.cs.meta
│ ├── Vector2Interpolator.cs
│ ├── Vector2Interpolator.cs.meta
│ ├── Vector3Interpolator.cs
│ ├── Vector3Interpolator.cs.meta
│ ├── Vector3RotationInterpolator.cs
│ ├── Vector3RotationInterpolator.cs.meta
│ ├── Vector4Interpolator.cs
│ └── Vector4Interpolator.cs.meta
├── Juce.Tween.Runtime.asmdef
├── Juce.Tween.Runtime.asmdef.meta
├── JuceTween.cs
├── JuceTween.cs.meta
├── Repositories.meta
├── Repositories
│ ├── SequenceTweenTweenRepository.cs
│ └── SequenceTweenTweenRepository.cs.meta
├── Tweeners.meta
├── Tweeners
│ ├── ColorTweener.cs
│ ├── ColorTweener.cs.meta
│ ├── FloatTweener.cs
│ ├── FloatTweener.cs.meta
│ ├── ITweener.cs
│ ├── ITweener.cs.meta
│ ├── IntTweener.cs
│ ├── IntTweener.cs.meta
│ ├── QuaternionTweener.cs
│ ├── QuaternionTweener.cs.meta
│ ├── RectTweener.cs
│ ├── RectTweener.cs.meta
│ ├── Tweener.cs
│ ├── Tweener.cs.meta
│ ├── Vector2Tweener.cs
│ ├── Vector2Tweener.cs.meta
│ ├── Vector3RotationTweener.cs
│ ├── Vector3RotationTweener.cs.meta
│ ├── Vector3Tweener.cs
│ ├── Vector3Tweener.cs.meta
│ ├── Vector4Tweener.cs
│ └── Vector4Tweener.cs.meta
├── Tweens.meta
├── Tweens
│ ├── CallbackTween.cs
│ ├── CallbackTween.cs.meta
│ ├── GroupTween.cs
│ ├── GroupTween.cs.meta
│ ├── ISequenceTween.cs
│ ├── ISequenceTween.cs.meta
│ ├── ITween.cs
│ ├── ITween.cs.meta
│ ├── InterpolationTween.cs
│ ├── InterpolationTween.cs.meta
│ ├── ResetableCallbackTween.cs
│ ├── ResetableCallbackTween.cs.meta
│ ├── SequenceTween.cs
│ ├── SequenceTween.cs.meta
│ ├── Tween.cs
│ ├── Tween.cs.meta
│ ├── TweenStatics.cs
│ ├── TweenStatics.cs.meta
│ ├── WaitTimeTween.cs
│ └── WaitTimeTween.cs.meta
├── Utils.meta
└── Utils
│ ├── AngleUtils.cs
│ ├── AngleUtils.cs.meta
│ ├── ColorUtils.cs
│ ├── ColorUtils.cs.meta
│ ├── TweenUtils.cs
│ └── TweenUtils.cs.meta
├── package.json
└── package.json.meta
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/Editor.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6653b4b5b680a7b47913c3ab4579057b
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Editor/Juce.Tween.Editor.asmdef:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Juce.Tween.Editor",
3 | "references": [
4 | "GUID:1765b9cf2ac90c24c957166617f61cc1",
5 | "GUID:9a64ff96d3b16d7498c8f46b660d81a0"
6 | ],
7 | "includePlatforms": [
8 | "Editor"
9 | ],
10 | "excludePlatforms": [],
11 | "allowUnsafeCode": false,
12 | "overrideReferences": false,
13 | "precompiledReferences": [],
14 | "autoReferenced": true,
15 | "defineConstraints": [],
16 | "versionDefines": [],
17 | "noEngineReferences": false
18 | }
--------------------------------------------------------------------------------
/Editor/Juce.Tween.Editor.asmdef.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a5ac40d22d1b4d64483aa748c8b33a23
3 | AssemblyDefinitionImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Editor/JuceTweenEditor.cs:
--------------------------------------------------------------------------------
1 | using UnityEditor;
2 |
3 | namespace Juce.Tweening
4 | {
5 | [CustomEditor(typeof(JuceTween))]
6 | public class JuceTweenEditor : Editor
7 | {
8 | private JuceTween CustomTarget => (JuceTween)target;
9 |
10 | public override void OnInspectorGUI()
11 | {
12 | EditorGUILayout.LabelField($"Juce Tween", EditorStyles.boldLabel);
13 |
14 | EditorGUILayout.Space();
15 |
16 | using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
17 | {
18 | EditorGUILayout.LabelField($"Alive tweens: {CustomTarget.GetAliveTweensCounts()}", EditorStyles.boldLabel);
19 | EditorGUILayout.LabelField($"Playing tweens: {CustomTarget.GetPlayingTweensCounts()}", EditorStyles.boldLabel);
20 | EditorGUILayout.LabelField($"Update milliseconds: {CustomTarget.UpdateMilliseconds}", EditorStyles.boldLabel);
21 |
22 | }
23 |
24 | using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
25 | {
26 | EditorGUILayout.LabelField($"Time Scale: {JuceTween.TimeScale}", EditorStyles.boldLabel);
27 | }
28 |
29 | Repaint();
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/Editor/JuceTweenEditor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b7433d3f1cddc094084da6308ca41e5d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Juce Assets
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.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2f8720b3989839448a3314e0506f5e7a
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Misc.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7e50700024a46d44eb193e738c5ebe78
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Misc/Logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Juce-Assets/Juce-Tween/ae6ce8daefc86a71bfed4317067728729fd7276a/Misc/Logo.png
--------------------------------------------------------------------------------
/Misc/Logo.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 045afa51f5d702b4daa7774d53108040
3 | TextureImporter:
4 | internalIDToNameTable: []
5 | externalObjects: {}
6 | serializedVersion: 11
7 | mipmaps:
8 | mipMapMode: 0
9 | enableMipMap: 0
10 | sRGBTexture: 1
11 | linearTexture: 0
12 | fadeOut: 0
13 | borderMipMap: 0
14 | mipMapsPreserveCoverage: 0
15 | alphaTestReferenceValue: 0.5
16 | mipMapFadeDistanceStart: 1
17 | mipMapFadeDistanceEnd: 3
18 | bumpmap:
19 | convertToNormalMap: 0
20 | externalNormalMap: 0
21 | heightScale: 0.25
22 | normalMapFilter: 0
23 | isReadable: 0
24 | streamingMipmaps: 0
25 | streamingMipmapsPriority: 0
26 | grayScaleToAlpha: 0
27 | generateCubemap: 6
28 | cubemapConvolution: 0
29 | seamlessCubemap: 0
30 | textureFormat: 1
31 | maxTextureSize: 2048
32 | textureSettings:
33 | serializedVersion: 2
34 | filterMode: -1
35 | aniso: -1
36 | mipBias: -100
37 | wrapU: 1
38 | wrapV: 1
39 | wrapW: 1
40 | nPOTScale: 0
41 | lightmap: 0
42 | compressionQuality: 50
43 | spriteMode: 1
44 | spriteExtrude: 1
45 | spriteMeshType: 1
46 | alignment: 0
47 | spritePivot: {x: 0.5, y: 0.5}
48 | spritePixelsToUnits: 100
49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
50 | spriteGenerateFallbackPhysicsShape: 1
51 | alphaUsage: 1
52 | alphaIsTransparency: 1
53 | spriteTessellationDetail: -1
54 | textureType: 8
55 | textureShape: 1
56 | singleChannelComponent: 0
57 | maxTextureSizeSet: 0
58 | compressionQualitySet: 0
59 | textureFormatSet: 0
60 | applyGammaDecoding: 0
61 | platformSettings:
62 | - serializedVersion: 3
63 | buildTarget: DefaultTexturePlatform
64 | maxTextureSize: 2048
65 | resizeAlgorithm: 0
66 | textureFormat: -1
67 | textureCompression: 1
68 | compressionQuality: 50
69 | crunchedCompression: 0
70 | allowsAlphaSplitting: 0
71 | overridden: 0
72 | androidETC2FallbackOverride: 0
73 | forceMaximumCompressionQuality_BC6H_BC7: 0
74 | spriteSheet:
75 | serializedVersion: 2
76 | sprites: []
77 | outline: []
78 | physicsShape: []
79 | bones: []
80 | spriteID: 5e97eb03825dee720800000000000000
81 | internalID: 0
82 | vertices: []
83 | indices:
84 | edges: []
85 | weights: []
86 | secondaryTextures: []
87 | spritePackingTag:
88 | pSDRemoveMatte: 0
89 | pSDShowRemoveMatteOption: 0
90 | userData:
91 | assetBundleName:
92 | assetBundleVariant:
93 |
--------------------------------------------------------------------------------
/Misc/Logo.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Juce-Assets/Juce-Tween/ae6ce8daefc86a71bfed4317067728729fd7276a/Misc/Logo.psd
--------------------------------------------------------------------------------
/Misc/Logo.psd.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e7fb55bd36f1a2b46b38cfbce5343d36
3 | TextureImporter:
4 | internalIDToNameTable: []
5 | externalObjects: {}
6 | serializedVersion: 11
7 | mipmaps:
8 | mipMapMode: 0
9 | enableMipMap: 0
10 | sRGBTexture: 1
11 | linearTexture: 0
12 | fadeOut: 0
13 | borderMipMap: 0
14 | mipMapsPreserveCoverage: 0
15 | alphaTestReferenceValue: 0.5
16 | mipMapFadeDistanceStart: 1
17 | mipMapFadeDistanceEnd: 3
18 | bumpmap:
19 | convertToNormalMap: 0
20 | externalNormalMap: 0
21 | heightScale: 0.25
22 | normalMapFilter: 0
23 | isReadable: 0
24 | streamingMipmaps: 0
25 | streamingMipmapsPriority: 0
26 | grayScaleToAlpha: 0
27 | generateCubemap: 6
28 | cubemapConvolution: 0
29 | seamlessCubemap: 0
30 | textureFormat: 1
31 | maxTextureSize: 2048
32 | textureSettings:
33 | serializedVersion: 2
34 | filterMode: -1
35 | aniso: -1
36 | mipBias: -100
37 | wrapU: 1
38 | wrapV: 1
39 | wrapW: 1
40 | nPOTScale: 0
41 | lightmap: 0
42 | compressionQuality: 50
43 | spriteMode: 1
44 | spriteExtrude: 1
45 | spriteMeshType: 1
46 | alignment: 0
47 | spritePivot: {x: 0.5, y: 0.5}
48 | spritePixelsToUnits: 100
49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
50 | spriteGenerateFallbackPhysicsShape: 1
51 | alphaUsage: 1
52 | alphaIsTransparency: 1
53 | spriteTessellationDetail: -1
54 | textureType: 8
55 | textureShape: 1
56 | singleChannelComponent: 0
57 | maxTextureSizeSet: 0
58 | compressionQualitySet: 0
59 | textureFormatSet: 0
60 | applyGammaDecoding: 0
61 | platformSettings:
62 | - serializedVersion: 3
63 | buildTarget: DefaultTexturePlatform
64 | maxTextureSize: 2048
65 | resizeAlgorithm: 0
66 | textureFormat: -1
67 | textureCompression: 1
68 | compressionQuality: 50
69 | crunchedCompression: 0
70 | allowsAlphaSplitting: 0
71 | overridden: 0
72 | androidETC2FallbackOverride: 0
73 | forceMaximumCompressionQuality_BC6H_BC7: 0
74 | spriteSheet:
75 | serializedVersion: 2
76 | sprites: []
77 | outline: []
78 | physicsShape: []
79 | bones: []
80 | spriteID: 5e97eb03825dee720800000000000000
81 | internalID: 0
82 | vertices: []
83 | indices:
84 | edges: []
85 | weights: []
86 | secondaryTextures: []
87 | spritePackingTag:
88 | pSDRemoveMatte: 0
89 | pSDShowRemoveMatteOption: 0
90 | userData:
91 | assetBundleName:
92 | assetBundleVariant:
93 |
--------------------------------------------------------------------------------
/Misc/LogoShortHeight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Juce-Assets/Juce-Tween/ae6ce8daefc86a71bfed4317067728729fd7276a/Misc/LogoShortHeight.png
--------------------------------------------------------------------------------
/Misc/LogoShortHeight.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a748ad2e027e41e40be10819c7c403c3
3 | TextureImporter:
4 | internalIDToNameTable: []
5 | externalObjects: {}
6 | serializedVersion: 11
7 | mipmaps:
8 | mipMapMode: 0
9 | enableMipMap: 0
10 | sRGBTexture: 1
11 | linearTexture: 0
12 | fadeOut: 0
13 | borderMipMap: 0
14 | mipMapsPreserveCoverage: 0
15 | alphaTestReferenceValue: 0.5
16 | mipMapFadeDistanceStart: 1
17 | mipMapFadeDistanceEnd: 3
18 | bumpmap:
19 | convertToNormalMap: 0
20 | externalNormalMap: 0
21 | heightScale: 0.25
22 | normalMapFilter: 0
23 | isReadable: 0
24 | streamingMipmaps: 0
25 | streamingMipmapsPriority: 0
26 | grayScaleToAlpha: 0
27 | generateCubemap: 6
28 | cubemapConvolution: 0
29 | seamlessCubemap: 0
30 | textureFormat: 1
31 | maxTextureSize: 2048
32 | textureSettings:
33 | serializedVersion: 2
34 | filterMode: -1
35 | aniso: -1
36 | mipBias: -100
37 | wrapU: 1
38 | wrapV: 1
39 | wrapW: 1
40 | nPOTScale: 0
41 | lightmap: 0
42 | compressionQuality: 50
43 | spriteMode: 1
44 | spriteExtrude: 1
45 | spriteMeshType: 1
46 | alignment: 0
47 | spritePivot: {x: 0.5, y: 0.5}
48 | spritePixelsToUnits: 100
49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
50 | spriteGenerateFallbackPhysicsShape: 1
51 | alphaUsage: 1
52 | alphaIsTransparency: 1
53 | spriteTessellationDetail: -1
54 | textureType: 8
55 | textureShape: 1
56 | singleChannelComponent: 0
57 | maxTextureSizeSet: 0
58 | compressionQualitySet: 0
59 | textureFormatSet: 0
60 | applyGammaDecoding: 0
61 | platformSettings:
62 | - serializedVersion: 3
63 | buildTarget: DefaultTexturePlatform
64 | maxTextureSize: 2048
65 | resizeAlgorithm: 0
66 | textureFormat: -1
67 | textureCompression: 1
68 | compressionQuality: 50
69 | crunchedCompression: 0
70 | allowsAlphaSplitting: 0
71 | overridden: 0
72 | androidETC2FallbackOverride: 0
73 | forceMaximumCompressionQuality_BC6H_BC7: 0
74 | spriteSheet:
75 | serializedVersion: 2
76 | sprites: []
77 | outline: []
78 | physicsShape: []
79 | bones: []
80 | spriteID: 5e97eb03825dee720800000000000000
81 | internalID: 0
82 | vertices: []
83 | indices:
84 | edges: []
85 | weights: []
86 | secondaryTextures: []
87 | spritePackingTag:
88 | pSDRemoveMatte: 0
89 | pSDShowRemoveMatteOption: 0
90 | userData:
91 | assetBundleName:
92 | assetBundleVariant:
93 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://opensource.org/licenses/MIT)
2 | [](https://github.com/Juce-Assets/Juce-Tween/issues)
3 | [](https://twitter.com/6uillem)
4 | [](https://github.com/Juce-Assets/Juce-Tween/releases/latest)
5 | [](https://openupm.com/packages/com.juce.tween/)
6 |
7 | # Juce-Tween
8 | Welcome to [Tween Component](https://github.com/Juce-Assets/Juce-Tween), the open-source tweening library that's part of the Juce Unity tools framework.
9 |
10 |
11 | 
12 |
13 |
14 |
15 | - **Easy to use**: gracefully integrated with Unity.
16 |
17 | - **Flexible**: nest as many tweens and sequences as you want to create complex animations.
18 |
19 | - **Extendible**: Easily create neew Tweens for animating any variable imaginable.
20 |
21 | - **Coders friendly**: we take a lot of effort making sure the underlying structure is clean and easy to extend. Code aims to be robust and well written.
22 |
23 | # Contents
24 |
25 | - [Why](https://github.com/Juce-Assets/Juce-Tween#why)
26 | - [Installing](https://github.com/Juce-Assets/Juce-Tween#installing)
27 | - [Enabling Extensions](https://github.com/Juce-Assets/Juce-Tween#enabling-extensions-tmpro-timeline-etc)
28 | - [Nomenclature](https://github.com/Juce-Assets/Juce-Tween#nomenclature)
29 | - [Basic Usage](https://github.com/Juce-Assets/Juce-Tween#basic-usage)
30 | - [Bindings](https://github.com/Juce-Assets/Juce-Tween#bindings)
31 | - [Tween Components Documentation](https://github.com/Juce-Assets/Juce-Tween#tween-components-documentation)
32 | - [Want to contribute?](https://github.com/Juce-Assets/Juce-Tween#want-to-contribute)
33 | - [Contributors](https://github.com/Juce-Assets/Juce-Tween#contributors)
34 |
35 | ## Why?
36 |
37 | When we start developing games in Unity and we learn about Tweening engines, we quickly jump to the most popular ones like DoTween, and they seem magical.
38 |
39 | But once you get more serious and advance on the journey of game development, you start to notice some small quirks and issues with those well known tweening engines that just make you wonder why they did that this way, or why this simple thing does not work.
40 |
41 | This tweening engine aims to solve that. Things just work as you would expect, there is no conditions nor compromises.
42 |
43 | ## Installing
44 |
45 | Unity Package Manager dependences:
46 | - TextMeshPro
47 |
48 | ### - Via Github
49 | #### Dependences
50 | First of all, you will need to download the following dependences
51 | - [Juce-Utils](https://github.com/Juce-Assets/Juce-Utils)
52 |
53 | Download the full repositories, and then place them under the Assets folder of your Unity project.
54 |
55 | #### Project installation
56 | Download this repository, and place it under the Assets folder of your Unity project.
57 |
58 | And that's all, with that you should be ready to go!
59 |
60 | ### - Via UPM
61 | Unity does not support resolving dependences from a git url. Because of that, you will need to add the following lines to your [manifest.json](https://docs.unity3d.com/Manual/upm-manifestPrj.html).
62 | ```
63 | "dependencies": {
64 | "com.juce.utils": "git+https://github.com/Juce-Assets/Juce-Utils",
65 | "com.juce.tween": "git+https://github.com/Juce-Assets/Juce-Tween",
66 | },
67 | ```
68 |
69 | ## Enabling Extensions
70 |
71 | Since Unity is moving towards a very granular approach, we dont want to force our users to have all the dependences installed in your project to start using the tool.
72 |
73 | To enanble or disable different extensions, first open on the Unity top bar: ***Tools/Juce/Configuration*** to open the Juce Configuration Window.
74 |
75 | 
76 |
77 | Once the window is opened, you just need to select which extension you want to use in your project. (You may need to wait for Unity to recompile).
78 |
79 | 
80 |
81 | For some Example scenes to work, you will probably need to add, at least, TextMeshPro to your project, and enable the toggle extension.
82 |
83 | ## Nomenclature
84 | - Tweening engine: system that allows you to animate stuff via code in an easy, concise and possibly powerful way.
85 | - Tween: unit of work that takes control of a value and animates it.
86 | - Sequence: special tween that, instead of taking control of a value, takes control of other tweens and animates them as a group.
87 |
88 | ## Basic Usage
89 | This is a very straightforward example of how the tweening engine works.
90 | Unity components have tweening extensions that you can call with the prefix **Tween**... like TweenPosition, TweenRotation, etc.
91 | This then returns an ITween that you can play whenever you want by callyng Play() on it;
92 | ```csharp
93 | using Juce.Tweening;
94 | using UnityEngine;
95 |
96 | public class Example : MonoBehaviour
97 | {
98 | [SerializeField] private Transform transform = default;
99 |
100 | private void Start()
101 | {
102 | ITween tween = transform.TweenPosition(to: new Vector3(10, 0, 0), duration: 1f);
103 |
104 | tween.Play();
105 | }
106 | }
107 | ```
108 |
109 | ## Generic Tweens
110 | This is the most flexible way of tweening and allows you to tween almost any value, either public or private, static or dynamic (shortcuts actually uses the generic tweens in the background).
111 |
112 | ```
113 | static Tween.To(getter, setter, to, float duration, validation);
114 | ```
115 | - Getter: function that gets called at the beggining to determine the starting value of the tween.
116 | - Setter: function that gets called every update, while the tween is active, and returns the current value of the tween.
117 | - Duration: time in seconds that the tween should take to complete.
118 | - Validation (optional): funcion that gets called every update, checks if the tween should be killed. This is practical, for example, for checking if a component that is using has been destroyed while the tween was running.
119 |
120 | Practical example:
121 | ```csharp
122 | using Juce.Tweening;
123 | using UnityEngine;
124 |
125 | public class Example : MonoBehaviour
126 | {
127 | [SerializeField] private Transform transform = default;
128 |
129 | private void Start()
130 | {
131 | Vector3 finalValue = new Vector3(10, 0, 0);
132 |
133 | ITween tween = Tween.To(
134 | () => transform.position,
135 | toSet => transform.position = toSet,
136 | () => finalValue,
137 | duration: 1f,
138 | validation: () => transform != null
139 | );
140 |
141 | tween.Play();
142 | }
143 | }
144 | ```
145 |
146 | ## Shortcut Tweens
147 | Juce-Tween includes shortcuts for some known Unity objects, like Transform, Rigidbody and Material, etc. You can start a tween directly from a reference to these objects, like:
148 | ```csharp
149 | transform.TweenPosition(new Vector3(10, 0, 0), 1);
150 | image.TweenColor(Color.green, 1);
151 | canvasGroup.TweenAlpha(0, 1);
152 | ```
153 | If the target Unity object gets destroyed, the Tween will automatically be killed.
154 |
155 | ## Sequences
156 | Sequences are Tweens, but instead of animating a property or value they animate other Tweens or Sequences as a group.
157 | Sequences can be contained inside other Sequences without any limit to the depth of the hierarchy.
158 |
159 | A Tween can be nested only inside a single other Sequence, meaning you can't reuse the same tween in multiple Sequences.
160 | To create a sequence, you do the following
161 | ```csharp
162 | ISequence sequence = JuceTween.Sequence();
163 |
164 | sequence.Append(tween1);
165 | sequence.Append(tween2);
166 | sequence.Append(tween3);
167 |
168 | sequence.Play();
169 | ```
170 |
171 |
172 | ### Conclusions
173 |
174 | We are always aiming to improve this tool. You can always leave suggestions on the [Issues](https://github.com/Juce-Assets/Juce-Tween/issues) link.
175 |
176 | ## Want to contribute?
177 |
178 | **Please follow these steps to get your work merged in.**
179 |
180 | 0. Clone the repo and make a new branch: `$ git checkout https://github.com/Juce-Assets/Juce-Tween/tree/develop -b [name_of_new_branch]`.
181 |
182 | 1. Add a feature, fix a bug, or refactor some code :)
183 |
184 | 2. Update `README.md` contributors, if necessary.
185 |
186 | 3. Open a Pull Request with a comprehensive description of changes.
187 |
188 | ###
189 |
190 | ## Contributors
191 |
192 | - Guillem SC - [@Guillemsc](https://github.com/Guillemsc)
193 |
194 |
195 |
--------------------------------------------------------------------------------
/README.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d7f11a7eb652d04408ddcbf970f46ea5
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Runtime.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b73d4890d3b4e3145a26d59f47beb888
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/Easing.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0566f31c1920fa74aa92a5211bbaba98
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/Easing/AnimationCurveEaser.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace Juce.Tweening.Easing
4 | {
5 | internal class AnimationCurveEaser
6 | {
7 | internal static EaseDelegate GetEaseDelegate(AnimationCurve animationCurve)
8 | {
9 | EaseDelegate result = (float a, float b, float t) =>
10 | {
11 | float newT = animationCurve.Evaluate(t);
12 |
13 | return a + ((b - a) * newT);
14 | };
15 |
16 | return result;
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/Runtime/Easing/AnimationCurveEaser.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2641ba405fd13084483c2e89f5b06f08
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Easing/Ease.cs:
--------------------------------------------------------------------------------
1 | namespace Juce.Tweening
2 | {
3 | public enum Ease
4 | {
5 | Linear,
6 | InSine,
7 | OutSine,
8 | InOutSine,
9 | InQuad,
10 | OutQuad,
11 | InOutQuad,
12 | InCubic,
13 | OutCubic,
14 | InOutCubic,
15 | InQuart,
16 | OutQuart,
17 | InOutQuart,
18 | InQuint,
19 | OutQuint,
20 | InOutQuint,
21 | InExpo,
22 | OutExpo,
23 | InOutExpo,
24 | InCirc,
25 | OutCirc,
26 | InOutCirc,
27 | InBack,
28 | OutBack,
29 | InOutBack,
30 | InElastic,
31 | OutElastic,
32 | InOutElastic,
33 | InBounce,
34 | OutBounce,
35 | InOutBounce
36 | }
37 | }
--------------------------------------------------------------------------------
/Runtime/Easing/Ease.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0b9b22965d0c4ae4ea5aeb4d209ccb27
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Easing/EaseDelegate.cs:
--------------------------------------------------------------------------------
1 | namespace Juce.Tweening.Easing
2 | {
3 | public delegate float EaseDelegate(float a, float b, float t);
4 | }
--------------------------------------------------------------------------------
/Runtime/Easing/EaseDelegate.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4dd37c240507b8f4ca06688bf43557da
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Easing/PresetEaser.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace Juce.Tweening.Easing
4 | {
5 | internal class PresetEaser
6 | {
7 | private const float C1 = 1.70158f;
8 | private const float C2 = C1 * 1.525f;
9 | private const float C3 = C1 + 1;
10 | private const float C4 = (2 * Mathf.PI) / 3;
11 | private const float C5 = (2 * Mathf.PI) / 4.5f;
12 |
13 | private const float N1 = 7.5625f;
14 | private const float D1 = 2.75f;
15 |
16 | public static EaseDelegate GetEaseDelegate(Ease ease)
17 | {
18 | EaseDelegate result;
19 |
20 | switch (ease)
21 | {
22 | default:
23 | case Ease.Linear: result = Linear; break;
24 | case Ease.InSine: result = InSine; break;
25 | case Ease.OutSine: result = OutSine; break;
26 | case Ease.InOutSine: result = InOutSine; break;
27 | case Ease.InQuad: result = InQuad; break;
28 | case Ease.OutQuad: result = OutQuad; break;
29 | case Ease.InOutQuad: result = InOutQuad; break;
30 | case Ease.InCubic: result = InCubic; break;
31 | case Ease.OutCubic: result = OutCubic; break;
32 | case Ease.InOutCubic: result = InOutCubic; break;
33 | case Ease.InQuart: result = InQuart; break;
34 | case Ease.OutQuart: result = OutQuart; break;
35 | case Ease.InOutQuart: result = InOutQuart; break;
36 | case Ease.InQuint: result = InQuint; break;
37 | case Ease.OutQuint: result = OutQuint; break;
38 | case Ease.InOutQuint: result = InOutQuint; break;
39 | case Ease.InExpo: result = InExpo; break;
40 | case Ease.OutExpo: result = OutExpo; break;
41 | case Ease.InOutExpo: result = InOutExpo; break;
42 | case Ease.InCirc: result = InCirc; break;
43 | case Ease.OutCirc: result = OutCirc; break;
44 | case Ease.InOutCirc: result = InOutCirc; break;
45 | case Ease.InBack: result = InBack; break;
46 | case Ease.OutBack: result = OutBack; break;
47 | case Ease.InOutBack: result = InOutBack; break;
48 | case Ease.InElastic: result = InElastic; break;
49 | case Ease.OutElastic: result = OutElastic; break;
50 | case Ease.InOutElastic: result = InOutElastic; break;
51 | case Ease.InBounce: result = InBounce; break;
52 | case Ease.OutBounce: result = OutBounce; break;
53 | case Ease.InOutBounce: result = InOutBounce; break;
54 | }
55 |
56 | return result;
57 | }
58 |
59 | private static float Linear(float a, float b, float t)
60 | {
61 | return Lerp(a, b, t);
62 | }
63 |
64 | private static float InSine(float a, float b, float t)
65 | {
66 | return Lerp(a, b, 1 - Mathf.Cos((t * Mathf.PI) / 2f));
67 | }
68 |
69 | private static float OutSine(float a, float b, float t)
70 | {
71 | return Lerp(a, b, Mathf.Sin((t * Mathf.PI) / 2f));
72 | }
73 |
74 | private static float InOutSine(float a, float b, float t)
75 | {
76 | return Lerp(a, b, -(Mathf.Cos(t * Mathf.PI) - 1) / 2f);
77 | }
78 |
79 | private static float InQuad(float a, float b, float t)
80 | {
81 | return Lerp(a, b, t * t);
82 | }
83 |
84 | private static float OutQuad(float a, float b, float t)
85 | {
86 | return Lerp(a, b, 1 - (1 - t) * (1 - t));
87 | }
88 |
89 | private static float InOutQuad(float a, float b, float t)
90 | {
91 | return Lerp(a, b, t < 0.5f ? 2 * t * t : 1 - Mathf.Pow(-2 * t + 2, 2) / 2);
92 | }
93 |
94 | private static float InCubic(float a, float b, float t)
95 | {
96 | return Lerp(a, b, t * t * t);
97 | }
98 |
99 | private static float OutCubic(float a, float b, float t)
100 | {
101 | return Lerp(a, b, 1 - Mathf.Pow(1 - t, 3));
102 | }
103 |
104 | private static float InOutCubic(float a, float b, float t)
105 | {
106 | return Lerp(a, b, t < 0.5f ? 4 * t * t * t : 1 - Mathf.Pow(-2 * t + 2, 3) / 2);
107 | }
108 |
109 | private static float InQuart(float a, float b, float t)
110 | {
111 | return Lerp(a, b, t * t * t * t);
112 | }
113 |
114 | private static float OutQuart(float a, float b, float t)
115 | {
116 | return Lerp(a, b, 1 - Mathf.Pow(1 - t, 4));
117 | }
118 |
119 | private static float InOutQuart(float a, float b, float t)
120 | {
121 | return Lerp(a, b, t < 0.5f ? 8 * t * t * t * t : 1 - Mathf.Pow(-2 * t + 2, 4) / 2);
122 | }
123 |
124 | private static float InQuint(float a, float b, float t)
125 | {
126 | return Lerp(a, b, t * t * t * t * t);
127 | }
128 |
129 | private static float OutQuint(float a, float b, float t)
130 | {
131 | return Lerp(a, b, 1 - Mathf.Pow(1 - t, 5));
132 | }
133 |
134 | private static float InOutQuint(float a, float b, float t)
135 | {
136 | return Lerp(a, b, t < 0.5f ? 16 * t * t * t * t * t : 1 - Mathf.Pow(-2 * t + 2, 5) / 2);
137 | }
138 |
139 | private static float InExpo(float a, float b, float t)
140 | {
141 | return Lerp(a, b, t == 0 ? 0 : Mathf.Pow(2, 10 * t - 10));
142 | }
143 |
144 | private static float OutExpo(float a, float b, float t)
145 | {
146 | return Lerp(a, b, t == 1 ? 1 : 1 - Mathf.Pow(2, -10 * t));
147 | }
148 |
149 | private static float InOutExpo(float a, float b, float t)
150 | {
151 | return Lerp(a, b, t == 0 ? 0 : t == 1 ? 1 : t < 0.5f ? Mathf.Pow(2, 20 * t - 10) / 2 : (2 - Mathf.Pow(2, -20 * t + 10)) / 2);
152 | }
153 |
154 | private static float InCirc(float a, float b, float t)
155 | {
156 | return Lerp(a, b, 1 - Mathf.Sqrt(1 - Mathf.Pow(t, 2)));
157 | }
158 |
159 | private static float OutCirc(float a, float b, float t)
160 | {
161 | return Lerp(a, b, Mathf.Sqrt(1 - Mathf.Pow(t - 1, 2)));
162 | }
163 |
164 | private static float InOutCirc(float a, float b, float t)
165 | {
166 | return Lerp(a, b, t < 0.5f ? (1 - Mathf.Sqrt(1 - Mathf.Pow(2 * t, 2))) / 2 : (Mathf.Sqrt(1 - Mathf.Pow(-2 * t + 2, 2)) + 1) / 2);
167 | }
168 |
169 | private static float InBack(float a, float b, float t)
170 | {
171 | return Lerp(a, b, C3 * t * t * t - C1 * t * t);
172 | }
173 |
174 | private static float OutBack(float a, float b, float t)
175 | {
176 | return Lerp(a, b, 1 + C3 * Mathf.Pow(t - 1, 3) + C1 * Mathf.Pow(t - 1, 2));
177 | }
178 |
179 | private static float InOutBack(float a, float b, float t)
180 | {
181 | return Lerp(a, b, t < 0.5f ? (Mathf.Pow(2 * t, 2) * ((C2 + 1) * 2 * t - C2)) / 2 : (Mathf.Pow(2 * t - 2, 2) * ((C2 + 1) * (t * 2 - 2) + C2) + 2) / 2);
182 | }
183 |
184 | private static float InElastic(float a, float b, float t)
185 | {
186 | return Lerp(a, b, t == 0 ? 0 : t == 1 ? 1 : -Mathf.Pow(2, 10 * t - 10) * Mathf.Sin((t * 10 - 10.75f) * C4));
187 | }
188 |
189 | private static float OutElastic(float a, float b, float t)
190 | {
191 | return Lerp(a, b, t == 0 ? 0 : t == 1 ? 1 : Mathf.Pow(2, -10 * t) * Mathf.Sin((t * 10 - 0.75f) * C4) + 1);
192 | }
193 |
194 | private static float InOutElastic(float a, float b, float t)
195 | {
196 | return Lerp(a, b, t == 0 ? 0 : t == 1 ? 1 : t < 0.5f ? -(Mathf.Pow(2, 20 * t - 10) * Mathf.Sin((20 * t - 11.125f) * C5)) / 2 : (Mathf.Pow(2, -20 * t + 10) * Mathf.Sin((20 * t - 11.125f) * C5)) / +1);
197 | }
198 |
199 | private static float InBounce(float a, float b, float t)
200 | {
201 | return Lerp(a, b, 1 - RawOutBounce(1 - t));
202 | }
203 |
204 | private static float OutBounce(float a, float b, float t)
205 | {
206 | return Lerp(a, b, RawOutBounce(t));
207 | }
208 |
209 | private static float InOutBounce(float a, float b, float t)
210 | {
211 | return Lerp(a, b, t < 0.5f ? (1 - RawOutBounce(1 - 2 * t)) / 2 : (1 + RawOutBounce(2 * t - 1)) / 2);
212 | }
213 |
214 | private static float RawOutBounce(float t)
215 | {
216 | if (t < 1 / D1)
217 | {
218 | return N1 * t * t;
219 | }
220 |
221 | if (t < 2 / D1)
222 | {
223 | return N1 * (t -= 1.5f / D1) * t + 0.75f;
224 | }
225 |
226 | if (t < 2.5f / D1)
227 | {
228 | return N1 * (t -= 2.25f / D1) * t + 0.9375f;
229 | }
230 |
231 | return N1 * (t -= 2.625f / D1) * t + 0.984375f;
232 | }
233 |
234 | private static float Lerp(float a, float b, float t)
235 | {
236 | return a + (b - a) * t;
237 | }
238 | }
239 | }
--------------------------------------------------------------------------------
/Runtime/Easing/PresetEaser.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: de5710940142d0c409352350481da66b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Enums.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2a0c64b3326fce14ba953e6605014491
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/Enums/ResetMode.cs:
--------------------------------------------------------------------------------
1 | namespace Juce.Tweening
2 | {
3 | public enum ResetMode
4 | {
5 | InitialValues,
6 | IncrementalValues,
7 | CurrentValues,
8 | }
9 | }
--------------------------------------------------------------------------------
/Runtime/Enums/ResetMode.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: feabe27a1901f1f489d9a32ba882c701
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Enums/RotationMode.cs:
--------------------------------------------------------------------------------
1 | namespace Juce.Tweening
2 | {
3 | public enum RotationMode
4 | {
5 | Fast,
6 | Beyond360,
7 | }
8 | }
--------------------------------------------------------------------------------
/Runtime/Enums/RotationMode.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 951c2fe723b4f3440b631a03a8986141
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0d4677a4e17925342acf52bb8d6ce11b
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenAudioSourceExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using UnityEngine;
3 |
4 | public static class JuceTweenAudioSourceExtensions
5 | {
6 | public static ITween TweenVolume(this AudioSource audioSource, float to, float duration)
7 | {
8 | return Tween.To(
9 | () => audioSource.volume,
10 | current => audioSource.volume = current,
11 | () => to,
12 | duration,
13 | () => audioSource != null
14 | );
15 | }
16 |
17 | public static ITween TweenPitch(this AudioSource audioSource, float to, float duration)
18 | {
19 | return Tween.To(
20 | () => audioSource.pitch,
21 | current => audioSource.pitch = current,
22 | () => to,
23 | duration,
24 | () => audioSource != null
25 | );
26 | }
27 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenAudioSourceExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 81339d541e00ad248b964ef21817f0c3
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenCameraExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using Juce.Tweening.Utils;
3 | using UnityEngine;
4 |
5 | public static class JuceTweenCameraExtensions
6 | {
7 | public static ITween TweenAspect(this Camera camera, float to, float duration)
8 | {
9 | return Tween.To(
10 | () => camera.aspect,
11 | current => camera.aspect = current,
12 | () => to,
13 | duration,
14 | () => camera != null
15 | );
16 | }
17 |
18 | public static ITween TweenBackgroundColor(this Camera camera, Color to, float duration)
19 | {
20 | return Tween.To(
21 | () => camera.backgroundColor,
22 | current => camera.backgroundColor = current,
23 | () => to,
24 | duration,
25 | () => camera != null
26 | );
27 | }
28 |
29 | public static ITween TweenBackgroundColorNoAlpha(this Camera camera, Color to, float duration)
30 | {
31 | return Tween.To(
32 | () => camera.backgroundColor,
33 | current => camera.backgroundColor = ColorUtils.ChangeColorKeepingAlpha(current, camera.backgroundColor),
34 | () => to,
35 | duration,
36 | () => camera != null
37 | );
38 | }
39 |
40 | public static ITween TweenBackgroundColorAlpha(this Camera camera, float to, float duration)
41 | {
42 | float to255 = to * 255.0f;
43 |
44 | return Tween.To(
45 | () => camera.backgroundColor.a,
46 | current => camera.backgroundColor = ColorUtils.ChangeAlpha(camera.backgroundColor, current),
47 | () => to,
48 | duration,
49 | () => camera != null
50 | );
51 | }
52 |
53 | public static ITween TweenFarClipPlane(this Camera camera, float to, float duration)
54 | {
55 | return Tween.To(
56 | () => camera.farClipPlane,
57 | current => camera.farClipPlane = current,
58 | () => to,
59 | duration,
60 | () => camera != null
61 | );
62 | }
63 |
64 | public static ITween TweenNearClipPlane(this Camera camera, float to, float duration)
65 | {
66 | return Tween.To(
67 | () => camera.nearClipPlane,
68 | current => camera.nearClipPlane = current,
69 | () => to,
70 | duration,
71 | () => camera != null
72 | );
73 | }
74 |
75 | public static ITween TweenFieldOfView(this Camera camera, float to, float duration)
76 | {
77 | return Tween.To(
78 | () => camera.fieldOfView,
79 | current => camera.fieldOfView = current,
80 | () => to,
81 | duration,
82 | () => camera != null
83 | );
84 | }
85 |
86 | public static ITween TweenOrthoSize(this Camera camera, float to, float duration)
87 | {
88 | return Tween.To(
89 | () => camera.orthographicSize,
90 | current => camera.orthographicSize = current,
91 | () => to,
92 | duration,
93 | () => camera != null
94 | );
95 | }
96 |
97 | public static ITween TweenRect(this Camera camera, Rect to, float duration)
98 | {
99 | return Tween.To(
100 | () => camera.rect,
101 | current => camera.rect = current,
102 | () => to,
103 | duration,
104 | () => camera != null
105 | );
106 | }
107 |
108 | public static ITween TweenPixelRect(this Camera camera, Rect to, float duration)
109 | {
110 | return Tween.To(
111 | () => camera.pixelRect,
112 | current => camera.pixelRect = current,
113 | () => to,
114 | duration,
115 | () => camera != null
116 | );
117 | }
118 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenCameraExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fb30dd59ff9642a448b18a66e8cefed8
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenCanvasGroupExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using UnityEngine;
3 |
4 | public static class JuceTweenCanvasGroupExtensions
5 | {
6 | public static ITween TweenAlpha(this CanvasGroup canvasGroup, float to, float duration)
7 | {
8 | return Tween.To(
9 | () => canvasGroup.alpha,
10 | current => canvasGroup.alpha = current,
11 | () => to,
12 | duration,
13 | () => canvasGroup != null
14 | );
15 | }
16 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenCanvasGroupExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3b21c081548a026488606106a6e49fa4
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenGraphicExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using Juce.Tweening.Utils;
3 | using UnityEngine;
4 | using UnityEngine.UI;
5 |
6 | public static class JuceTweenGraphicExtensions
7 | {
8 | public static ITween TweenColor(this Graphic graphic, Color to, float duration)
9 | {
10 | return Tween.To(
11 | () => graphic.color,
12 | current => graphic.color = current,
13 | () => to,
14 | duration,
15 | () => graphic != null
16 | );
17 | }
18 |
19 | public static ITween TweenColorNoAlpha(this Graphic graphic, Color to, float duration)
20 | {
21 | return Tween.To(
22 | () => graphic.color,
23 | current => graphic.color = ColorUtils.ChangeColorKeepingAlpha(current, graphic.color),
24 | () => to,
25 | duration,
26 | () => graphic != null
27 | );
28 | }
29 |
30 | public static ITween TweenColorAlpha(this Graphic graphic, float to, float duration)
31 | {
32 | float to255 = to * 255.0f;
33 |
34 | return Tween.To(
35 | () => graphic.color.a,
36 | current => graphic.color = ColorUtils.ChangeAlpha(graphic.color, current),
37 | () => to,
38 | duration,
39 | () => graphic != null
40 | );
41 | }
42 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenGraphicExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e9947011855092941bb47e3f666e911b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenImageExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using Juce.Tweening.Utils;
3 | using UnityEngine;
4 | using UnityEngine.UI;
5 |
6 | public static class JuceTweenImageExtensions
7 | {
8 | public static ITween TweenColor(this Image image, Color to, float duration)
9 | {
10 | return Tween.To(
11 | () => image.color,
12 | current => image.color = current,
13 | () => to,
14 | duration,
15 | () => image != null
16 | );
17 | }
18 |
19 | public static ITween TweenColorNoAlpha(this Image image, Color to, float duration)
20 | {
21 | return Tween.To(
22 | () => image.color,
23 | current => image.color = ColorUtils.ChangeColorKeepingAlpha(current, image.color),
24 | () => to,
25 | duration,
26 | () => image != null
27 | );
28 | }
29 |
30 | public static ITween TweenColorAlpha(this Image image, float to, float duration)
31 | {
32 | float to255 = to * 255.0f;
33 |
34 | return Tween.To(
35 | () => image.color.a,
36 | current => image.color = ColorUtils.ChangeAlpha(image.color, current),
37 | () => to,
38 | duration,
39 | () => image != null
40 | );
41 | }
42 |
43 | public static ITween TweenFillAmount(this Image image, float to, float duration)
44 | {
45 | return Tween.To(
46 | () => image.fillAmount,
47 | current => image.fillAmount = current,
48 | () => to,
49 | duration,
50 | () => image != null
51 | );
52 | }
53 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenImageExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f02949f0e5e38174e812d13931571724
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenLayoutElementExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using UnityEngine;
3 | using UnityEngine.UI;
4 |
5 | public static class JuceTweenLayoutElementExtensions
6 | {
7 | public static ITween TweenFlexibleWidth(this LayoutElement layoutElement, float to, float duration)
8 | {
9 | return Tween.To(
10 | () => layoutElement.flexibleWidth,
11 | current => layoutElement.flexibleWidth = current,
12 | () => to,
13 | duration,
14 | () => layoutElement != null
15 | );
16 | }
17 |
18 | public static ITween TweenFlexibleHeight(this LayoutElement layoutElement, float to, float duration)
19 | {
20 | return Tween.To(
21 | () => layoutElement.flexibleHeight,
22 | current => layoutElement.flexibleHeight = current,
23 | () => to,
24 | duration,
25 | () => layoutElement != null
26 | );
27 | }
28 |
29 | public static ITween TweenFlexibleSize(this LayoutElement layoutElement, Vector2 to, float duration)
30 | {
31 | ITween widthTween = TweenFlexibleWidth(layoutElement, to.x, duration);
32 | ITween heightTween = TweenFlexibleHeight(layoutElement, to.y, duration);
33 |
34 | GroupTween groupTween = new GroupTween();
35 | groupTween.Add(widthTween);
36 | groupTween.Add(heightTween);
37 |
38 | return groupTween;
39 | }
40 |
41 | public static ITween TweenMinWidth(this LayoutElement layoutElement, float to, float duration)
42 | {
43 | return Tween.To(
44 | () => layoutElement.minWidth,
45 | current => layoutElement.minWidth = current,
46 | () => to,
47 | duration,
48 | () => layoutElement != null
49 | );
50 | }
51 |
52 | public static ITween TweenMinHeight(this LayoutElement layoutElement, float to, float duration)
53 | {
54 | return Tween.To(
55 | () => layoutElement.minHeight,
56 | current => layoutElement.minHeight = current,
57 | () => to,
58 | duration,
59 | () => layoutElement != null
60 | );
61 | }
62 |
63 | public static ITween TweenMinSize(this LayoutElement layoutElement, Vector2 to, float duration)
64 | {
65 | ITween widthTween = TweenMinWidth(layoutElement, to.x, duration);
66 | ITween heightTween = TweenMinHeight(layoutElement, to.y, duration);
67 |
68 | GroupTween groupTween = new GroupTween();
69 | groupTween.Add(widthTween);
70 | groupTween.Add(heightTween);
71 |
72 | return groupTween;
73 | }
74 |
75 | public static ITween TweenPreferedWidth(this LayoutElement layoutElement, float to, float duration)
76 | {
77 | return Tween.To(
78 | () => layoutElement.preferredWidth,
79 | current => layoutElement.preferredWidth = current,
80 | () => to,
81 | duration,
82 | () => layoutElement != null
83 | );
84 | }
85 |
86 | public static ITween TweenPreferedHeight(this LayoutElement layoutElement, float to, float duration)
87 | {
88 | return Tween.To(
89 | () => layoutElement.preferredHeight,
90 | current => layoutElement.preferredHeight = current,
91 | () => to,
92 | duration,
93 | () => layoutElement != null
94 | );
95 | }
96 |
97 | public static ITween TweenPreferedSize(this LayoutElement layoutElement, Vector2 to, float duration)
98 | {
99 | ITween widthTween = TweenPreferedWidth(layoutElement, to.x, duration);
100 | ITween heightTween = TweenPreferedHeight(layoutElement, to.y, duration);
101 |
102 | GroupTween groupTween = new GroupTween();
103 | groupTween.Add(widthTween);
104 | groupTween.Add(heightTween);
105 |
106 | return groupTween;
107 | }
108 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenLayoutElementExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 26ec0e2e1304bdc44ae2b3f71827594e
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenLightExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using UnityEngine;
3 |
4 | public static class JuceTweenLightExtensions
5 | {
6 | public static ITween TweenColor(this Light light, Color to, float duration)
7 | {
8 | return Tween.To(
9 | () => light.color,
10 | current => light.color = current,
11 | () => to,
12 | duration,
13 | () => light != null
14 | );
15 | }
16 |
17 | public static ITween TweenIntensity(this Light light, float to, float duration)
18 | {
19 | return Tween.To(
20 | () => light.intensity,
21 | current => light.intensity = current,
22 | () => to,
23 | duration,
24 | () => light != null
25 | );
26 | }
27 |
28 | public static ITween TweenShadowStrenght(this Light light, float to, float duration)
29 | {
30 | return Tween.To(
31 | () => light.shadowStrength,
32 | current => light.shadowStrength = current,
33 | () => to,
34 | duration,
35 | () => light != null
36 | );
37 | }
38 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenLightExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: af67e7f1eeb6d184e958c62fd6007c18
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenLineRendererExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using UnityEngine;
3 |
4 | public static class JuceTweenLineRendererExtensions
5 | {
6 | public static ITween TweenStartColor(this LineRenderer lineRenderer, Color to, float duration)
7 | {
8 | return Tween.To(
9 | () => lineRenderer.startColor,
10 | current => lineRenderer.startColor = current,
11 | () => to,
12 | duration,
13 | () => lineRenderer != null
14 | );
15 | }
16 |
17 | public static ITween TweenEndColor(this LineRenderer lineRenderer, Color to, float duration)
18 | {
19 | return Tween.To(
20 | () => lineRenderer.endColor,
21 | current => lineRenderer.endColor = current,
22 | () => to,
23 | duration,
24 | () => lineRenderer != null
25 | );
26 | }
27 |
28 | public static ITween TweenColor(this LineRenderer lineRenderer, Color to, float duration)
29 | {
30 | ITween startTween = TweenStartColor(lineRenderer, to, duration);
31 | ITween endTween = TweenEndColor(lineRenderer, to, duration);
32 |
33 | GroupTween groupTween = new GroupTween();
34 | groupTween.Add(startTween);
35 | groupTween.Add(endTween);
36 |
37 | return groupTween;
38 | }
39 |
40 | public static ITween TweenStartWidth(this LineRenderer lineRenderer, float to, float duration)
41 | {
42 | return Tween.To(
43 | () => lineRenderer.startWidth,
44 | current => lineRenderer.startWidth = current,
45 | () => to,
46 | duration,
47 | () => lineRenderer != null
48 | );
49 | }
50 |
51 | public static ITween TweenEndWidth(this LineRenderer lineRenderer, float to, float duration)
52 | {
53 | return Tween.To(
54 | () => lineRenderer.endWidth,
55 | current => lineRenderer.endWidth = current,
56 | () => to,
57 | duration,
58 | () => lineRenderer != null
59 | );
60 | }
61 |
62 | public static ITween TweenWidth(this LineRenderer lineRenderer, float to, float duration)
63 | {
64 | ITween startTween = TweenStartWidth(lineRenderer, to, duration);
65 | ITween endTween = TweenEndWidth(lineRenderer, to, duration);
66 |
67 | GroupTween groupTween = new GroupTween();
68 | groupTween.Add(startTween);
69 | groupTween.Add(endTween);
70 |
71 | return groupTween;
72 | }
73 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenLineRendererExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3d68dee077b28844388ce85fd684d2bb
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenMaterialExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using Juce.Tweening.Utils;
3 | using UnityEngine;
4 |
5 | public static class JuceTweenMaterialExtensions
6 | {
7 | public static ITween TweenColor(this Material material, Color to, float duration)
8 | {
9 | return Tween.To(
10 | () => material.color,
11 | current => material.color = current,
12 | () => to,
13 | duration,
14 | () => material != null
15 | );
16 | }
17 |
18 | public static ITween TweenColor(this Material material, Color to, string property, float duration)
19 | {
20 | return Tween.To(
21 | () => material.GetColor(property),
22 | current => material.SetColor(property, current),
23 | () => to,
24 | duration,
25 | () => material != null
26 | );
27 | }
28 |
29 | public static ITween TweenColor(this Material material, Color to, int propertyID, float duration)
30 | {
31 | return Tween.To(
32 | () => material.GetColor(propertyID),
33 | current => material.SetColor(propertyID, current),
34 | () => to,
35 | duration,
36 | () => material != null
37 | );
38 | }
39 |
40 | public static ITween TweenColorNoAlpha(this Material material, Color to, float duration)
41 | {
42 | return Tween.To(
43 | () => material.color,
44 | current => material.color = ColorUtils.ChangeColorKeepingAlpha(current, material.color),
45 | () => to,
46 | duration,
47 | () => material != null
48 | );
49 | }
50 |
51 | public static ITween TweenColorNoAlpha(this Material material, Color to, string property, float duration)
52 | {
53 | return Tween.To(
54 | () => material.GetColor(property),
55 | current => material.SetColor(property, ColorUtils.ChangeColorKeepingAlpha(current, material.GetColor(property))),
56 | () => to,
57 | duration,
58 | () => material != null
59 | );
60 | }
61 |
62 | public static ITween TweenColorNoAlpha(this Material material, Color to, int propertyID, float duration)
63 | {
64 | return Tween.To(
65 | () => material.GetColor(propertyID),
66 | current => material.SetColor(propertyID, ColorUtils.ChangeColorKeepingAlpha(current, material.GetColor(propertyID))),
67 | () => to,
68 | duration,
69 | () => material != null
70 | );
71 | }
72 |
73 | public static ITween TweenColorAlpha(this Material material, float to, float duration)
74 | {
75 | float to255 = to * 255.0f;
76 |
77 | return Tween.To(
78 | () => material.color.a,
79 | current => material.color = ColorUtils.ChangeAlpha(material.color, current),
80 | () => to,
81 | duration,
82 | () => material != null
83 | );
84 | }
85 |
86 | public static ITween TweenColorAlpha(this Material material, float to, string property, float duration)
87 | {
88 | float to255 = to * 255.0f;
89 |
90 | return Tween.To(
91 | () => material.GetColor(property).a,
92 | current => material.SetColor(property, ColorUtils.ChangeAlpha(material.GetColor(property), current)),
93 | () => to,
94 | duration,
95 | () => material != null
96 | );
97 | }
98 |
99 | public static ITween TweenColorAlpha(this Material material, float to, int propertyID, float duration)
100 | {
101 | float to255 = to * 255.0f;
102 |
103 | return Tween.To(
104 | () => material.GetColor(propertyID).a,
105 | current => material.SetColor(propertyID, ColorUtils.ChangeAlpha(material.GetColor(propertyID), current)),
106 | () => to,
107 | duration,
108 | () => material != null
109 | );
110 | }
111 |
112 | public static ITween TweenFloat(this Material material, float to, string property, float duration)
113 | {
114 | return Tween.To(
115 | () => material.GetFloat(property),
116 | current => material.SetFloat(property, current),
117 | () => to,
118 | duration,
119 | () => material != null
120 | );
121 | }
122 |
123 | public static ITween TweenFloat(this Material material, float to, int propertyID, float duration)
124 | {
125 | return Tween.To(
126 | () => material.GetFloat(propertyID),
127 | current => material.SetFloat(propertyID, current),
128 | () => to,
129 | duration,
130 | () => material != null
131 | );
132 | }
133 |
134 | public static ITween TweenVector(this Material material, Vector4 to, string property, float duration)
135 | {
136 | return Tween.To(
137 | () => material.GetVector(property),
138 | current => material.SetVector(property, current),
139 | () => to,
140 | duration,
141 | () => material != null
142 | );
143 | }
144 |
145 | public static ITween TweenVector(this Material material, Vector4 to, int propertyID, float duration)
146 | {
147 | return Tween.To(
148 | () => material.GetVector(propertyID),
149 | current => material.SetVector(propertyID, current),
150 | () => to,
151 | duration,
152 | () => material != null
153 | );
154 | }
155 |
156 | public static ITween TweenTextureOffset(this Material material, Vector2 to, float duration)
157 | {
158 | return Tween.To(
159 | () => material.mainTextureOffset,
160 | current => material.mainTextureOffset = current,
161 | () => to,
162 | duration,
163 | () => material != null
164 | );
165 | }
166 |
167 | public static ITween TweenTextureOffset(this Material material, Vector2 to, string property, float duration)
168 | {
169 | return Tween.To(
170 | () => material.GetTextureOffset(property),
171 | current => material.SetTextureOffset(property, current),
172 | () => to,
173 | duration,
174 | () => material != null
175 | );
176 | }
177 |
178 | public static ITween TweenTextureOffset(this Material material, Vector2 to, int propertyID, float duration)
179 | {
180 | return Tween.To(
181 | () => material.GetTextureOffset(propertyID),
182 | current => material.SetTextureOffset(propertyID, current),
183 | () => to,
184 | duration,
185 | () => material != null
186 | );
187 | }
188 |
189 | public static ITween TweenTextureScale(this Material material, Vector2 to, float duration)
190 | {
191 | return Tween.To(
192 | () => material.mainTextureScale,
193 | current => material.mainTextureScale = current,
194 | () => to,
195 | duration,
196 | () => material != null
197 | );
198 | }
199 |
200 | public static ITween TweenTextureScale(this Material material, Vector2 to, string property, float duration)
201 | {
202 | return Tween.To(
203 | () => material.GetTextureScale(property),
204 | current => material.SetTextureScale(property, current),
205 | () => to,
206 | duration,
207 | () => material != null
208 | );
209 | }
210 |
211 | public static ITween TweenTextureScale(this Material material, Vector2 to, int propertyID, float duration)
212 | {
213 | return Tween.To(
214 | () => material.GetTextureScale(propertyID),
215 | current => material.SetTextureScale(propertyID, current),
216 | () => to,
217 | duration,
218 | () => material != null
219 | );
220 | }
221 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenMaterialExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5362a8ea29738874d8e952966ffe479f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenOutlineExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using Juce.Tweening.Utils;
3 | using UnityEngine;
4 | using UnityEngine.UI;
5 |
6 | public static class JuceTweenOutlineExtensions
7 | {
8 | public static ITween TweenColor(this Outline outline, Color to, float duration)
9 | {
10 | return Tween.To(
11 | () => outline.effectColor,
12 | current => outline.effectColor = current,
13 | () => to,
14 | duration,
15 | () => outline != null
16 | );
17 | }
18 |
19 | public static ITween TweenColorNoAlpha(this Outline outline, Color to, float duration)
20 | {
21 | return Tween.To(
22 | () => outline.effectColor,
23 | current => outline.effectColor = ColorUtils.ChangeColorKeepingAlpha(current, outline.effectColor),
24 | () => to,
25 | duration,
26 | () => outline != null
27 | );
28 | }
29 |
30 | public static ITween TweenColorAlpha(this Outline outline, float to, float duration)
31 | {
32 | float to255 = to * 255.0f;
33 |
34 | return Tween.To(
35 | () => outline.effectColor.a,
36 | current => outline.effectColor = ColorUtils.ChangeAlpha(outline.effectColor, current),
37 | () => to,
38 | duration,
39 | () => outline != null
40 | );
41 | }
42 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenOutlineExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 88189d6a07cc03f499c801d8b37d87ef
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenRectTransformExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using UnityEngine;
3 |
4 | public static class JuceTweenRectTransformExtensions
5 | {
6 | public static ITween TweenAnchorMax(this RectTransform rectTransform, Vector2 to, float duration)
7 | {
8 | return Tween.To(
9 | () => rectTransform.anchorMax,
10 | current => rectTransform.anchorMax = current,
11 | () => to,
12 | duration,
13 | () => rectTransform != null
14 | );
15 | }
16 |
17 | public static ITween TweenAnchorMaxX(this RectTransform rectTransform, float to, float duration)
18 | {
19 | return Tween.To(
20 | () => rectTransform.anchorMax.x,
21 | current => rectTransform.anchorMax = new Vector2(current, rectTransform.anchorMax.y),
22 | () => to,
23 | duration,
24 | () => rectTransform != null
25 | );
26 | }
27 |
28 | public static ITween TweenAnchorMaxY(this RectTransform rectTransform, float to, float duration)
29 | {
30 | return Tween.To(
31 | () => rectTransform.anchorMax.y,
32 | current => rectTransform.anchorMax = new Vector2(rectTransform.anchorMax.x, current),
33 | () => to,
34 | duration,
35 | () => rectTransform != null
36 | );
37 | }
38 |
39 | public static ITween TweenAnchorMin(this RectTransform rectTransform, Vector2 to, float duration)
40 | {
41 | return Tween.To(
42 | () => rectTransform.anchorMin,
43 | current => rectTransform.anchorMin = current,
44 | () => to,
45 | duration,
46 | () => rectTransform != null
47 | );
48 | }
49 |
50 | public static ITween TweenAnchorMinX(this RectTransform rectTransform, float to, float duration)
51 | {
52 | return Tween.To(
53 | () => rectTransform.anchorMin.x,
54 | current => rectTransform.anchorMin = new Vector2(current, rectTransform.anchorMin.y),
55 | () => to,
56 | duration,
57 | () => rectTransform != null
58 | );
59 | }
60 |
61 | public static ITween TweenAnchorMinY(this RectTransform rectTransform, float to, float duration)
62 | {
63 | return Tween.To(
64 | () => rectTransform.anchorMin.y,
65 | current => rectTransform.anchorMin = new Vector2(rectTransform.anchorMin.x, current),
66 | () => to,
67 | duration,
68 | () => rectTransform != null
69 | );
70 | }
71 |
72 | public static ITween TweenAnchoredPosition(this RectTransform rectTransform, Vector2 to, float duration)
73 | {
74 | return Tween.To(
75 | () => rectTransform.anchoredPosition,
76 | current => rectTransform.anchoredPosition = current,
77 | () => to,
78 | duration,
79 | () => rectTransform != null
80 | );
81 | }
82 |
83 | public static ITween TweenAnchoredPositionX(this RectTransform rectTransform, float to, float duration)
84 | {
85 | return Tween.To(
86 | () => rectTransform.anchoredPosition.x,
87 | current => rectTransform.anchoredPosition = new Vector2(current, rectTransform.anchoredPosition.y),
88 | () => to,
89 | duration,
90 | () => rectTransform != null
91 | );
92 | }
93 |
94 | public static ITween TweenAnchoredPositionY(this RectTransform rectTransform, float to, float duration)
95 | {
96 | return Tween.To(
97 | () => rectTransform.anchoredPosition.y,
98 | current => rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x, current),
99 | () => to,
100 | duration,
101 | () => rectTransform != null
102 | );
103 | }
104 |
105 | public static ITween TweenAnchoredPosition3D(this RectTransform rectTransform, Vector3 to, float duration)
106 | {
107 | return Tween.To(
108 | () => rectTransform.anchoredPosition3D,
109 | current => rectTransform.anchoredPosition3D = current,
110 | () => to,
111 | duration,
112 | () => rectTransform != null
113 | );
114 | }
115 |
116 | public static ITween TweenPivot(this RectTransform rectTransform, Vector2 to, float duration)
117 | {
118 | return Tween.To(
119 | () => rectTransform.pivot,
120 | current => rectTransform.pivot = current,
121 | () => to,
122 | duration,
123 | () => rectTransform != null
124 | );
125 | }
126 |
127 | public static ITween TweenSizeDelta(this RectTransform rectTransform, Vector2 to, float duration)
128 | {
129 | return Tween.To(
130 | () => rectTransform.sizeDelta,
131 | current => rectTransform.sizeDelta = current,
132 | () => to,
133 | duration,
134 | () => rectTransform != null
135 | );
136 | }
137 |
138 | public static ITween TweenSizeDeltaX(this RectTransform rectTransform, float to, float duration)
139 | {
140 | return Tween.To(
141 | () => rectTransform.sizeDelta.x,
142 | current => rectTransform.sizeDelta = new Vector2(current, rectTransform.sizeDelta.y),
143 | () => to,
144 | duration,
145 | () => rectTransform != null
146 | );
147 | }
148 |
149 | public static ITween TweenSizeDeltaY(this RectTransform rectTransform, float to, float duration)
150 | {
151 | return Tween.To(
152 | () => rectTransform.sizeDelta.y,
153 | current => rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, current),
154 | () => to,
155 | duration,
156 | () => rectTransform != null
157 | );
158 | }
159 |
160 | public static ITween TweenOffsetMax(this RectTransform rectTransform, Vector2 to, float duration)
161 | {
162 | return Tween.To(
163 | () => rectTransform.offsetMax,
164 | current => rectTransform.offsetMax = current,
165 | () => to,
166 | duration,
167 | () => rectTransform != null
168 | );
169 | }
170 |
171 | public static ITween TweenOffsetMaxX(this RectTransform rectTransform, float to, float duration)
172 | {
173 | return Tween.To(
174 | () => rectTransform.offsetMax.x,
175 | current => rectTransform.offsetMax = new Vector2(current, rectTransform.offsetMax.y),
176 | () => to,
177 | duration,
178 | () => rectTransform != null
179 | );
180 | }
181 |
182 | public static ITween TweenOffsetMaxY(this RectTransform rectTransform, float to, float duration)
183 | {
184 | return Tween.To(
185 | () => rectTransform.offsetMax.y,
186 | current => rectTransform.offsetMax = new Vector2(rectTransform.offsetMax.x, current),
187 | () => to,
188 | duration,
189 | () => rectTransform != null
190 | );
191 | }
192 |
193 | public static ITween TweenSizeWithCurrentAnchors(this RectTransform rectTransform, Vector2 to, float duration)
194 | {
195 | return Tween.To(
196 | () => rectTransform.rect.size,
197 | current =>
198 | {
199 | rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, current.x);
200 | rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, current.y);
201 | },
202 | () => to,
203 | duration,
204 | () => rectTransform != null
205 | );
206 | }
207 |
208 | public static ITween TweenSizeXWithCurrentAnchors(this RectTransform rectTransform, float to, float duration)
209 | {
210 | return Tween.To(
211 | () => rectTransform.rect.size.x,
212 | current => rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, current),
213 | () => to,
214 | duration,
215 | () => rectTransform != null
216 | );
217 | }
218 |
219 | public static ITween TweenSizeYWithCurrentAnchors(this RectTransform rectTransform, float to, float duration)
220 | {
221 | return Tween.To(
222 | () => rectTransform.rect.size.y,
223 | current => rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, current),
224 | () => to,
225 | duration,
226 | () => rectTransform != null
227 | );
228 | }
229 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenRectTransformExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7af6c17173028ca4aaf6602b8e108699
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenRigidBody2DExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using UnityEngine;
3 |
4 | public static class JuceTweenRigidBody2DExtensions
5 | {
6 | public static ITween TweenPosition(this Rigidbody2D rigidbody, Vector2 to, float duration)
7 | {
8 | return Tween.To(
9 | () => rigidbody.position,
10 | current => rigidbody.MovePosition(current),
11 | () => to,
12 | duration,
13 | () => rigidbody != null
14 | );
15 | }
16 |
17 | public static ITween TweenRotation(this Rigidbody rigidbody, Vector2 to, float duration)
18 | {
19 | return Tween.To(
20 | () => (Vector2)rigidbody.rotation.eulerAngles,
21 | current => rigidbody.MoveRotation(Quaternion.Euler(current)),
22 | () => to,
23 | duration,
24 | () => rigidbody != null
25 | );
26 | }
27 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenRigidBody2DExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 78a3aca8af89fc94fa9a8f448703cec9
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenRigidbodyExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using UnityEngine;
3 |
4 | public static class JuceTweenRigidbodyExtensions
5 | {
6 | public static ITween TweenPosition(this Rigidbody rigidbody, Vector3 to, float duration)
7 | {
8 | return Tween.To(
9 | () => rigidbody.position,
10 | current => rigidbody.MovePosition(current),
11 | () => to,
12 | duration,
13 | () => rigidbody != null
14 | );
15 | }
16 |
17 | public static ITween TweenRotation(this Rigidbody rigidbody, Vector3 to, float duration)
18 | {
19 | return Tween.To(
20 | () => rigidbody.rotation.eulerAngles,
21 | current => rigidbody.MoveRotation(Quaternion.Euler(current)),
22 | () => to,
23 | duration,
24 | () => rigidbody != null
25 | );
26 | }
27 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenRigidbodyExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ad49168c319ef6b478fcaa88a33e0843
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenScrollRectExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using UnityEngine;
3 | using UnityEngine.UI;
4 |
5 | public static class JuceTweenScrollRectExtensions
6 | {
7 | public static ITween TweenNormalizedPosition(this ScrollRect scrollRect, Vector2 to, float duration)
8 | {
9 | return Tween.To(
10 | () => scrollRect.normalizedPosition,
11 | current => scrollRect.normalizedPosition = current,
12 | () => to,
13 | duration,
14 | () => scrollRect != null
15 | );
16 | }
17 |
18 | public static ITween TweenHorizontalNormalizedPosition(this ScrollRect scrollRect, float to, float duration)
19 | {
20 | return Tween.To(
21 | () => scrollRect.horizontalNormalizedPosition,
22 | current => scrollRect.horizontalNormalizedPosition = current,
23 | () => to,
24 | duration,
25 | () => scrollRect != null
26 | );
27 | }
28 |
29 | public static ITween TweenVerticalNormalizedPosition(this ScrollRect scrollRect, float to, float duration)
30 | {
31 | return Tween.To(
32 | () => scrollRect.verticalNormalizedPosition,
33 | current => scrollRect.verticalNormalizedPosition = current,
34 | () => to,
35 | duration,
36 | () => scrollRect != null
37 | );
38 | }
39 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenScrollRectExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fe2fd9cdc1f57f342aa4ffbf8d60c3d7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenSpriteRendererExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using Juce.Tweening.Utils;
3 | using UnityEngine;
4 |
5 | public static class JuceTweenSpriteRendererExtensions
6 | {
7 | public static ITween TweenColor(this SpriteRenderer spriteRenderer, Color to, float duration)
8 | {
9 | return Tween.To(
10 | () => spriteRenderer.color,
11 | current => spriteRenderer.color = current,
12 | () => to,
13 | duration,
14 | () => spriteRenderer != null
15 | );
16 | }
17 |
18 | public static ITween TweenColorNoAlpha(this SpriteRenderer spriteRenderer, Color to, float duration)
19 | {
20 | return Tween.To(
21 | () => spriteRenderer.color,
22 | current => spriteRenderer.color = ColorUtils.ChangeColorKeepingAlpha(current, spriteRenderer.color),
23 | () => to,
24 | duration,
25 | () => spriteRenderer != null
26 | );
27 | }
28 |
29 | public static ITween TweenColorAlpha(this SpriteRenderer spriteRenderer, float to, float duration)
30 | {
31 | float to255 = to * 255.0f;
32 |
33 | return Tween.To(
34 | () => spriteRenderer.color.a,
35 | current => spriteRenderer.color =
36 | ColorUtils.ChangeAlpha(spriteRenderer.color, current),
37 | () => to,
38 | duration,
39 | () => spriteRenderer != null
40 | );
41 | }
42 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenSpriteRendererExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 39eca3b0809eb7d46b5594f7e907c9e4
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenTextExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using Juce.Tweening.Utils;
3 | using UnityEngine;
4 | using UnityEngine.UI;
5 |
6 | public static class JuceTweenTextExtensions
7 | {
8 | public static ITween TweenColor(this Text text, Color to, float duration)
9 | {
10 | return Tween.To(
11 | () => text.color,
12 | current => text.color = current,
13 | () => to,
14 | duration,
15 | () => text != null
16 | );
17 | }
18 |
19 | public static ITween TweenColorNoAlpha(this Text text, Color to, float duration)
20 | {
21 | return Tween.To(
22 | () => text.color,
23 | current => text.color = ColorUtils.ChangeColorKeepingAlpha(current, text.color),
24 | () => to,
25 | duration,
26 | () => text != null
27 | );
28 | }
29 |
30 | public static ITween TweenColorAlpha(this Text text, float to, float duration)
31 | {
32 | float to255 = to * 255.0f;
33 |
34 | return Tween.To(
35 | () => text.color.a,
36 | current => text.color = ColorUtils.ChangeAlpha(text.color, current),
37 | () => to,
38 | duration,
39 | () => text != null
40 | );
41 | }
42 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenTextExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6f917176f999a7c4fa95a6a66e596934
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenTextMeshProExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using Juce.Tweening.Utils;
3 | using TMPro;
4 | using UnityEngine;
5 |
6 | public static class JuceTweenTextMeshProExtensions
7 | {
8 | public static ITween TweenFontSize(this TextMeshProUGUI textMeshProUGUI, float to, float duration)
9 | {
10 | return Tween.To(
11 | () => textMeshProUGUI.fontSize,
12 | current => textMeshProUGUI.fontSize = current,
13 | () => to,
14 | duration,
15 | () => textMeshProUGUI != null
16 | );
17 | }
18 |
19 | public static ITween TweenColor(this TextMeshProUGUI textMeshProUGUI, Color to, float duration)
20 | {
21 | return Tween.To(
22 | () => textMeshProUGUI.color,
23 | current => textMeshProUGUI.color = current,
24 | () => to,
25 | duration,
26 | () => textMeshProUGUI != null
27 | );
28 | }
29 |
30 | public static ITween TweenColorAlpha(this TextMeshProUGUI textMeshProUGUI, float to, float duration)
31 | {
32 | float to255 = to * 255.0f;
33 |
34 | return Tween.To(
35 | () => textMeshProUGUI.color.a,
36 | current => textMeshProUGUI.color = ColorUtils.ChangeAlpha(textMeshProUGUI.color, current),
37 | () => to,
38 | duration,
39 | () => textMeshProUGUI != null
40 | );
41 | }
42 |
43 | public static ITween TweenFaceColor(this TextMeshProUGUI textMeshProUGUI, Color to, float duration)
44 | {
45 | return Tween.To(
46 | () => textMeshProUGUI.faceColor,
47 | current => textMeshProUGUI.faceColor = current,
48 | () => to,
49 | duration,
50 | () => textMeshProUGUI != null
51 | );
52 | }
53 |
54 | public static ITween TweenFaceColorAlpha(this TextMeshProUGUI textMeshProUGUI, float to, float duration)
55 | {
56 | float to255 = to * 255.0f;
57 |
58 | return Tween.To(
59 | () => textMeshProUGUI.faceColor.a,
60 | current => textMeshProUGUI.faceColor = ColorUtils.ChangeAlpha(textMeshProUGUI.faceColor, current),
61 | () => to,
62 | duration,
63 | () => textMeshProUGUI != null
64 | );
65 | }
66 |
67 | public static ITween TweenMaxVisibleCharacters(this TextMeshProUGUI textMeshProUGUI, int to, float duration)
68 | {
69 | return Tween.To(
70 | () => textMeshProUGUI.maxVisibleCharacters,
71 | current => textMeshProUGUI.maxVisibleCharacters = current,
72 | () => to,
73 | duration,
74 | () => textMeshProUGUI != null
75 | );
76 | }
77 |
78 | public static ITween TweenCharacterSpacing(this TextMeshProUGUI textMeshProUGUI, float to, float duration)
79 | {
80 | return Tween.To(
81 | () => textMeshProUGUI.characterSpacing,
82 | current => textMeshProUGUI.characterSpacing = current,
83 | () => to,
84 | duration,
85 | () => textMeshProUGUI != null
86 | );
87 | }
88 |
89 | public static ITween TweenWordSpacing(this TextMeshProUGUI textMeshProUGUI, float to, float duration)
90 | {
91 | return Tween.To(
92 | () => textMeshProUGUI.wordSpacing,
93 | current => textMeshProUGUI.wordSpacing = current,
94 | () => to,
95 | duration,
96 | () => textMeshProUGUI != null
97 | );
98 | }
99 |
100 | public static ITween TweenLineSpacing(this TextMeshProUGUI textMeshProUGUI, float to, float duration)
101 | {
102 | return Tween.To(
103 | () => textMeshProUGUI.lineSpacing,
104 | current => textMeshProUGUI.lineSpacing = current,
105 | () => to,
106 | duration,
107 | () => textMeshProUGUI != null
108 | );
109 | }
110 |
111 | public static ITween TweenParagraphSpacingSpacing(this TextMeshProUGUI textMeshProUGUI, float to, float duration)
112 | {
113 | return Tween.To(
114 | () => textMeshProUGUI.paragraphSpacing,
115 | current => textMeshProUGUI.paragraphSpacing = current,
116 | () => to,
117 | duration,
118 | () => textMeshProUGUI != null
119 | );
120 | }
121 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenTextMeshProExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0b0db92f0a41e7c4a97be469d526af90
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenTrailRendererExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using Juce.Tweening.Utils;
3 | using UnityEngine;
4 |
5 | public static class JuceTweenTrailRendererExtensions
6 | {
7 | public static ITween TweenTime(this TrailRenderer trailRenderer, float to, float duration)
8 | {
9 | return Tween.To(
10 | () => trailRenderer.time,
11 | current => trailRenderer.time = current,
12 | () => to,
13 | duration,
14 | () => trailRenderer != null
15 | );
16 | }
17 |
18 | public static ITween TweenStartColor(this TrailRenderer trailRenderer, Color to, float duration)
19 | {
20 | return Tween.To(
21 | () => trailRenderer.startColor,
22 | current => trailRenderer.startColor = current,
23 | () => to,
24 | duration,
25 | () => trailRenderer != null
26 | );
27 | }
28 |
29 | public static ITween TweenEndColor(this TrailRenderer trailRenderer, Color to, float duration)
30 | {
31 | return Tween.To(
32 | () => trailRenderer.endColor,
33 | current => trailRenderer.endColor = current,
34 | () => to,
35 | duration,
36 | () => trailRenderer != null
37 | );
38 | }
39 |
40 | public static ITween TweenColor(this TrailRenderer trailRenderer, Color to, float duration)
41 | {
42 | ITween startTween = TweenStartColor(trailRenderer, to, duration);
43 | ITween endTween = TweenEndColor(trailRenderer, to, duration);
44 |
45 | GroupTween groupTween = new GroupTween();
46 | groupTween.Add(startTween);
47 | groupTween.Add(endTween);
48 |
49 | return groupTween;
50 | }
51 |
52 | public static ITween TweenStartColorNoAlpha(this TrailRenderer trailRenderer, Color to, float duration)
53 | {
54 | return Tween.To(
55 | () => trailRenderer.startColor,
56 | current => trailRenderer.startColor = ColorUtils.ChangeColorKeepingAlpha(current, trailRenderer.startColor),
57 | () => to,
58 | duration,
59 | () => trailRenderer != null
60 | );
61 | }
62 |
63 | public static ITween TweenEndColorNoAlpha(this TrailRenderer trailRenderer, Color to, float duration)
64 | {
65 | return Tween.To(
66 | () => trailRenderer.endColor,
67 | current => trailRenderer.endColor = ColorUtils.ChangeColorKeepingAlpha(current, trailRenderer.endColor),
68 | () => to,
69 | duration,
70 | () => trailRenderer != null
71 | );
72 | }
73 |
74 | public static ITween TweenColorNoAlpha(this TrailRenderer trailRenderer, Color to, float duration)
75 | {
76 | ITween startTween = TweenStartColorNoAlpha(trailRenderer, to, duration);
77 | ITween endTween = TweenEndColorNoAlpha(trailRenderer, to, duration);
78 |
79 | GroupTween groupTween = new GroupTween();
80 | groupTween.Add(startTween);
81 | groupTween.Add(endTween);
82 |
83 | return groupTween;
84 | }
85 |
86 | public static ITween TweenStartColorAlpha(this TrailRenderer trailRenderer, float to, float duration)
87 | {
88 | float to255 = to * 255.0f;
89 |
90 | return Tween.To(
91 | () => trailRenderer.startColor.a,
92 | current => trailRenderer.startColor = ColorUtils.ChangeAlpha(trailRenderer.startColor, current),
93 | () => to,
94 | duration,
95 | () => trailRenderer != null
96 | );
97 | }
98 |
99 | public static ITween TweenEndColorAlpha(this TrailRenderer trailRenderer, float to, float duration)
100 | {
101 | float to255 = to * 255.0f;
102 |
103 | return Tween.To(
104 | () => trailRenderer.endColor.a,
105 | current => trailRenderer.endColor = ColorUtils.ChangeAlpha(trailRenderer.endColor, current),
106 | () => to,
107 | duration,
108 | () => trailRenderer != null
109 | );
110 | }
111 |
112 | public static ITween TweenColorAlpha(this TrailRenderer trailRenderer, float to, float duration)
113 | {
114 | ITween startTween = TweenStartColorAlpha(trailRenderer, to, duration);
115 | ITween endTween = TweenEndColorAlpha(trailRenderer, to, duration);
116 |
117 | GroupTween groupTween = new GroupTween();
118 | groupTween.Add(startTween);
119 | groupTween.Add(endTween);
120 |
121 | return groupTween;
122 | }
123 |
124 | public static ITween TweenStartWidth(this TrailRenderer trailRenderer, float to, float duration)
125 | {
126 | return Tween.To(
127 | () => trailRenderer.startWidth,
128 | current => trailRenderer.startWidth = current,
129 | () => to,
130 | duration,
131 | () => trailRenderer != null
132 | );
133 | }
134 |
135 | public static ITween TweenEndWidth(this TrailRenderer trailRenderer, float to, float duration)
136 | {
137 | return Tween.To(
138 | () => trailRenderer.endWidth,
139 | current => trailRenderer.endWidth = current,
140 | () => to,
141 | duration,
142 | () => trailRenderer != null
143 | );
144 | }
145 |
146 | public static ITween TweenWidth(this TrailRenderer trailRenderer, float to, float duration)
147 | {
148 | ITween startTween = TweenStartWidth(trailRenderer, to, duration);
149 | ITween endTween = TweenEndWidth(trailRenderer, to, duration);
150 |
151 | GroupTween groupTween = new GroupTween();
152 | groupTween.Add(startTween);
153 | groupTween.Add(endTween);
154 |
155 | return groupTween;
156 | }
157 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenTrailRendererExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6b0546dd3233e68498624776092fb184
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenTransformExtensions.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening;
2 | using Juce.Tweening.Utils;
3 | using UnityEngine;
4 |
5 | public static class JuceTweenTransformExtensions
6 | {
7 | public static ITween TweenPosition(this Transform transform, Vector3 to, float duration)
8 | {
9 | return Tween.To(
10 | () => transform.position,
11 | current => transform.position = current,
12 | () => to,
13 | duration,
14 | () => transform != null
15 | );
16 | }
17 |
18 | public static ITween TweenPositionX(this Transform transform, float to, float duration)
19 | {
20 | return Tween.To(
21 | () => transform.position.x,
22 | current => transform.position = new Vector3(current, transform.position.y, transform.position.z),
23 | () => to,
24 | duration,
25 | () => transform != null
26 | );
27 | }
28 |
29 | public static ITween TweenPositionY(this Transform transform, float to, float duration)
30 | {
31 | return Tween.To(
32 | () => transform.position.y,
33 | current => transform.position = new Vector3(transform.position.x, current, transform.position.z),
34 | () => to,
35 | duration,
36 | () => transform != null
37 | );
38 | }
39 |
40 | public static ITween TweenPositionZ(this Transform transform, float to, float duration)
41 | {
42 | return Tween.To(
43 | () => transform.position.z,
44 | current => transform.position = new Vector3(transform.position.x, transform.position.y, current),
45 | () => to,
46 | duration,
47 | () => transform != null
48 | );
49 | }
50 |
51 | public static ITween TweenLocalPosition(this Transform transform, Vector3 to, float duration)
52 | {
53 | return Tween.To(
54 | () => transform.localPosition,
55 | current => transform.localPosition = current,
56 | () => to,
57 | duration,
58 | () => transform != null
59 | );
60 | }
61 |
62 | public static ITween TweenLocalPositionX(this Transform transform, float to, float duration)
63 | {
64 | return Tween.To(
65 | () => transform.localPosition.x,
66 | current => transform.localPosition = new Vector3(current, transform.localPosition.y, transform.localPosition.z),
67 | () => to,
68 | duration,
69 | () => transform != null
70 | );
71 | }
72 |
73 | public static ITween TweenLocalPositionY(this Transform transform, float to, float duration)
74 | {
75 | return Tween.To(
76 | () => transform.localPosition.y,
77 | current => transform.localPosition = new Vector3(transform.localPosition.x, current, transform.localPosition.z),
78 | () => to,
79 | duration,
80 | () => transform != null
81 | );
82 | }
83 |
84 | public static ITween TweenLocalPositionZ(this Transform transform, float to, float duration)
85 | {
86 | return Tween.To(
87 | () => transform.localPosition.z,
88 | current => transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, current),
89 | () => to,
90 | duration,
91 | () => transform != null
92 | );
93 | }
94 |
95 | public static ITween TweenRotation(this Transform transform, Vector3 to, float duration, RotationMode mode)
96 | {
97 | return Tween.To(
98 | () => transform.rotation.eulerAngles,
99 | current => transform.rotation = Quaternion.Euler(current),
100 | () => AngleUtils.GetDestinationAngle(transform.rotation.eulerAngles, to, mode),
101 | duration,
102 | () => transform != null
103 | );
104 | }
105 |
106 | public static ITween TweenRotationX(this Transform transform, float to, float duration, RotationMode mode)
107 | {
108 | return Tween.To(
109 | () => transform.rotation.eulerAngles.x,
110 | current => transform.rotation = Quaternion.Euler(current, transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z),
111 | () => AngleUtils.GetDestinationAngle(transform.rotation.eulerAngles.x, to, mode),
112 | duration,
113 | () => transform != null
114 | );
115 | }
116 |
117 | public static ITween TweenRotationY(this Transform transform, float to, float duration, RotationMode mode)
118 | {
119 | return Tween.To(
120 | () => transform.rotation.eulerAngles.y,
121 | current => transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, current, transform.rotation.eulerAngles.z),
122 | () => AngleUtils.GetDestinationAngle(transform.rotation.eulerAngles.y, to, mode),
123 | duration,
124 | () => transform != null
125 | );
126 | }
127 |
128 | public static ITween TweenRotationZ(this Transform transform, float to, float duration, RotationMode mode)
129 | {
130 | return Tween.To(
131 | () => transform.rotation.eulerAngles.z,
132 | current => transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, current),
133 | () => AngleUtils.GetDestinationAngle(transform.rotation.eulerAngles.z, to, mode),
134 | duration,
135 | () => transform != null
136 | );
137 | }
138 |
139 | public static ITween TweenLocalRotation(
140 | this Transform transform,
141 | Vector3 to,
142 | float duration,
143 | RotationMode mode
144 | )
145 | {
146 | return Tween.To(
147 | () => transform.localRotation.eulerAngles,
148 | current => transform.localRotation = Quaternion.Euler(current),
149 | () => AngleUtils.GetDestinationAngle(transform.localRotation.eulerAngles, to, mode),
150 | mode,
151 | duration,
152 | () => transform != null
153 | );
154 | }
155 |
156 | public static ITween TweenLocalRotationX(this Transform transform, float to, float duration, RotationMode mode)
157 | {
158 | return Tween.To(
159 | () => transform.localRotation.eulerAngles.x,
160 | current => transform.localRotation = Quaternion.Euler(current, transform.localRotation.eulerAngles.y, transform.localRotation.eulerAngles.z),
161 | () => AngleUtils.GetDestinationAngle(transform.localRotation.eulerAngles.x, to, mode),
162 | duration,
163 | () => transform != null
164 | );
165 | }
166 |
167 | public static ITween TweenLocalRotationY(this Transform transform, float to, float duration, RotationMode mode)
168 | {
169 | return Tween.To(
170 | () => transform.localRotation.eulerAngles.y,
171 | current => transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles.x, current, transform.localRotation.eulerAngles.z),
172 | () => AngleUtils.GetDestinationAngle(transform.localRotation.eulerAngles.y, to, mode),
173 | duration,
174 | () => transform != null
175 | );
176 | }
177 |
178 | public static ITween TweenLocalRotationZ(this Transform transform, float to, float duration, RotationMode mode)
179 | {
180 | return Tween.To(
181 | () => transform.localRotation.eulerAngles.z,
182 | current => transform.localRotation = Quaternion.Euler(transform.localRotation.eulerAngles.x, transform.localRotation.eulerAngles.y, current),
183 | () => AngleUtils.GetDestinationAngle(transform.localRotation.eulerAngles.z, to, mode),
184 | duration,
185 | () => transform != null
186 | );
187 | }
188 |
189 | public static ITween TweenLocalScale(this Transform transform, Vector3 to, float duration)
190 | {
191 | return Tween.To(
192 | () => transform.localScale,
193 | current => transform.localScale = current,
194 | () => to,
195 | duration,
196 | () => transform != null
197 | );
198 | }
199 |
200 | public static ITween TweenLocalScaleX(this Transform transform, float to, float duration)
201 | {
202 | return Tween.To(
203 | () => transform.localScale.x,
204 | current => transform.localScale = new Vector3(current, transform.localScale.y, transform.localScale.z),
205 | () => to,
206 | duration,
207 | () => transform != null
208 | );
209 | }
210 |
211 | public static ITween TweenLocalScaleY(this Transform transform, float to, float duration)
212 | {
213 | return Tween.To(
214 | () => transform.localScale.y,
215 | current => transform.localScale = new Vector3(transform.localScale.x, current, transform.localScale.z),
216 | () => to,
217 | duration,
218 | () => transform != null
219 | );
220 | }
221 |
222 | public static ITween TweenLocalScaleZ(this Transform transform, float to, float duration)
223 | {
224 | return Tween.To(
225 | () => transform.localScale.z,
226 | current => transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y, current),
227 | () => to,
228 | duration,
229 | () => transform != null
230 | );
231 | }
232 | }
--------------------------------------------------------------------------------
/Runtime/Extensions/JuceTweenTransformExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: aef6a5b34cf8c344a938071ee94d050f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Interpolators.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6276f2791486b414887c7397af0303eb
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/Interpolators/ColorInterpolator.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using System;
3 | using UnityEngine;
4 |
5 | namespace Juce.Tweening.Interpolators
6 | {
7 | public class ColorInterpolator : IInterpolator
8 | {
9 | public static readonly ColorInterpolator Instance = new ColorInterpolator();
10 |
11 | private ColorInterpolator()
12 | {
13 |
14 | }
15 |
16 | public Color Evaluate(
17 | Color initialValue,
18 | Color finalValue,
19 | float time,
20 | EaseDelegate easeFunction
21 | )
22 | {
23 | if (easeFunction == null)
24 | {
25 | throw new ArgumentNullException($"Tried to Evaluate with a " +
26 | $"null {nameof(EaseDelegate)} on {nameof(ColorInterpolator)}");
27 | }
28 |
29 | return new Color(
30 | easeFunction(initialValue.r, finalValue.r, time),
31 | easeFunction(initialValue.g, finalValue.g, time),
32 | easeFunction(initialValue.b, finalValue.b, time),
33 | easeFunction(initialValue.a, finalValue.a, time)
34 | );
35 | }
36 |
37 | public Color Subtract(Color initialValue, Color finalValue)
38 | {
39 | return finalValue - initialValue;
40 | }
41 |
42 | public Color Add(Color initialValue, Color finalValue)
43 | {
44 | return finalValue + initialValue;
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/Runtime/Interpolators/ColorInterpolator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a6e480ecd0f8fce4fbaf84fb35f4f61f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Interpolators/FloatInterpolator.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using System;
3 |
4 | namespace Juce.Tweening.Interpolators
5 | {
6 | public class FloatInterpolator : IInterpolator
7 | {
8 | public static readonly FloatInterpolator Instance = new FloatInterpolator();
9 |
10 | private FloatInterpolator()
11 | {
12 |
13 | }
14 |
15 | public float Evaluate(
16 | float initialValue,
17 | float finalValue,
18 | float time,
19 | EaseDelegate easeFunction
20 | )
21 | {
22 | if (easeFunction == null)
23 | {
24 | throw new ArgumentNullException($"Tried to Evaluate with a " +
25 | $"null {nameof(EaseDelegate)} on {nameof(FloatInterpolator)}");
26 | }
27 |
28 | return easeFunction(initialValue, finalValue, time);
29 | }
30 |
31 | public float Subtract(float initialValue, float finalValue)
32 | {
33 | return finalValue - initialValue;
34 | }
35 |
36 | public float Add(float initialValue, float finalValue)
37 | {
38 | return finalValue + initialValue;
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/Runtime/Interpolators/FloatInterpolator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6dd846aa1129c6c478343b20579106c4
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Interpolators/IInterpolator.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 |
3 | namespace Juce.Tweening.Interpolators
4 | {
5 | public interface IInterpolator
6 | {
7 | T Evaluate(T initialValue, T finalValue, float time, EaseDelegate easeFunction);
8 | T Subtract(T initialValue, T finalValue);
9 | T Add(T initialValue, T finalValue);
10 | }
11 | }
--------------------------------------------------------------------------------
/Runtime/Interpolators/IInterpolator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8ecf420a72315f549a1eb96406a82b01
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Interpolators/IntInterpolator.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using System;
3 |
4 | namespace Juce.Tweening.Interpolators
5 | {
6 | public class IntInterpolator : IInterpolator
7 | {
8 | public static readonly IntInterpolator Instance = new IntInterpolator();
9 |
10 | private IntInterpolator()
11 | {
12 |
13 | }
14 |
15 | public int Evaluate(
16 | int initialValue,
17 | int finalValue,
18 | float time,
19 | EaseDelegate easeFunction
20 | )
21 | {
22 | if (easeFunction == null)
23 | {
24 | throw new ArgumentNullException($"Tried to Evaluate with a " +
25 | $"null {nameof(EaseDelegate)} on {nameof(IntInterpolator)}");
26 | }
27 |
28 | return (int)easeFunction(initialValue, finalValue, time);
29 | }
30 |
31 | public int Subtract(int initialValue, int finalValue)
32 | {
33 | return finalValue - initialValue;
34 | }
35 |
36 | public int Add(int initialValue, int finalValue)
37 | {
38 | return finalValue + initialValue;
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/Runtime/Interpolators/IntInterpolator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fff6a884b56919f4aa3849f5e2be3706
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Interpolators/QuaternionInterpolator.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using System;
3 | using UnityEngine;
4 |
5 | namespace Juce.Tweening.Interpolators
6 | {
7 | public class QuaternionInterpolator : IInterpolator
8 | {
9 | public static readonly QuaternionInterpolator Instance = new QuaternionInterpolator();
10 |
11 | private QuaternionInterpolator()
12 | {
13 |
14 | }
15 |
16 | public Quaternion Evaluate(
17 | Quaternion initialValue,
18 | Quaternion finalValue,
19 | float time,
20 | EaseDelegate easeFunction
21 | )
22 | {
23 | if (easeFunction == null)
24 | {
25 | throw new ArgumentNullException($"Tried to Evaluate with a " +
26 | $"null {nameof(EaseDelegate)} on {nameof(ColorInterpolator)}");
27 | }
28 |
29 | float curveTime = easeFunction(0f, 1f, time);
30 |
31 | return Quaternion.Slerp(initialValue, finalValue, curveTime);
32 | }
33 |
34 | public Quaternion Subtract(Quaternion initialValue, Quaternion finalValue)
35 | {
36 | return Quaternion.Inverse(initialValue) * finalValue;
37 | }
38 |
39 | public Quaternion Add(Quaternion initialValue, Quaternion finalValue)
40 | {
41 | return initialValue * finalValue;
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/Runtime/Interpolators/QuaternionInterpolator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5553042c454532c4caf2adf010baffe9
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Interpolators/RectInterpolator.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using System;
3 | using UnityEngine;
4 |
5 | namespace Juce.Tweening.Interpolators
6 | {
7 | public class RectInterpolator : IInterpolator
8 | {
9 | public static readonly RectInterpolator Instance = new RectInterpolator();
10 |
11 | private RectInterpolator()
12 | {
13 |
14 | }
15 |
16 | public Rect Evaluate(
17 | Rect initialValue,
18 | Rect finalValue,
19 | float time,
20 | EaseDelegate easeFunction
21 | )
22 | {
23 | if (easeFunction == null)
24 | {
25 | throw new ArgumentNullException($"Tried to Evaluate with a " +
26 | $"null {nameof(EaseDelegate)} on {nameof(Rect)}");
27 | }
28 |
29 | return new Rect(
30 | easeFunction(initialValue.x, finalValue.x, time),
31 | easeFunction(initialValue.y, finalValue.y, time),
32 | easeFunction(initialValue.width, finalValue.width, time),
33 | easeFunction(initialValue.height, finalValue.height, time)
34 | );
35 | }
36 |
37 | public Rect Subtract(Rect initialValue, Rect finalValue)
38 | {
39 | return new Rect(finalValue.x - initialValue.x,
40 | finalValue.y - initialValue.y,
41 | finalValue.width - initialValue.width,
42 | finalValue.height - initialValue.height
43 | );
44 | }
45 |
46 | public Rect Add(Rect initialValue, Rect finalValue)
47 | {
48 | return new Rect(finalValue.x + initialValue.x,
49 | finalValue.y + initialValue.y,
50 | finalValue.width + initialValue.width,
51 | finalValue.height + initialValue.height
52 | );
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/Runtime/Interpolators/RectInterpolator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4e97f463ee1aec64b9502edbe33f1118
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Interpolators/Vector2Interpolator.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using System;
3 | using UnityEngine;
4 |
5 | namespace Juce.Tweening.Interpolators
6 | {
7 | public class Vector2Interpolator : IInterpolator
8 | {
9 | public static readonly Vector2Interpolator Instance = new Vector2Interpolator();
10 |
11 | private Vector2Interpolator()
12 | {
13 |
14 | }
15 |
16 | public Vector2 Evaluate(
17 | Vector2 initialValue,
18 | Vector2 finalValue,
19 | float time,
20 | EaseDelegate easeFunction
21 | )
22 | {
23 | if (easeFunction == null)
24 | {
25 | throw new ArgumentNullException($"Tried to Evaluate with a " +
26 | $"null {nameof(EaseDelegate)} on {nameof(Vector2Interpolator)}");
27 | }
28 |
29 | return new Vector2(
30 | easeFunction(initialValue.x, finalValue.x, time),
31 | easeFunction(initialValue.y, finalValue.y, time)
32 | );
33 | }
34 |
35 | public Vector2 Subtract(Vector2 initialValue, Vector2 finalValue)
36 | {
37 | return finalValue - initialValue;
38 | }
39 |
40 | public Vector2 Add(Vector2 initialValue, Vector2 finalValue)
41 | {
42 | return finalValue + initialValue;
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/Runtime/Interpolators/Vector2Interpolator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8bac7d5a4f133204bbd6183d8e833abb
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Interpolators/Vector3Interpolator.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using System;
3 | using UnityEngine;
4 |
5 | namespace Juce.Tweening.Interpolators
6 | {
7 | public class Vector3Interpolator : IInterpolator
8 | {
9 | public static readonly Vector3Interpolator Instance = new Vector3Interpolator();
10 |
11 | private Vector3Interpolator()
12 | {
13 |
14 | }
15 |
16 | public Vector3 Evaluate(
17 | Vector3 initialValue,
18 | Vector3 finalValue,
19 | float time,
20 | EaseDelegate easeFunction
21 | )
22 | {
23 | if (easeFunction == null)
24 | {
25 | throw new ArgumentNullException($"Tried to Evaluate with a " +
26 | $"null {nameof(EaseDelegate)} on {nameof(Vector3Interpolator)}");
27 | }
28 |
29 | return new Vector3(
30 | easeFunction(initialValue.x, finalValue.x, time),
31 | easeFunction(initialValue.y, finalValue.y, time),
32 | easeFunction(initialValue.z, finalValue.z, time)
33 | );
34 | }
35 |
36 | public Vector3 Subtract(Vector3 initialValue, Vector3 finalValue)
37 | {
38 | return finalValue - initialValue;
39 | }
40 |
41 | public Vector3 Add(Vector3 initialValue, Vector3 finalValue)
42 | {
43 | return finalValue + initialValue;
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/Runtime/Interpolators/Vector3Interpolator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 60b02d36fa8c13f4085c78a9c59bb2ac
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Interpolators/Vector3RotationInterpolator.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using Juce.Tweening.Utils;
3 | using System;
4 | using UnityEngine;
5 |
6 | namespace Juce.Tweening.Interpolators
7 | {
8 | public class Vector3RotationInterpolator : IInterpolator
9 | {
10 | private readonly RotationMode rotationMode;
11 |
12 | public Vector3RotationInterpolator(RotationMode rotationMode)
13 | {
14 | this.rotationMode = rotationMode;
15 | }
16 |
17 | public Vector3 Evaluate(
18 | Vector3 initialValue,
19 | Vector3 finalValue,
20 | float time,
21 | EaseDelegate easeFunction
22 | )
23 | {
24 | if (easeFunction == null)
25 | {
26 | throw new ArgumentNullException($"Tried to Evaluate with a " +
27 | $"null {nameof(EaseDelegate)} on {nameof(Vector3Interpolator)}");
28 | }
29 |
30 | if (rotationMode == RotationMode.Fast)
31 | {
32 | Vector3 deltaAngle = AngleUtils.DeltaAngle(initialValue, finalValue);
33 |
34 | finalValue = initialValue + deltaAngle;
35 | }
36 |
37 | return new Vector3(
38 | easeFunction(initialValue.x, finalValue.x, time),
39 | easeFunction(initialValue.y, finalValue.y, time),
40 | easeFunction(initialValue.z, finalValue.z, time)
41 | );
42 | }
43 |
44 | public Vector3 Subtract(Vector3 initialValue, Vector3 finalValue)
45 | {
46 | return finalValue - initialValue;
47 | }
48 |
49 | public Vector3 Add(Vector3 firstValue, Vector3 secondValue)
50 | {
51 | return secondValue + firstValue;
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/Runtime/Interpolators/Vector3RotationInterpolator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 01648616fe9e91b4491293c98ac2699a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Interpolators/Vector4Interpolator.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using System;
3 | using UnityEngine;
4 |
5 | namespace Juce.Tweening.Interpolators
6 | {
7 | public class Vector4Interpolator : IInterpolator
8 | {
9 | public static readonly Vector4Interpolator Instance = new Vector4Interpolator();
10 |
11 | private Vector4Interpolator()
12 | {
13 |
14 | }
15 |
16 | public Vector4 Evaluate(
17 | Vector4 initialValue,
18 | Vector4 finalValue,
19 | float time,
20 | EaseDelegate easeFunction
21 | )
22 | {
23 | if (easeFunction == null)
24 | {
25 | throw new ArgumentNullException($"Tried to Evaluate with a " +
26 | $"null {nameof(EaseDelegate)} on {nameof(Vector4Interpolator)}");
27 | }
28 |
29 | return new Vector4(
30 | easeFunction(initialValue.x, finalValue.x, time),
31 | easeFunction(initialValue.y, finalValue.y, time),
32 | easeFunction(initialValue.z, finalValue.z, time),
33 | easeFunction(initialValue.z, finalValue.w, time)
34 | );
35 | }
36 |
37 | public Vector4 Subtract(Vector4 initialValue, Vector4 finalValue)
38 | {
39 | return finalValue - initialValue;
40 | }
41 |
42 | public Vector4 Add(Vector4 initialValue, Vector4 finalValue)
43 | {
44 | return finalValue + initialValue;
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/Runtime/Interpolators/Vector4Interpolator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 066356c4c0630bc4182433e8d3fd5a1d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Juce.Tween.Runtime.asmdef:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Juce.Tween.Runtime",
3 | "references": [
4 | "GUID:9a64ff96d3b16d7498c8f46b660d81a0",
5 | "GUID:6055be8ebefd69e48b49212b09b47b2f"
6 | ],
7 | "includePlatforms": [],
8 | "excludePlatforms": [],
9 | "allowUnsafeCode": false,
10 | "overrideReferences": false,
11 | "precompiledReferences": [],
12 | "autoReferenced": true,
13 | "defineConstraints": [],
14 | "versionDefines": [],
15 | "noEngineReferences": false
16 | }
--------------------------------------------------------------------------------
/Runtime/Juce.Tween.Runtime.asmdef.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1765b9cf2ac90c24c957166617f61cc1
3 | AssemblyDefinitionImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Runtime/JuceTween.cs:
--------------------------------------------------------------------------------
1 | using Juce.Utils.Singletons;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Diagnostics;
5 |
6 | namespace Juce.Tweening
7 | {
8 | public class JuceTween : AutoStartMonoSingleton
9 | {
10 | private readonly List aliveTweens = new List();
11 | private readonly List tweensToAdd = new List();
12 | private readonly List tweensToRemove = new List();
13 |
14 | private readonly Stopwatch updateStopwatch = new Stopwatch();
15 |
16 | private float timeScale;
17 |
18 | public float UpdateMilliseconds { get; private set; }
19 |
20 | public static float TimeScale
21 | {
22 | get { return Instance.timeScale; }
23 | set { Instance.timeScale = value; }
24 | }
25 |
26 | private void Awake()
27 | {
28 | Init();
29 | }
30 |
31 | private void Update()
32 | {
33 | UpdateTweens();
34 | }
35 |
36 | private void OnDestroy()
37 | {
38 | Dispose();
39 | }
40 |
41 | private void Init()
42 | {
43 | timeScale = 1.0f;
44 | }
45 |
46 | private void Dispose()
47 | {
48 | aliveTweens.Clear();
49 | tweensToAdd.Clear();
50 | tweensToRemove.Clear();
51 | }
52 |
53 | public static ISequenceTween Sequence()
54 | {
55 | return new SequenceTween();
56 | }
57 |
58 | public int GetAliveTweensCounts()
59 | {
60 | int aliveTweensCount = 0;
61 |
62 | for (int i = 0; i < aliveTweens.Count; ++i)
63 | {
64 | aliveTweensCount += aliveTweens[i].GetTweensCount();
65 | }
66 |
67 | return aliveTweensCount;
68 | }
69 |
70 | public int GetPlayingTweensCounts()
71 | {
72 | int aliveTweensCount = 0;
73 |
74 | for (int i = 0; i < aliveTweens.Count; ++i)
75 | {
76 | aliveTweensCount += aliveTweens[i].GetPlayingTweensCount();
77 | }
78 |
79 | return aliveTweensCount;
80 | }
81 |
82 | internal static void Add(Tween tween)
83 | {
84 | if(InstanceWasDestroyed)
85 | {
86 | return;
87 | }
88 |
89 | if (tween == null)
90 | {
91 | throw new ArgumentNullException($"Tried to play a null {nameof(Tween)} on {nameof(JuceTween)} instance");
92 | }
93 |
94 | if(tween.IsNested)
95 | {
96 | return;
97 | }
98 |
99 | if(tween.IsAlive)
100 | {
101 | Instance.TryStartTween(tween);
102 |
103 | return;
104 | }
105 |
106 | tween.IsAlive = true;
107 |
108 | Instance.tweensToAdd.Add(tween);
109 |
110 | Instance.TryStartTween(tween);
111 | }
112 |
113 | private void TryStartTween(Tween tween)
114 | {
115 | if (!tween.IsPlaying)
116 | {
117 | tween.Start();
118 | }
119 | }
120 |
121 | private void UpdateTweens()
122 | {
123 | updateStopwatch.Restart();
124 |
125 | foreach(Tween tween in tweensToAdd)
126 | {
127 | aliveTweens.Add(tween);
128 | }
129 |
130 | tweensToAdd.Clear();
131 |
132 | foreach (Tween tween in aliveTweens)
133 | {
134 | if(tween.IsPlaying && !tween.IsCompleted)
135 | {
136 | tween.Update();
137 | }
138 |
139 | if(!tween.IsPlaying || tween.IsCompleted || tween.IsNested)
140 | {
141 | tweensToRemove.Add(tween);
142 | }
143 | }
144 |
145 | foreach(Tween tween in tweensToRemove)
146 | {
147 | tween.IsAlive = false;
148 |
149 | aliveTweens.Remove(tween);
150 | tweensToAdd.Remove(tween);
151 | }
152 |
153 | tweensToRemove.Clear();
154 |
155 | updateStopwatch.Stop();
156 |
157 | UpdateMilliseconds = updateStopwatch.ElapsedMilliseconds;
158 | }
159 | }
160 | }
--------------------------------------------------------------------------------
/Runtime/JuceTween.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8ecaea46f9006ae46b9a32c9e2052196
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Repositories.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bfa531771f459ca42916f33d0ce88c0f
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/Repositories/SequenceTweenTweenRepository.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Juce.Tweening.Repositories
4 | {
5 | public class SequenceTweenTweenRepository
6 | {
7 | private readonly List tweens = new List();
8 |
9 | private bool creatingGroupTween;
10 |
11 | public IReadOnlyList Tweens => tweens;
12 |
13 | public void Append(Tween tween)
14 | {
15 | creatingGroupTween = false;
16 |
17 | tweens.Add(tween);
18 | }
19 |
20 | public void Join(Tween tween)
21 | {
22 | if(creatingGroupTween)
23 | {
24 | GroupTween groupTween = (GroupTween)tweens[tweens.Count - 1];
25 |
26 | groupTween.Add(tween);
27 |
28 | return;
29 | }
30 |
31 | creatingGroupTween = true;
32 |
33 | GroupTween newGroupTween = new GroupTween();
34 |
35 | newGroupTween.Add(tween);
36 |
37 | tweens.Add(newGroupTween);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Runtime/Repositories/SequenceTweenTweenRepository.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f2d437c2b9d7bcf438ec88acaa9215f2
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweeners.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b871b483a4b45cb4a94b79d5cf9f10a7
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/Tweeners/ColorTweener.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Interpolators;
2 | using UnityEngine;
3 |
4 | namespace Juce.Tweening.Tweeners
5 | {
6 | public class ColorTweener : Tweener
7 | {
8 | public ColorTweener(
9 | Getter currValueGetter,
10 | Setter setter,
11 | Getter finalValueGetter,
12 | float duration,
13 | Validation validation
14 | )
15 | : base(currValueGetter,
16 | setter,
17 | finalValueGetter,
18 | duration,
19 | ColorInterpolator.Instance,
20 | validation
21 | )
22 | {
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/Runtime/Tweeners/ColorTweener.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c44e80cf62714e44c82235aa20e26a8f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweeners/FloatTweener.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Interpolators;
2 |
3 | namespace Juce.Tweening.Tweeners
4 | {
5 | public class FloatTweener : Tweener
6 | {
7 | public FloatTweener(
8 | Getter currValueGetter,
9 | Setter setter,
10 | Getter finalValueGetter,
11 | float duration,
12 | Validation validation
13 | )
14 | : base(
15 | currValueGetter,
16 | setter,
17 | finalValueGetter,
18 | duration,
19 | FloatInterpolator.Instance,
20 | validation
21 | )
22 | {
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/Runtime/Tweeners/FloatTweener.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 02fd432055a8c3b46a310712a5db713e
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweeners/ITweener.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 |
3 | namespace Juce.Tweening.Tweeners
4 | {
5 | public interface ITweener
6 | {
7 | float Duration { get; }
8 | float Elapsed { get; }
9 |
10 | bool UseGeneralTimeScale { get; set; }
11 | float TimeScale { get; set; }
12 |
13 | bool IsPlaying { get; }
14 |
15 | void SetEase(EaseDelegate easeFunction);
16 |
17 | void Reset(ResetMode mode);
18 | void Start();
19 | void Update();
20 | void Complete();
21 | void Kill();
22 | }
23 | }
--------------------------------------------------------------------------------
/Runtime/Tweeners/ITweener.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 901378c6b0736514f8bce9ae34d1a1f6
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweeners/IntTweener.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Interpolators;
2 |
3 | namespace Juce.Tweening.Tweeners
4 | {
5 | public class IntTweener : Tweener
6 | {
7 | internal IntTweener(
8 | Getter currValueGetter,
9 | Setter setter,
10 | Getter finalValueGetter,
11 | float duration,
12 | Validation validation
13 | )
14 | : base(
15 | currValueGetter,
16 | setter,
17 | finalValueGetter,
18 | duration,
19 | IntInterpolator.Instance,
20 | validation
21 | )
22 | {
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/Runtime/Tweeners/IntTweener.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e99000f572a49f9409ad8038c388498a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweeners/QuaternionTweener.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Interpolators;
2 | using UnityEngine;
3 |
4 | namespace Juce.Tweening.Tweeners
5 | {
6 | public class QuaternionTweener : Tweener
7 | {
8 | public QuaternionTweener(
9 | Getter currValueGetter,
10 | Setter setter,
11 | Getter finalValueGetter,
12 | float duration,
13 | Validation validation
14 | )
15 | : base(
16 | currValueGetter,
17 | setter,
18 | finalValueGetter,
19 | duration,
20 | QuaternionInterpolator.Instance,
21 | validation
22 | )
23 | {
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/Runtime/Tweeners/QuaternionTweener.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5637520f66e781144a881abfc290600e
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweeners/RectTweener.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Interpolators;
2 | using UnityEngine;
3 |
4 | namespace Juce.Tweening.Tweeners
5 | {
6 | public class RectTweener : Tweener
7 | {
8 | public RectTweener(
9 | Getter currValueGetter,
10 | Setter setter,
11 | Getter finalValueGetter,
12 | float duration,
13 | Validation validation
14 | )
15 | : base(
16 | currValueGetter,
17 | setter,
18 | finalValueGetter,
19 | duration,
20 | RectInterpolator.Instance,
21 | validation
22 | )
23 | {
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/Runtime/Tweeners/RectTweener.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e3fda4bb0db5dbb4db25f1a0e58a2341
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweeners/Tweener.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using Juce.Tweening.Interpolators;
3 | using UnityEngine;
4 |
5 | namespace Juce.Tweening.Tweeners
6 | {
7 | public abstract class Tweener : ITweener
8 | {
9 | public delegate void Setter(T currentValue);
10 | public delegate T Getter();
11 | public delegate bool Validation();
12 |
13 | private readonly IInterpolator interpolator;
14 |
15 | private readonly Getter currValueGetter;
16 | private readonly Setter setter;
17 | private readonly Getter finalValueGetter;
18 | private readonly Validation validation;
19 |
20 | private bool firstTime;
21 | private T firstTimeInitialValue;
22 | private T firstTimeFinalValue;
23 |
24 | private T initialValue;
25 | private T finalValue;
26 | private T currentValue;
27 |
28 | private EaseDelegate easeFunction;
29 |
30 | public bool IsPlaying { get; protected set; }
31 |
32 | public float Duration { get; }
33 | public float Elapsed { get; private set; }
34 |
35 | public bool UseGeneralTimeScale { get; set; }
36 | public float TimeScale { get; set; }
37 |
38 | public Tweener(
39 | Getter currValueGetter,
40 | Setter setter,
41 | Getter finalValueGetter,
42 | float duration,
43 | IInterpolator interpolator,
44 | Validation validation
45 | )
46 | {
47 | this.currValueGetter = currValueGetter;
48 | this.setter = setter;
49 | this.finalValueGetter = finalValueGetter;
50 | Duration = Mathf.Max(duration, 0.0f);
51 | this.interpolator = interpolator;
52 | this.validation = validation;
53 |
54 | firstTime = true;
55 |
56 | UseGeneralTimeScale = true;
57 | TimeScale = 1.0f;
58 | }
59 |
60 | public void Start()
61 | {
62 | if (IsPlaying)
63 | {
64 | return;
65 | }
66 |
67 | IsPlaying = true;
68 |
69 | Elapsed = 0.0f;
70 |
71 | bool valid = Validate();
72 |
73 | if(!valid)
74 | {
75 | Kill();
76 |
77 | return;
78 | }
79 |
80 | initialValue = currValueGetter.Invoke();
81 |
82 | if (firstTime)
83 | {
84 | firstTime = false;
85 |
86 | finalValue = finalValueGetter.Invoke();
87 |
88 | firstTimeInitialValue = initialValue;
89 | firstTimeFinalValue = finalValue;
90 | }
91 |
92 | CompleteIfInstant();
93 | }
94 |
95 | public void Reset(ResetMode mode)
96 | {
97 | if (firstTime)
98 | {
99 | return;
100 | }
101 |
102 | bool valid = Validate();
103 |
104 | if (!valid)
105 | {
106 | Kill();
107 |
108 | return;
109 | }
110 |
111 | Elapsed = 0.0f;
112 |
113 | switch (mode)
114 | {
115 | case ResetMode.InitialValues:
116 | {
117 | setter(firstTimeInitialValue);
118 | finalValue = firstTimeFinalValue;
119 | }
120 | break;
121 |
122 | case ResetMode.IncrementalValues:
123 | {
124 | T difference = interpolator.Subtract(firstTimeInitialValue, firstTimeFinalValue);
125 |
126 | finalValue = interpolator.Add(currentValue, difference);
127 | }
128 | break;
129 |
130 | case ResetMode.CurrentValues:
131 | {
132 | finalValue = firstTimeFinalValue;
133 | }
134 | break;
135 | }
136 | }
137 |
138 | public void Update()
139 | {
140 | if (!IsPlaying)
141 | {
142 | return;
143 | }
144 |
145 | bool valid = Validate();
146 |
147 | if (!valid)
148 | {
149 | Kill();
150 |
151 | return;
152 | }
153 |
154 | float generalTimeScale = UseGeneralTimeScale ? JuceTween.TimeScale : 1.0f;
155 |
156 | float dt = Time.unscaledDeltaTime * generalTimeScale * TimeScale;
157 |
158 | Elapsed += dt;
159 |
160 | if (Elapsed < Duration)
161 | {
162 | float timeNormalized = Elapsed / Duration;
163 |
164 | currentValue = interpolator.Evaluate(initialValue, finalValue, timeNormalized, easeFunction);
165 |
166 | setter(currentValue);
167 | }
168 | else
169 | {
170 | Complete();
171 | }
172 | }
173 |
174 | public void Complete()
175 | {
176 | T newValue = interpolator.Evaluate(initialValue, finalValue, 1.0f, easeFunction);
177 |
178 | setter(newValue);
179 |
180 | IsPlaying = false;
181 | }
182 |
183 | public void Kill()
184 | {
185 | IsPlaying = false;
186 | }
187 |
188 | public void SetEase(EaseDelegate easeFunction)
189 | {
190 | this.easeFunction = easeFunction;
191 | }
192 |
193 | private void CompleteIfInstant()
194 | {
195 | if (!IsPlaying)
196 | {
197 | return;
198 | }
199 |
200 | bool isInstant = Duration == 0.0f;
201 |
202 | if (isInstant)
203 | {
204 | Complete();
205 | }
206 | }
207 |
208 | private bool Validate()
209 | {
210 | if(validation == null)
211 | {
212 | return true;
213 | }
214 |
215 | return validation.Invoke();
216 | }
217 | }
218 | }
--------------------------------------------------------------------------------
/Runtime/Tweeners/Tweener.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5fbf47b5c58b09e41972d4dc4f7cc6d9
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweeners/Vector2Tweener.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Interpolators;
2 | using UnityEngine;
3 |
4 | namespace Juce.Tweening.Tweeners
5 | {
6 | public class Vector2Tweener : Tweener
7 | {
8 | public Vector2Tweener(
9 | Getter currValueGetter,
10 | Setter setter,
11 | Getter finalValueGetter,
12 | float duration,
13 | Validation validation
14 | )
15 | : base(
16 | currValueGetter,
17 | setter,
18 | finalValueGetter,
19 | duration,
20 | Vector2Interpolator.Instance,
21 | validation
22 | )
23 | {
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/Runtime/Tweeners/Vector2Tweener.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5dcf178f4382dd140be9736ada3f18f2
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweeners/Vector3RotationTweener.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Interpolators;
2 | using UnityEngine;
3 |
4 | namespace Juce.Tweening.Tweeners
5 | {
6 | public class Vector3RotationTweener : Tweener
7 | {
8 | public Vector3RotationTweener(
9 | Getter currValueGetter,
10 | Setter setter,
11 | Getter finalValueGetter,
12 | RotationMode rotationMode,
13 | float duration,
14 | Validation validation
15 | )
16 | : base(
17 | currValueGetter,
18 | setter,
19 | finalValueGetter,
20 | duration,
21 | new Vector3RotationInterpolator(rotationMode),
22 | validation
23 | )
24 | {
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/Runtime/Tweeners/Vector3RotationTweener.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 583703635dd35554bbdace6b6f285e4b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweeners/Vector3Tweener.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Interpolators;
2 | using UnityEngine;
3 |
4 | namespace Juce.Tweening.Tweeners
5 | {
6 | public class Vector3Tweener : Tweener
7 | {
8 | public Vector3Tweener(
9 | Getter currValueGetter,
10 | Setter setter,
11 | Getter finalValueGetter,
12 | float duration,
13 | Validation validation
14 | )
15 | : base(
16 | currValueGetter,
17 | setter,
18 | finalValueGetter,
19 | duration,
20 | Vector3Interpolator.Instance,
21 | validation
22 | )
23 | {
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/Runtime/Tweeners/Vector3Tweener.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 39819ea83d26cd4488a8949fff2b4aa4
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweeners/Vector4Tweener.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Interpolators;
2 | using UnityEngine;
3 |
4 | namespace Juce.Tweening.Tweeners
5 | {
6 | public class Vector4Tweener : Tweener
7 | {
8 | public Vector4Tweener(
9 | Getter currValueGetter,
10 | Setter setter,
11 | Getter finalValueGetter,
12 | float duration,
13 | Validation validation
14 | )
15 | : base(
16 | currValueGetter,
17 | setter,
18 | finalValueGetter,
19 | duration,
20 | Vector4Interpolator.Instance,
21 | validation
22 | )
23 | {
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/Runtime/Tweeners/Vector4Tweener.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 47f837a2457fa41428f6eed5ef3d1bcb
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweens.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5981de89daf80a04f895d26159a646a4
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/Tweens/CallbackTween.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using System;
3 |
4 | namespace Juce.Tweening
5 | {
6 | public class CallbackTween : Tween
7 | {
8 | private readonly Action action;
9 | private readonly bool callIfCompletingInstantly;
10 |
11 | protected override bool Loopable => false;
12 |
13 | public CallbackTween(Action action, bool callIfCompletingInstantly)
14 | {
15 | this.action = action;
16 | this.callIfCompletingInstantly = callIfCompletingInstantly;
17 | }
18 |
19 | protected override void OnTweenStart(bool isCompletingInstantly)
20 | {
21 | bool canCall = !isCompletingInstantly || callIfCompletingInstantly;
22 |
23 | if (canCall)
24 | {
25 | action?.Invoke();
26 | }
27 |
28 | NewMarkCompleted();
29 | }
30 |
31 | protected override void OnTweenUpdate()
32 | {
33 |
34 | }
35 |
36 | protected override void OnTweenKill()
37 | {
38 |
39 | }
40 |
41 | protected override void OnTweenComplete()
42 | {
43 |
44 | }
45 |
46 | protected override void OnTweenReset(bool kill, ResetMode resetMode)
47 | {
48 |
49 | }
50 |
51 | protected override void OnTweenStartLoop(ResetMode loopResetMode)
52 | {
53 |
54 | }
55 |
56 | public override void OnTimeScaleChanges(float timeScale)
57 | {
58 |
59 | }
60 |
61 | public override void OnEaseDelegateChanges(EaseDelegate easeFunction)
62 | {
63 |
64 | }
65 |
66 | public override float OnGetDuration()
67 | {
68 | return 0.0f;
69 | }
70 |
71 | public override float OnGetElapsed()
72 | {
73 | return 0.0f;
74 | }
75 |
76 | public override int OnGetTweensCount()
77 | {
78 | return 1;
79 | }
80 |
81 | public override int OnGetPlayingTweensCount()
82 | {
83 | return IsPlaying ? 1 : 0;
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/Runtime/Tweens/CallbackTween.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4e5f0c2c30a61564090c98495929280a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweens/GroupTween.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using System;
3 | using System.Collections.Generic;
4 |
5 | namespace Juce.Tweening
6 | {
7 | public class GroupTween : Tween
8 | {
9 | private readonly List tweens = new List();
10 | private readonly List playingTweens = new List();
11 |
12 | protected override bool Loopable => true;
13 |
14 | private bool durationCalculated;
15 | private float cachedCalculatedDuration;
16 |
17 | protected override void OnTweenStart(bool isCompletingInstantly)
18 | {
19 | StartTweens(isCompletingInstantly);
20 | }
21 |
22 | protected override void OnTweenUpdate()
23 | {
24 | for (int i = playingTweens.Count - 1; i >= 0; --i)
25 | {
26 | Tween tween = playingTweens[i];
27 |
28 | tween.Update();
29 |
30 | if (!tween.IsPlaying)
31 | {
32 | playingTweens.RemoveAt(i);
33 | }
34 | }
35 |
36 | if (playingTweens.Count == 0)
37 | {
38 | NewMarkCompleted();
39 | }
40 | }
41 |
42 | protected override void OnTweenKill()
43 | {
44 | foreach (Tween tween in playingTweens)
45 | {
46 | tween.Kill();
47 | }
48 |
49 | playingTweens.Clear();
50 | }
51 |
52 | protected override void OnTweenComplete()
53 | {
54 | foreach (Tween tween in playingTweens)
55 | {
56 | if (tween.IsCompleted)
57 | {
58 | continue;
59 | }
60 |
61 | if (!tween.IsPlaying)
62 | {
63 | tween.Start(isCompletingInstantly: true);
64 | }
65 |
66 | tween.Complete();
67 | }
68 |
69 | playingTweens.Clear();
70 |
71 | NewMarkCompleted();
72 | }
73 |
74 | protected override void OnTweenReset(bool kill, ResetMode resetMode)
75 | {
76 | for (int i = tweens.Count - 1; i >= 0; --i)
77 | {
78 | Tween tween = tweens[i];
79 |
80 | tween.Reset(kill, resetMode);
81 | }
82 | }
83 |
84 | protected override void OnTweenStartLoop(ResetMode loopResetMode)
85 | {
86 | StartTweens(isCompletingInstantly: false);
87 | }
88 |
89 | public override void OnTimeScaleChanges(float timeScale)
90 | {
91 | foreach (Tween tween in tweens)
92 | {
93 | tween.OnTimeScaleChanges(timeScale);
94 | }
95 | }
96 |
97 | public override void OnEaseDelegateChanges(EaseDelegate easeFunction)
98 | {
99 | foreach (Tween tween in tweens)
100 | {
101 | tween.OnEaseDelegateChanges(easeFunction);
102 | }
103 |
104 | EaseFunction = easeFunction;
105 | }
106 |
107 | public override float OnGetDuration()
108 | {
109 | if(durationCalculated)
110 | {
111 | return cachedCalculatedDuration;
112 | }
113 |
114 | durationCalculated = true;
115 |
116 | cachedCalculatedDuration = 0.0f;
117 |
118 | foreach (Tween tween in tweens)
119 | {
120 | cachedCalculatedDuration += tween.GetDuration();
121 | }
122 |
123 | return cachedCalculatedDuration;
124 | }
125 |
126 | public override float OnGetElapsed()
127 | {
128 | float totalDuration = 0.0f;
129 |
130 | foreach (Tween tween in tweens)
131 | {
132 | totalDuration += tween.GetElapsed();
133 | }
134 |
135 | return totalDuration;
136 | }
137 |
138 | public override int OnGetTweensCount()
139 | {
140 | int totalTweens = 1;
141 |
142 | foreach (Tween tween in tweens)
143 | {
144 | totalTweens += tween.GetTweensCount();
145 | }
146 |
147 | return totalTweens;
148 | }
149 |
150 | public override int OnGetPlayingTweensCount()
151 | {
152 | if(!IsPlaying)
153 | {
154 | return 0;
155 | }
156 |
157 | int totalTweens = 1;
158 |
159 | foreach (Tween tween in tweens)
160 | {
161 | totalTweens += tween.OnGetPlayingTweensCount();
162 | }
163 |
164 | return totalTweens;
165 | }
166 |
167 | public void Add(ITween tween)
168 | {
169 | Tween castedTween = tween as Tween;
170 |
171 | if(castedTween == null)
172 | {
173 | throw new ArgumentNullException($"Tried to {nameof(Add)} a null {nameof(Tween)} on {nameof(GroupTween)}");
174 | }
175 |
176 | if(IsPlaying)
177 | {
178 | return;
179 | }
180 |
181 | if(tween.IsPlaying)
182 | {
183 | return;
184 | }
185 |
186 | if(castedTween.IsNested)
187 | {
188 | return;
189 | }
190 |
191 | castedTween.IsNested = true;
192 |
193 | tweens.Add(castedTween);
194 |
195 | durationCalculated = false;
196 | }
197 |
198 | private void StartTweens(bool isCompletingInstantly)
199 | {
200 | playingTweens.Clear();
201 | playingTweens.AddRange(tweens);
202 |
203 | for (int i = playingTweens.Count - 1; i >= 0; --i)
204 | {
205 | Tween tween = playingTweens[i];
206 |
207 | tween.Start(isCompletingInstantly);
208 |
209 | if (!tween.IsPlaying)
210 | {
211 | playingTweens.RemoveAt(i);
212 | }
213 | }
214 |
215 | if (playingTweens.Count == 0)
216 | {
217 | NewMarkCompleted();
218 | }
219 | }
220 | }
221 | }
222 |
--------------------------------------------------------------------------------
/Runtime/Tweens/GroupTween.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6e3b24f2fa6daf74eb528beee035ad79
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweens/ISequenceTween.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Juce.Tweening
4 | {
5 | public interface ISequenceTween : ITween
6 | {
7 | void Append(ITween tween);
8 | void Join(ITween tween);
9 | void AppendCallback(Action callback, bool callIfCompletingInstantly = true);
10 | void JoinCallback(Action callback , bool callIfCompletingInstantly = true);
11 | void AppendResetableCallback(Action callback, Action reset, bool callIfCompletingInstantly = true);
12 | void JoinResetableCallback(Action callback, Action reset, bool callIfCompletingInstantly = true);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Runtime/Tweens/ISequenceTween.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e7f02848a3ba2c2458ea4f11dd55ce68
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweens/ITween.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using UnityEngine;
5 |
6 | namespace Juce.Tweening
7 | {
8 | public interface ITween
9 | {
10 | float TimeScale { get; }
11 |
12 | int Loops { get; }
13 | ResetMode LoopResetMode { get; }
14 |
15 | bool IsPlaying { get; }
16 | bool IsCompleted { get; }
17 |
18 | event Action OnTimeScaleChanged;
19 | event Action OnStart;
20 | event Action OnLoop;
21 | event Action OnReset;
22 | event Action OnComplete;
23 | event Action OnKill;
24 | event Action OnCompleteOrKill;
25 |
26 | float GetDuration();
27 | float GetElapsed();
28 | float GetNormalizedProgress();
29 | int GetTweensCount();
30 | int GetPlayingTweensCount();
31 |
32 | void SetTimeScale(float timeScale);
33 |
34 | void SetEase(Ease ease);
35 | void SetEase(AnimationCurve animationCurve);
36 | void SetLoops(int loops, ResetMode resetMode);
37 |
38 | void Complete();
39 | void Kill();
40 | void Reset(bool kill, ResetMode resetMode = ResetMode.InitialValues);
41 |
42 | void Replay();
43 | void Play();
44 |
45 | Task AwaitCompleteOrKill(CancellationToken cancellationToken);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Runtime/Tweens/ITween.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e276ac79d5770b34983e86c95656ea69
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweens/InterpolationTween.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using Juce.Tweening.Tweeners;
3 | using System;
4 | using System.Collections.Generic;
5 |
6 | namespace Juce.Tweening
7 | {
8 | public class InterpolationTween : Tween
9 | {
10 | private readonly List tweeners = new List();
11 | private readonly List playingTweeners = new List();
12 |
13 | protected override bool Loopable => true;
14 |
15 | private bool durationCalculated;
16 | private float cachedCalculatedDuration;
17 |
18 | protected override void OnTweenStart(bool isCompletingInstantly)
19 | {
20 | StartTweeners();
21 | }
22 |
23 | protected override void OnTweenUpdate()
24 | {
25 | for (int i = playingTweeners.Count - 1; i >= 0; --i)
26 | {
27 | ITweener tweener = playingTweeners[i];
28 |
29 | tweener.Update();
30 |
31 | if (!tweener.IsPlaying)
32 | {
33 | playingTweeners.RemoveAt(i);
34 | }
35 | }
36 |
37 | if (playingTweeners.Count == 0)
38 | {
39 | NewMarkCompleted();
40 | }
41 | }
42 |
43 | protected override void OnTweenKill()
44 | {
45 | foreach (ITweener tweener in playingTweeners)
46 | {
47 | tweener.Kill();
48 | }
49 |
50 | playingTweeners.Clear();
51 | }
52 |
53 | protected override void OnTweenComplete()
54 | {
55 | foreach (ITweener tweener in playingTweeners)
56 | {
57 | tweener.Complete();
58 | }
59 |
60 | playingTweeners.Clear();
61 |
62 | NewMarkCompleted();
63 | }
64 |
65 | protected override void OnTweenReset(bool kill, ResetMode resetMode)
66 | {
67 | for (int i = tweeners.Count - 1; i >= 0; --i)
68 | {
69 | ITweener tweener = tweeners[i];
70 |
71 | tweener.Reset(resetMode);
72 | }
73 | }
74 |
75 | protected override void OnTweenStartLoop(ResetMode loopResetMode)
76 | {
77 | StartTweeners();
78 | }
79 |
80 | public override void OnEaseDelegateChanges(EaseDelegate easeFunction)
81 | {
82 | foreach (ITweener tweener in tweeners)
83 | {
84 | tweener.SetEase(easeFunction);
85 | }
86 |
87 | EaseFunction = easeFunction;
88 | }
89 |
90 | public override void OnTimeScaleChanges(float timeScale)
91 | {
92 | foreach(ITweener tweener in tweeners)
93 | {
94 | tweener.TimeScale = timeScale;
95 | }
96 | }
97 |
98 | public override int OnGetTweensCount()
99 | {
100 | return 1;
101 | }
102 |
103 | public override int OnGetPlayingTweensCount()
104 | {
105 | return IsPlaying ? 1 : 0;
106 | }
107 |
108 | public override float OnGetDuration()
109 | {
110 | if(durationCalculated)
111 | {
112 | return cachedCalculatedDuration;
113 | }
114 |
115 | durationCalculated = true;
116 |
117 | cachedCalculatedDuration = 0.0f;
118 |
119 | foreach (ITweener tweener in tweeners)
120 | {
121 | cachedCalculatedDuration += tweener.Duration;
122 | }
123 |
124 | return cachedCalculatedDuration;
125 | }
126 |
127 | public override float OnGetElapsed()
128 | {
129 | float totalElapsed = 0.0f;
130 |
131 | foreach (ITweener tweener in tweeners)
132 | {
133 | totalElapsed += tweener.Elapsed;
134 | }
135 |
136 | return totalElapsed;
137 | }
138 |
139 | public void Add(ITweener tweener)
140 | {
141 | if (tweener == null)
142 | {
143 | throw new ArgumentNullException($"Tried to {nameof(Add)} a null {nameof(ITweener)} on {nameof(InterpolationTween)}");
144 | }
145 |
146 | if (tweener.IsPlaying)
147 | {
148 | throw new ArgumentNullException($"Tried to {nameof(Add)} a {nameof(ITweener)} on {nameof(InterpolationTween)} " +
149 | $"but it was already playing");
150 | }
151 |
152 | if (tweeners.Contains(tweener))
153 | {
154 | throw new ArgumentNullException($"Tried to {nameof(Add)} a {nameof(ITweener)} on {nameof(InterpolationTween)} " +
155 | $"but it was already added");
156 | }
157 |
158 | tweeners.Add(tweener);
159 |
160 | durationCalculated = false;
161 | }
162 |
163 | private void StartTweeners()
164 | {
165 | playingTweeners.Clear();
166 | playingTweeners.AddRange(tweeners);
167 |
168 | for (int i = playingTweeners.Count - 1; i >= 0; --i)
169 | {
170 | ITweener tweener = playingTweeners[i];
171 |
172 | tweener.TimeScale = TimeScale;
173 | tweener.SetEase(EaseFunction);
174 |
175 | tweener.Start();
176 |
177 | if (!tweener.IsPlaying)
178 | {
179 | playingTweeners.RemoveAt(i);
180 | }
181 | }
182 |
183 | if (playingTweeners.Count == 0)
184 | {
185 | NewMarkCompleted();
186 | }
187 | }
188 | }
189 | }
190 |
--------------------------------------------------------------------------------
/Runtime/Tweens/InterpolationTween.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 98469170bdf01ad4692e0ac727e24eca
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweens/ResetableCallbackTween.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using System;
3 |
4 | namespace Juce.Tweening
5 | {
6 | public class ResetableCallbackTween : Tween
7 | {
8 | private readonly Action action;
9 | private readonly Action resetAction;
10 | private readonly bool callIfCompletingInstantly;
11 |
12 | protected override bool Loopable => false;
13 |
14 | public ResetableCallbackTween(Action action, Action resetAction, bool callIfCompletingInstantly)
15 | {
16 | this.action = action;
17 | this.resetAction = resetAction;
18 | this.callIfCompletingInstantly = callIfCompletingInstantly;
19 | }
20 |
21 |
22 | protected override void OnTweenStart(bool isCompletingInstantly)
23 | {
24 | bool canCall = !isCompletingInstantly || callIfCompletingInstantly;
25 |
26 | if (canCall)
27 | {
28 | action?.Invoke();
29 | }
30 |
31 | NewMarkCompleted();
32 | }
33 |
34 | protected override void OnTweenUpdate()
35 | {
36 |
37 | }
38 |
39 | protected override void OnTweenKill()
40 | {
41 |
42 | }
43 |
44 | protected override void OnTweenComplete()
45 | {
46 |
47 | }
48 |
49 | protected override void OnTweenReset(bool kill, ResetMode resetMode)
50 | {
51 | resetAction?.Invoke();
52 | }
53 |
54 | protected override void OnTweenStartLoop(ResetMode loopResetMode)
55 | {
56 |
57 | }
58 |
59 | public override void OnTimeScaleChanges(float timeScale)
60 | {
61 |
62 | }
63 |
64 | public override void OnEaseDelegateChanges(EaseDelegate easeFunction)
65 | {
66 |
67 | }
68 |
69 | public override float OnGetDuration()
70 | {
71 | return 0.0f;
72 | }
73 |
74 | public override float OnGetElapsed()
75 | {
76 | return 0.0f;
77 | }
78 |
79 | public override int OnGetTweensCount()
80 | {
81 | return 1;
82 | }
83 |
84 | public override int OnGetPlayingTweensCount()
85 | {
86 | return IsPlaying ? 1 : 0;
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/Runtime/Tweens/ResetableCallbackTween.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e22234a16e08012459beba0c23465a7b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweens/SequenceTween.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using Juce.Tweening.Repositories;
3 | using Juce.Tweening.Utils;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace Juce.Tweening
8 | {
9 | public class SequenceTween : Tween, ISequenceTween
10 | {
11 | private readonly SequenceTweenTweenRepository tweenRepository = new SequenceTweenTweenRepository();
12 | private readonly List playingTweens = new List();
13 |
14 | protected override bool Loopable => true;
15 |
16 | private bool durationCalculated;
17 | private float cachedCalculatedDuration;
18 |
19 | protected override void OnTweenStart(bool isCompletingInstantly)
20 | {
21 | StartTweens(isCompletingInstantly);
22 | }
23 |
24 | protected override void OnTweenUpdate()
25 | {
26 | if (playingTweens.Count == 0)
27 | {
28 | NewMarkCompleted();
29 |
30 | return;
31 | }
32 |
33 | Tween tween = playingTweens[0];
34 |
35 | tween.Update();
36 |
37 | if (tween.IsPlaying)
38 | {
39 | return;
40 | }
41 |
42 | playingTweens.RemoveAt(0);
43 |
44 | if (playingTweens.Count > 0)
45 | {
46 | Tween nextTween = playingTweens[0];
47 |
48 | nextTween.Start();
49 | }
50 | else
51 | {
52 | base.Update();
53 | }
54 | }
55 |
56 | protected override void OnTweenKill()
57 | {
58 | foreach (Tween tween in playingTweens)
59 | {
60 | tween.Kill();
61 | }
62 |
63 | playingTweens.Clear();
64 | }
65 |
66 | protected override void OnTweenComplete()
67 | {
68 | foreach (Tween tween in tweenRepository.Tweens)
69 | {
70 | if(tween.IsCompleted)
71 | {
72 | continue;
73 | }
74 |
75 | if (!tween.IsPlaying)
76 | {
77 | tween.Start(isCompletingInstantly: true);
78 | }
79 |
80 | tween.Complete();
81 | }
82 |
83 | playingTweens.Clear();
84 |
85 | NewMarkCompleted();
86 | }
87 |
88 | protected override void OnTweenReset(bool kill, ResetMode resetMode)
89 | {
90 | for (int i = tweenRepository.Tweens.Count - 1; i >= 0; --i)
91 | {
92 | Tween tween = tweenRepository.Tweens[i];
93 |
94 | tween.Reset(kill, resetMode);
95 | }
96 | }
97 |
98 | protected override void OnTweenStartLoop(ResetMode loopResetMode)
99 | {
100 | StartTweens(isCompletingInstantly: false);
101 | }
102 |
103 | public override void OnTimeScaleChanges(float timeScale)
104 | {
105 | foreach (Tween tween in tweenRepository.Tweens)
106 | {
107 | tween.OnTimeScaleChanges(timeScale);
108 | }
109 | }
110 |
111 | public override void OnEaseDelegateChanges(EaseDelegate easeFunction)
112 | {
113 | foreach (Tween tween in tweenRepository.Tweens)
114 | {
115 | tween.OnEaseDelegateChanges(easeFunction);
116 | }
117 |
118 | EaseFunction = easeFunction;
119 | }
120 |
121 | public override float OnGetDuration()
122 | {
123 | if(durationCalculated)
124 | {
125 | return cachedCalculatedDuration;
126 | }
127 |
128 | durationCalculated = true;
129 |
130 | cachedCalculatedDuration = 0.0f;
131 |
132 | foreach (Tween tween in tweenRepository.Tweens)
133 | {
134 | cachedCalculatedDuration += tween.GetDuration();
135 | }
136 |
137 | return cachedCalculatedDuration;
138 | }
139 |
140 | public override float OnGetElapsed()
141 | {
142 | float totalDuration = 0.0f;
143 |
144 | foreach (Tween tween in tweenRepository.Tweens)
145 | {
146 | totalDuration += tween.GetElapsed();
147 | }
148 |
149 | return totalDuration;
150 | }
151 |
152 | public override int OnGetTweensCount()
153 | {
154 | int totalTweens = 1;
155 |
156 | foreach (Tween tween in tweenRepository.Tweens)
157 | {
158 | totalTweens += tween.GetTweensCount();
159 | }
160 |
161 | return totalTweens;
162 | }
163 |
164 | public override int OnGetPlayingTweensCount()
165 | {
166 | if (!IsPlaying)
167 | {
168 | return 0;
169 | }
170 |
171 | int totalTweens = 1;
172 |
173 | foreach (Tween tween in tweenRepository.Tweens)
174 | {
175 | totalTweens += tween.OnGetPlayingTweensCount();
176 | }
177 |
178 | return totalTweens;
179 | }
180 |
181 | public void Append(ITween tween)
182 | {
183 | Tween castedTween = tween as Tween;
184 |
185 | if (castedTween == null)
186 | {
187 | throw new ArgumentNullException($"Tried to {nameof(Append)} a null {nameof(Tween)} on {nameof(SequenceTween)}");
188 | }
189 |
190 | bool canAdd = TweenUtils.CanAddTween(this, tween);
191 |
192 | if(!canAdd)
193 | {
194 | return;
195 | }
196 |
197 | tweenRepository.Append(castedTween);
198 |
199 | castedTween.IsNested = true;
200 |
201 | durationCalculated = false;
202 | }
203 |
204 | public void Join(ITween tween)
205 | {
206 | Tween castedTween = tween as Tween;
207 |
208 | if (castedTween == null)
209 | {
210 | throw new ArgumentNullException($"Tried to {nameof(Join)} a null {nameof(Tween)} on {nameof(SequenceTween)}");
211 | }
212 |
213 | bool canAdd = TweenUtils.CanAddTween(this, tween);
214 |
215 | if (!canAdd)
216 | {
217 | return;
218 | }
219 |
220 | tweenRepository.Join(castedTween);
221 |
222 | castedTween.IsNested = true;
223 |
224 | durationCalculated = false;
225 | }
226 |
227 | public void AppendCallback(Action callback, bool callIfCompletingInstantly = true)
228 | {
229 | Append(new CallbackTween(callback, callIfCompletingInstantly));
230 | }
231 |
232 | public void JoinCallback(Action callback, bool callIfCompletingInstantly = true)
233 | {
234 | Join(new CallbackTween(callback, callIfCompletingInstantly));
235 | }
236 |
237 | public void AppendResetableCallback(Action callback, Action reset, bool callIfCompletingInstantly = true)
238 | {
239 | Append(new ResetableCallbackTween(callback, reset, callIfCompletingInstantly));
240 | }
241 |
242 | public void JoinResetableCallback(Action callback, Action reset, bool callIfCompletingInstantly = true)
243 | {
244 | Join(new ResetableCallbackTween(callback, reset, callIfCompletingInstantly));
245 | }
246 |
247 | private void StartTweens(bool isCompletingInstantly)
248 | {
249 | playingTweens.Clear();
250 | playingTweens.AddRange(tweenRepository.Tweens);
251 |
252 | for (int i = playingTweens.Count - 1; i >= 0; --i)
253 | {
254 | Tween tween = playingTweens[i];
255 |
256 | if (i == 0)
257 | {
258 | tween.Start(isCompletingInstantly);
259 | }
260 | }
261 |
262 | if (playingTweens.Count == 0)
263 | {
264 | NewMarkCompleted();
265 | }
266 | }
267 | }
268 | }
269 |
--------------------------------------------------------------------------------
/Runtime/Tweens/SequenceTween.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 96fa29b435f224448be201dff5576dd6
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Tweens/Tween.cs:
--------------------------------------------------------------------------------
1 | using Juce.Tweening.Easing;
2 | using System;
3 | using System.Threading;
4 | using System.Threading.Tasks;
5 | using UnityEngine;
6 |
7 | namespace Juce.Tweening
8 | {
9 | public abstract partial class Tween : ITween
10 | {
11 | private int loopsRemaining;
12 |
13 | protected EaseDelegate EaseFunction { get; set; }
14 | public float TimeScale { get; private set; }
15 |
16 | public int Loops { get; private set; }
17 | public ResetMode LoopResetMode { get; private set; }
18 |
19 | public bool IsNested { get; set; }
20 |
21 | public bool IsPlaying { get; protected set; }
22 | public bool IsCompleted { get; protected set; }
23 |
24 | public bool IsAlive { get; set; }
25 |
26 | public event Action OnTimeScaleChanged;
27 | public event Action OnStart;
28 | public event Action OnLoop;
29 | public event Action OnReset;
30 | public event Action OnComplete;
31 | public event Action OnKill;
32 | public event Action OnCompleteOrKill;
33 |
34 | internal Tween()
35 | {
36 | SetEase(Ease.Linear);
37 | SetTimeScale(1.0f);
38 | }
39 |
40 | public void Start(bool isCompletingInstantly = false)
41 | {
42 | if (IsPlaying)
43 | {
44 | Kill();
45 | }
46 |
47 | IsPlaying = true;
48 | IsCompleted = false;
49 |
50 | loopsRemaining = Loops;
51 |
52 | OnStart?.Invoke();
53 |
54 | OnTweenStart(isCompletingInstantly);
55 | }
56 |
57 | public void Update()
58 | {
59 | if (!IsPlaying)
60 | {
61 | return;
62 | }
63 |
64 | OnTweenUpdate();
65 | }
66 |
67 | public void Complete()
68 | {
69 | if (!IsPlaying && !IsCompleted)
70 | {
71 | Start(isCompletingInstantly: true);
72 | }
73 |
74 | OnTweenComplete();
75 |
76 | loopsRemaining = 0;
77 |
78 | NewMarkCompleted();
79 | }
80 |
81 | public void Kill()
82 | {
83 | if (!IsPlaying)
84 | {
85 | return;
86 | }
87 |
88 | IsPlaying = false;
89 | IsCompleted = true;
90 |
91 | OnTweenKill();
92 |
93 | OnKill?.Invoke();
94 | OnCompleteOrKill?.Invoke();
95 | }
96 |
97 | public void Reset(bool kill, ResetMode resetMode = ResetMode.InitialValues)
98 | {
99 | if (kill)
100 | {
101 | Kill();
102 |
103 | IsPlaying = false;
104 | }
105 |
106 | IsCompleted = false;
107 |
108 | OnTweenReset(kill, resetMode);
109 |
110 | OnReset?.Invoke();
111 | }
112 |
113 | public float GetDuration()
114 | {
115 | return OnGetDuration();
116 | }
117 |
118 | public float GetElapsed()
119 | {
120 | if(!IsPlaying && !IsCompleted)
121 | {
122 | return 0.0f;
123 | }
124 |
125 | if(!IsPlaying && IsCompleted)
126 | {
127 | return GetDuration();
128 | }
129 |
130 | return OnGetElapsed();
131 | }
132 |
133 | public float GetNormalizedProgress()
134 | {
135 | float duration = GetDuration();
136 |
137 | if(duration <= 0)
138 | {
139 | return 0.0f;
140 | }
141 |
142 | float elapsed = GetElapsed();
143 |
144 | return (1.0f / duration) * elapsed;
145 | }
146 |
147 | public int GetTweensCount()
148 | {
149 | return OnGetTweensCount();
150 | }
151 |
152 | public int GetPlayingTweensCount()
153 | {
154 | return OnGetPlayingTweensCount();
155 | }
156 |
157 | public void SetTimeScale(float timeScale)
158 | {
159 | if(TimeScale == timeScale)
160 | {
161 | return;
162 | }
163 |
164 | TimeScale = timeScale;
165 |
166 | OnTimeScaleChanges(timeScale);
167 |
168 | OnTimeScaleChanged?.Invoke(timeScale);
169 | }
170 |
171 | public void SetEase(EaseDelegate easeFunction)
172 | {
173 | EaseFunction = easeFunction;
174 |
175 | OnEaseDelegateChanges(EaseFunction);
176 | }
177 |
178 | public void SetEase(Ease ease)
179 | {
180 | SetEase(PresetEaser.GetEaseDelegate(ease));
181 | }
182 |
183 | public void SetEase(AnimationCurve animationCurve)
184 | {
185 | if (animationCurve == null)
186 | {
187 | throw new ArgumentNullException($"Tried to {nameof(SetEase)} " +
188 | $"with a null {nameof(AnimationCurve)} on {nameof(Tween)}");
189 | }
190 |
191 | SetEase(AnimationCurveEaser.GetEaseDelegate(animationCurve));
192 | }
193 |
194 | public void SetLoops(int loops, ResetMode resetMode)
195 | {
196 | Loops = Math.Max(loops, 0);
197 | LoopResetMode = resetMode;
198 | }
199 |
200 | public void Replay()
201 | {
202 | Reset(kill: true);
203 | Play();
204 | }
205 |
206 | public void Play()
207 | {
208 | JuceTween.Add(this);
209 | }
210 |
211 | private bool NewLoop(ResetMode loopResetMode)
212 | {
213 | bool needsToLoop = loopsRemaining > 0;
214 |
215 | if(!needsToLoop || !Loopable)
216 | {
217 | return false;
218 | }
219 |
220 | --loopsRemaining;
221 |
222 | Reset(kill: false, loopResetMode);
223 |
224 | Start();
225 |
226 | OnLoop?.Invoke();
227 |
228 | return true;
229 | }
230 |
231 | protected void NewMarkCompleted()
232 | {
233 | if (!IsPlaying)
234 | {
235 | return;
236 | }
237 |
238 | bool loops = NewLoop(LoopResetMode);
239 |
240 | if(loops)
241 | {
242 | return;
243 | }
244 |
245 | IsPlaying = false;
246 | IsCompleted = true;
247 |
248 | OnTweenComplete();
249 |
250 | OnComplete?.Invoke();
251 | OnCompleteOrKill?.Invoke();
252 | }
253 |
254 | public async Task AwaitCompleteOrKill(CancellationToken cancellationToken)
255 | {
256 | if (!IsPlaying)
257 | {
258 | return;
259 | }
260 |
261 | TaskCompletionSource