From c0ff80e76d07f0e537bbeece7dece18c94f4031a Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Sun, 25 Jun 2023 13:36:33 -0500 Subject: [PATCH 01/19] Update package version to 2.6.2 --- CHANGELOG.md | 15 +++++++++++++++ package.json | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88f541e..efc8794 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.6.2] - 2022/10/16 + +### Fixed + +- Fixed tweens not updating when the duration is set to zero + +### Added + +- New extension method `ShadowTweens.TweenAlpha` + +### Changed + +- Renamed `ShadowTweens.TweenEffectColor` to `ShadowTweens.TweenColor` +- Renamed `ShadowTweens.TweenEffectDistance` to `ShadowTweens.TweenDistance` + ## [2.6.1] - 2022/05/11 ### Fixed diff --git a/package.json b/package.json index 24f8d62..357fdc2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.zigurous.tweening", - "version": "2.6.1", + "version": "2.6.2", "displayName": "Tweening", "description": "The Tweening package provides a system for tweening object properties in Unity. A tween is an animation of a value from a start position to an end position using an easing function, providing a natural sense of motion.\n\nThe system is lightweight, optimized, type-safe, and memory efficient. Hundreds of predefined tweening functions can be called on many common Unity classes, or you can animate anything using generic tweening functions. Tweens can be controlled with many different control methods and various callback functions.", "unity": "2019.4", From df59bf1153f727139a7a87d377e942e305d0a360 Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Sun, 25 Jun 2023 13:36:33 -0500 Subject: [PATCH 02/19] Code formatting changes --- Runtime/PropertyChaining.cs | 38 ++++++++++++++++++------------------- Runtime/Tweening.cs | 10 +++++----- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Runtime/PropertyChaining.cs b/Runtime/PropertyChaining.cs index fa82cd0..b8b2c9d 100644 --- a/Runtime/PropertyChaining.cs +++ b/Runtime/PropertyChaining.cs @@ -17,7 +17,7 @@ public static class PropertyChaining /// The tween to assign the value to. /// The target component. /// The tween itself to allow for chaining. - public static T SetTarget(this T tween, Component target) where T: Tween + public static T SetTarget(this T tween, Component target) where T : Tween { if (tween != null && target != null) { @@ -36,7 +36,7 @@ public static T SetTarget(this T tween, Component target) where T: Tween /// The tween to assign the value to. /// The target component. /// The tween itself to allow for chaining. - public static T SetTarget(this T tween, GameObject target) where T: Tween + public static T SetTarget(this T tween, GameObject target) where T : Tween { if (tween != null && target != null) { @@ -54,7 +54,7 @@ public static T SetTarget(this T tween, GameObject target) where T: Tween /// The tween to assign the value to. /// The id to set. /// The tween itself to allow for chaining. - public static T SetId(this T tween, int id) where T: Tween + public static T SetId(this T tween, int id) where T : Tween { if (tween != null) { tween.id = id; @@ -70,7 +70,7 @@ public static T SetId(this T tween, int id) where T: Tween /// The tween to assign the value to. /// The scene index to set. /// The tween itself to allow for chaining. - public static T SetSceneIndex(this T tween, int index) where T: Tween + public static T SetSceneIndex(this T tween, int index) where T : Tween { if (tween != null) { tween.sceneIndex = index; @@ -86,7 +86,7 @@ public static T SetSceneIndex(this T tween, int index) where T: Tween /// The tween to assign the value to. /// The ease to set. /// The tween itself to allow for chaining. - public static T SetEase(this T tween, Ease ease) where T: Tween + public static T SetEase(this T tween, Ease ease) where T : Tween { if (tween != null) { tween.ease = ease; @@ -102,7 +102,7 @@ public static T SetEase(this T tween, Ease ease) where T: Tween /// The tween to assign the value to. /// The duration to set. /// The tween itself to allow for chaining. - public static T SetDuration(this T tween, float duration) where T: Tween + public static T SetDuration(this T tween, float duration) where T : Tween { if (tween != null) { tween.duration = duration; @@ -118,7 +118,7 @@ public static T SetDuration(this T tween, float duration) where T: Tween /// The tween to assign the value to. /// The delay to set. /// The tween itself to allow for chaining. - public static T SetDelay(this T tween, float delay) where T: Tween + public static T SetDelay(this T tween, float delay) where T : Tween { if (tween != null) { tween.delay = delay; @@ -135,7 +135,7 @@ public static T SetDelay(this T tween, float delay) where T: Tween /// The number of loops to set. /// The type of loop style to set. /// The tween itself to allow for chaining. - public static T SetLoops(this T tween, int loops, LoopType loopType = LoopType.Restart) where T: Tween + public static T SetLoops(this T tween, int loops, LoopType loopType = LoopType.Restart) where T : Tween { if (tween != null) { @@ -153,7 +153,7 @@ public static T SetLoops(this T tween, int loops, LoopType loopType = LoopTyp /// The tween to assign the value to. /// True if the tween is to be played in reverse. /// The tween itself to allow for chaining. - public static T SetReversed(this T tween, bool reversed = true) where T: Tween + public static T SetReversed(this T tween, bool reversed = true) where T : Tween { if (tween != null) { tween.reversed = reversed; @@ -169,7 +169,7 @@ public static T SetReversed(this T tween, bool reversed = true) where T: Twee /// The tween to assign the value to. /// True if interpolated values should be snapped to whole numbers. /// The tween itself to allow for chaining. - public static T SetSnapping(this T tween, bool snapping = true) where T: Tween + public static T SetSnapping(this T tween, bool snapping = true) where T : Tween { if (tween != null) { tween.snapping = snapping; @@ -185,7 +185,7 @@ public static T SetSnapping(this T tween, bool snapping = true) where T: Twee /// The tween to assign the value to. /// True if the tween is to be recycled. /// The tween itself to allow for chaining. - public static T SetRecyclable(this T tween, bool recyclable) where T: Tween + public static T SetRecyclable(this T tween, bool recyclable) where T : Tween { if (tween != null) { tween.recyclable = recyclable; @@ -201,7 +201,7 @@ public static T SetRecyclable(this T tween, bool recyclable) where T: Tween /// The tween to assign the value to. /// True if the tween is to be started automatically. /// The tween itself to allow for chaining. - public static T SetAutoStart(this T tween, bool autoStart) where T: Tween + public static T SetAutoStart(this T tween, bool autoStart) where T : Tween { if (tween != null) { tween.autoStart = autoStart; @@ -217,7 +217,7 @@ public static T SetAutoStart(this T tween, bool autoStart) where T: Tween /// The tween to assign the value to. /// True if the tween is to be killed automatically. /// The tween itself to allow for chaining. - public static T SetAutoKill(this T tween, bool autoKill) where T: Tween + public static T SetAutoKill(this T tween, bool autoKill) where T : Tween { if (tween != null) { tween.autoKill = autoKill; @@ -233,7 +233,7 @@ public static T SetAutoKill(this T tween, bool autoKill) where T: Tween /// The tween to assign the value to. /// The callback to invoke. /// The tween itself to allow for chaining. - public static T OnUpdate(this T tween, TweenCallback callback) where T: Tween + public static T OnUpdate(this T tween, TweenCallback callback) where T : Tween { if (tween != null) { tween.onUpdate += callback; @@ -249,7 +249,7 @@ public static T OnUpdate(this T tween, TweenCallback callback) where T: Tween /// The tween to assign the value to. /// The callback to invoke. /// The tween itself to allow for chaining. - public static T OnStart(this T tween, TweenCallback callback) where T: Tween + public static T OnStart(this T tween, TweenCallback callback) where T : Tween { if (tween != null) { tween.onStart += callback; @@ -265,7 +265,7 @@ public static T OnStart(this T tween, TweenCallback callback) where T: Tween /// The tween to assign the value to. /// The callback to invoke. /// The tween itself to allow for chaining. - public static T OnStop(this T tween, TweenCallback callback) where T: Tween + public static T OnStop(this T tween, TweenCallback callback) where T : Tween { if (tween != null) { tween.onStop += callback; @@ -281,7 +281,7 @@ public static T OnStop(this T tween, TweenCallback callback) where T: Tween /// The tween to assign the value to. /// The callback to invoke. /// The tween itself to allow for chaining. - public static T OnLoop(this T tween, TweenCallback callback) where T: Tween + public static T OnLoop(this T tween, TweenCallback callback) where T : Tween { if (tween != null) { tween.onLoop += callback; @@ -297,7 +297,7 @@ public static T OnLoop(this T tween, TweenCallback callback) where T: Tween /// The tween to assign the value to. /// The callback to invoke. /// The tween itself to allow for chaining. - public static T OnComplete(this T tween, TweenCallback callback) where T: Tween + public static T OnComplete(this T tween, TweenCallback callback) where T : Tween { if (tween != null) { tween.onComplete += callback; @@ -313,7 +313,7 @@ public static T OnComplete(this T tween, TweenCallback callback) where T: Twe /// The tween to assign the value to. /// The callback to invoke. /// The tween itself to allow for chaining. - public static T OnKill(this T tween, TweenCallback callback) where T: Tween + public static T OnKill(this T tween, TweenCallback callback) where T : Tween { if (tween != null) { tween.onKill += callback; diff --git a/Runtime/Tweening.cs b/Runtime/Tweening.cs index 898fe02..d73917b 100644 --- a/Runtime/Tweening.cs +++ b/Runtime/Tweening.cs @@ -467,7 +467,7 @@ public static void Play(int id) /// /// The type of the target object. /// The target object to play the tweens of. - public static void Play(T target) where T: class + public static void Play(T target) where T : class { Play(target.GetHashCode()); } @@ -513,7 +513,7 @@ public static void Stop(int id) /// /// The type of the target object. /// The target object to stop the tweens of. - public static void Stop(T target) where T: class + public static void Stop(T target) where T : class { Stop(target.GetHashCode()); } @@ -559,7 +559,7 @@ public static void Restart(int id) /// /// The type of the target object. /// The target object to restart the tweens of. - public static void Restart(T target) where T: class + public static void Restart(T target) where T : class { Restart(target.GetHashCode()); } @@ -605,7 +605,7 @@ public static void Complete(int id) /// /// The type of the target object. /// The target object to complete the tweens of. - public static void Complete(T target) where T: class + public static void Complete(T target) where T : class { Complete(target.GetHashCode()); } @@ -657,7 +657,7 @@ public static void Kill(int id, bool complete = false) /// The type of the target object. /// The target object to kill the tweens of. /// Whether to complete the tweens before being killed. - public static void KillTweens(this T target, bool complete = false) where T: class + public static void KillTweens(this T target, bool complete = false) where T : class { Kill(target.GetHashCode(), complete); } From ef761dbb6ba561acd9acb4c96b6f3c5cebbdc092 Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Sun, 25 Jun 2023 13:36:33 -0500 Subject: [PATCH 03/19] Remove extra newline --- Runtime/EaseFunction.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Runtime/EaseFunction.cs b/Runtime/EaseFunction.cs index 9170d26..fbe7cbf 100644 --- a/Runtime/EaseFunction.cs +++ b/Runtime/EaseFunction.cs @@ -167,7 +167,6 @@ public static float QuadInOut(float x) return x < 0.5f ? 2f * x * x : 1f - Mathf.Pow(-2f * x + 2f, 2f) / 2f; - } /// From 02df49e651cddfbd6109d2ac5a69a0f3b24f0342 Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Mon, 26 Jun 2023 17:34:49 -0500 Subject: [PATCH 04/19] Refactor tween extensions to remove closures --- Runtime/Delegates.cs | 15 +- .../Audio/AudioChorusFilterTweens.cs | 36 ++-- .../Audio/AudioDistortionFilterTweens.cs | 6 +- .../Extensions/Audio/AudioEchoFilterTweens.cs | 21 +-- .../Audio/AudioHighPassFilterTweens.cs | 11 +- .../Extensions/Audio/AudioListenerTweens.cs | 6 +- .../Audio/AudioLowPassFilterTweens.cs | 11 +- .../Audio/AudioReverbFilterTweens.cs | 71 +++----- .../Extensions/Audio/AudioReverbZoneTweens.cs | 51 +++--- Runtime/Extensions/Audio/AudioSourceTweens.cs | 87 ++++----- .../Extensions/Misc/AimConstraintTweens.cs | 31 ++-- Runtime/Extensions/Misc/GridTweens.cs | 11 +- .../Extensions/Misc/LookAtConstraintTweens.cs | 21 +-- .../Extensions/Misc/ParentConstraintTweens.cs | 16 +- .../Misc/PositionConstraintTweens.cs | 16 +- Runtime/Extensions/Misc/RectOffsetTweens.cs | 21 +-- .../Misc/RotationConstraintTweens.cs | 16 +- .../Extensions/Misc/ScaleConstraintTweens.cs | 16 +- Runtime/Extensions/Misc/TransformTweens.cs | 71 +++----- .../Navigation/NavMeshAgentTweens.cs | 51 +++--- .../Navigation/NavMeshObstacleTweens.cs | 26 ++- .../Extensions/Physics/BoxColliderTweens.cs | 11 +- .../Physics/CapsuleColliderTweens.cs | 16 +- .../Physics/CharacterControllerTweens.cs | 36 ++-- .../Physics/CharacterJointTweens.cs | 16 +- Runtime/Extensions/Physics/ClothTweens.cs | 66 +++---- Runtime/Extensions/Physics/ColliderTweens.cs | 6 +- .../Physics/ConfigurableJointTweens.cs | 36 ++-- .../Extensions/Physics/ConstantForceTweens.cs | 21 +-- Runtime/Extensions/Physics/JointTweens.cs | 36 ++-- .../Physics/PhysicMaterialTweens.cs | 16 +- Runtime/Extensions/Physics/RigidbodyTweens.cs | 66 +++---- .../Physics/SphereColliderTweens.cs | 11 +- .../Extensions/Physics/SpringJointTweens.cs | 26 ++- .../Extensions/Physics/WheelColliderTweens.cs | 51 +++--- .../Physics2D/AnchoredJoint2DTweens.cs | 11 +- .../Physics2D/AreaEffector2DTweens.cs | 26 ++- .../Physics2D/BoxCollider2DTweens.cs | 11 +- .../Physics2D/BuoyancyEffector2DTweens.cs | 36 ++-- .../Physics2D/CapsuleCollider2DTweens.cs | 6 +- .../Physics2D/CircleCollider2DTweens.cs | 6 +- .../Extensions/Physics2D/Collider2DTweens.cs | 11 +- .../Physics2D/CompositeCollider2DTweens.cs | 16 +- .../Physics2D/ConstantForce2DTweens.cs | 16 +- .../Physics2D/DistanceJoint2DTweens.cs | 6 +- .../Physics2D/EdgeCollider2DTweens.cs | 6 +- .../Physics2D/FixedJoint2DTweens.cs | 11 +- .../Physics2D/FrictionJoint2DTweens.cs | 11 +- Runtime/Extensions/Physics2D/Joint2DTweens.cs | 11 +- .../Physics2D/PhysicsMaterial2DTweens.cs | 11 +- .../Physics2D/PlatformEffector2DTweens.cs | 16 +- .../Physics2D/PointEffector2DTweens.cs | 26 ++- .../Physics2D/RelativeJoint2DTweens.cs | 26 ++- .../Extensions/Physics2D/Rigidbody2DTweens.cs | 51 +++--- .../Physics2D/SliderJoint2DTweens.cs | 6 +- .../Physics2D/SpringJoint2DTweens.cs | 16 +- .../Physics2D/SurfaceEffector2DTweens.cs | 16 +- .../Physics2D/TargetJoint2DTweens.cs | 26 ++- .../Extensions/Rendering/AnimatorTweens.cs | 36 ++-- Runtime/Extensions/Rendering/CameraTweens.cs | 71 +++----- .../Extensions/Rendering/LensFlareTweens.cs | 16 +- Runtime/Extensions/Rendering/LightTweens.cs | 66 +++---- .../Rendering/LineRendererTweens.cs | 31 ++-- .../Extensions/Rendering/MaterialTweens.cs | 93 ++++------ .../Rendering/OcclusionAreaTweens.cs | 11 +- .../ParticleSystemForceFieldTweens.cs | 26 ++- .../Rendering/ParticleSystemTweens.cs | 6 +- .../Extensions/Rendering/ProjectorTweens.cs | 26 ++- .../Rendering/ReflectionProbeTweens.cs | 41 ++--- .../Extensions/Rendering/SpriteMaskTweens.cs | 6 +- .../Rendering/SpriteRendererTweens.cs | 21 +-- .../Rendering/SpriteShapeRendererTweens.cs | 11 +- Runtime/Extensions/Rendering/TilemapTweens.cs | 26 ++- .../Rendering/TrailRendererTweens.cs | 41 ++--- .../Extensions/Rendering/VideoPlayerTweens.cs | 26 ++- .../Extensions/Rendering/WindZoneTweens.cs | 26 ++- .../Extensions/UI/AspectRatioFitterTweens.cs | 6 +- Runtime/Extensions/UI/CanvasGroupTweens.cs | 6 +- Runtime/Extensions/UI/CanvasScalerTweens.cs | 36 ++-- Runtime/Extensions/UI/CanvasTweens.cs | 21 +-- Runtime/Extensions/UI/GraphicTweens.cs | 11 +- .../Extensions/UI/GridLayoutGroupTweens.cs | 11 +- .../HorizontalOrVerticalLayoutGroupTweens.cs | 6 +- Runtime/Extensions/UI/RectMask2DTweens.cs | 11 +- Runtime/Extensions/UI/RectTransformTweens.cs | 41 ++--- Runtime/Extensions/UI/ScrollRectTweens.cs | 46 ++--- Runtime/Extensions/UI/ScrollbarTweens.cs | 11 +- Runtime/Extensions/UI/ShadowTweens.cs | 16 +- Runtime/Extensions/UI/SliderTweens.cs | 21 +-- Runtime/Extensions/UI/TextMeshTweens.cs | 36 ++-- Runtime/Extensions/UI/TextTweens.cs | 6 +- Runtime/Interpolation.cs | 22 ++- Runtime/TweenManager.cs | 10 +- Runtime/Tweener.cs | 26 ++- Runtime/Tweening.cs | 170 ++++++++++++------ 95 files changed, 1032 insertions(+), 1464 deletions(-) diff --git a/Runtime/Delegates.cs b/Runtime/Delegates.cs index a6a906a..bf31838 100644 --- a/Runtime/Delegates.cs +++ b/Runtime/Delegates.cs @@ -1,18 +1,24 @@ namespace Zigurous.Tweening { /// - /// A function delegate that gets the current value of a parameter. + /// A function delegate that gets the current value of a parameter from a + /// source object. /// + /// The type of the source object. /// The type of the parameter. + /// The source object to get the value from. /// The current value of the parameter. - public delegate T TweenGetter(); + public delegate T TweenGetter(S source); /// - /// A function delegate that sets a new value of a parameter. + /// A function delegate that sets a new value of a parameter on a source + /// object. /// + /// The type of the source object. /// The type of the parameter. + /// The source object to set the value on. /// The new value of the parameter. - public delegate void TweenSetter(T value); + public delegate void TweenSetter(S source, T value); /// /// A function delegate that can be invoked during various tween events @@ -31,5 +37,4 @@ /// Snaps the interpolated value to the nearest whole number. /// The interpolated value between the start and end value. public delegate T Interpolater(T a, T b, float t, bool snapping); - } diff --git a/Runtime/Extensions/Audio/AudioChorusFilterTweens.cs b/Runtime/Extensions/Audio/AudioChorusFilterTweens.cs index 7647f53..67a9004 100644 --- a/Runtime/Extensions/Audio/AudioChorusFilterTweens.cs +++ b/Runtime/Extensions/Audio/AudioChorusFilterTweens.cs @@ -5,40 +5,32 @@ namespace Zigurous.Tweening public static class AudioChorusFilterTweens { public static Tween TweenDelay(this AudioChorusFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.delay, - setter: delay => filter.delay = delay, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.delay, (source, value) => source.delay = value, to, duration) + .SetTarget(filter); public static Tween TweenRate(this AudioChorusFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.rate, - setter: rate => filter.rate = rate, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.rate, (source, value) => source.rate = value, to, duration) + .SetTarget(filter); public static Tween TweenDepth(this AudioChorusFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.depth, - setter: depth => filter.depth = depth, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.depth, (source, value) => source.depth = value, to, duration) + .SetTarget(filter); public static Tween TweenDryMix(this AudioChorusFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.dryMix, - setter: dryMix => filter.dryMix = dryMix, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.dryMix, (source, value) => source.dryMix = value, to, duration) + .SetTarget(filter); public static Tween TweenWetMix1(this AudioChorusFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.wetMix1, - setter: wetMix1 => filter.wetMix1 = wetMix1, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.wetMix1, (source, value) => source.wetMix1 = value, to, duration) + .SetTarget(filter); public static Tween TweenWetMix2(this AudioChorusFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.wetMix2, - setter: wetMix2 => filter.wetMix2 = wetMix2, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.wetMix2, (source, value) => source.wetMix2 = value, to, duration) + .SetTarget(filter); public static Tween TweenWetMix3(this AudioChorusFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.wetMix3, - setter: wetMix3 => filter.wetMix3 = wetMix3, - to, duration).SetTarget(filter); - + Tweening.To(filter, (source) => source.wetMix3, (source, value) => source.wetMix3 = value, to, duration) + .SetTarget(filter); } } diff --git a/Runtime/Extensions/Audio/AudioDistortionFilterTweens.cs b/Runtime/Extensions/Audio/AudioDistortionFilterTweens.cs index 55b1a52..514bb4c 100644 --- a/Runtime/Extensions/Audio/AudioDistortionFilterTweens.cs +++ b/Runtime/Extensions/Audio/AudioDistortionFilterTweens.cs @@ -5,10 +5,8 @@ namespace Zigurous.Tweening public static class AudioDistortionFilterTweens { public static Tween TweenDistortionLevel(this AudioDistortionFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.distortionLevel, - setter: distortionLevel => filter.distortionLevel = distortionLevel, - to, duration).SetTarget(filter); - + Tweening.To(filter, (source) => source.distortionLevel, (source, value) => source.distortionLevel = value, to, duration) + .SetTarget(filter); } } diff --git a/Runtime/Extensions/Audio/AudioEchoFilterTweens.cs b/Runtime/Extensions/Audio/AudioEchoFilterTweens.cs index 215a12f..e489686 100644 --- a/Runtime/Extensions/Audio/AudioEchoFilterTweens.cs +++ b/Runtime/Extensions/Audio/AudioEchoFilterTweens.cs @@ -5,25 +5,20 @@ namespace Zigurous.Tweening public static class AudioEchoFilterTweens { public static Tween TweenDelay(this AudioEchoFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.delay, - setter: delay => filter.delay = delay, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.delay, (source, value) => source.delay = value, to, duration) + .SetTarget(filter); public static Tween TweenDecayRatio(this AudioEchoFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.decayRatio, - setter: decayRatio => filter.decayRatio = decayRatio, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.decayRatio, (source, value) => source.decayRatio = value, to, duration) + .SetTarget(filter); public static Tween TweenDryMix(this AudioEchoFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.dryMix, - setter: dryMix => filter.dryMix = dryMix, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.dryMix, (source, value) => source.dryMix = value, to, duration) + .SetTarget(filter); public static Tween TweenWetMix(this AudioEchoFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.wetMix, - setter: wetMix => filter.wetMix = wetMix, - to, duration).SetTarget(filter); - + Tweening.To(filter, (source) => source.wetMix, (source, value) => source.wetMix = value, to, duration) + .SetTarget(filter); } } diff --git a/Runtime/Extensions/Audio/AudioHighPassFilterTweens.cs b/Runtime/Extensions/Audio/AudioHighPassFilterTweens.cs index 1742d10..af6844c 100644 --- a/Runtime/Extensions/Audio/AudioHighPassFilterTweens.cs +++ b/Runtime/Extensions/Audio/AudioHighPassFilterTweens.cs @@ -5,15 +5,12 @@ namespace Zigurous.Tweening public static class AudioHighPassFilterTweens { public static Tween TweenCutoffFrequency(this AudioHighPassFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.cutoffFrequency, - setter: cutoffFrequency => filter.cutoffFrequency = cutoffFrequency, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.cutoffFrequency, (source, value) => source.cutoffFrequency = value, to, duration) + .SetTarget(filter); public static Tween TweenHighpassResonanceQ(this AudioHighPassFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.highpassResonanceQ, - setter: highpassResonanceQ => filter.highpassResonanceQ = highpassResonanceQ, - to, duration).SetTarget(filter); - + Tweening.To(filter, (source) => source.highpassResonanceQ, (source, value) => source.highpassResonanceQ = value, to, duration) + .SetTarget(filter); } } diff --git a/Runtime/Extensions/Audio/AudioListenerTweens.cs b/Runtime/Extensions/Audio/AudioListenerTweens.cs index 22d5ba6..5fd6a44 100644 --- a/Runtime/Extensions/Audio/AudioListenerTweens.cs +++ b/Runtime/Extensions/Audio/AudioListenerTweens.cs @@ -5,10 +5,8 @@ namespace Zigurous.Tweening public static class AudioListenerTweens { public static Tween TweenVolume(this AudioListener listener, float to, float duration) => - Tweening.To(getter: () => AudioListener.volume, - setter: volume => AudioListener.volume = volume, - to, duration).SetTarget(listener); - + Tweening.To(listener, (source) => AudioListener.volume, (source, value) => AudioListener.volume = value, to, duration) + .SetTarget(listener); } } diff --git a/Runtime/Extensions/Audio/AudioLowPassFilterTweens.cs b/Runtime/Extensions/Audio/AudioLowPassFilterTweens.cs index d090fe4..a790d99 100644 --- a/Runtime/Extensions/Audio/AudioLowPassFilterTweens.cs +++ b/Runtime/Extensions/Audio/AudioLowPassFilterTweens.cs @@ -5,15 +5,12 @@ namespace Zigurous.Tweening public static class AudioLowPassFilterTweens { public static Tween TweenCutoffFrequency(this AudioLowPassFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.cutoffFrequency, - setter: cutoffFrequency => filter.cutoffFrequency = cutoffFrequency, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.cutoffFrequency, (source, value) => source.cutoffFrequency = value, to, duration) + .SetTarget(filter); public static Tween TweenLowpassResonanceQ(this AudioLowPassFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.lowpassResonanceQ, - setter: lowpassResonanceQ => filter.lowpassResonanceQ = lowpassResonanceQ, - to, duration).SetTarget(filter); - + Tweening.To(filter, (source) => source.lowpassResonanceQ, (source, value) => source.lowpassResonanceQ = value, to, duration) + .SetTarget(filter); } } diff --git a/Runtime/Extensions/Audio/AudioReverbFilterTweens.cs b/Runtime/Extensions/Audio/AudioReverbFilterTweens.cs index 1fb1d26..817e076 100644 --- a/Runtime/Extensions/Audio/AudioReverbFilterTweens.cs +++ b/Runtime/Extensions/Audio/AudioReverbFilterTweens.cs @@ -5,75 +5,60 @@ namespace Zigurous.Tweening public static class AudioReverbFilterTweens { public static Tween TweenDensity(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.density, - setter: density => filter.density = density, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.density, (source, value) => source.density = value, to, duration) + .SetTarget(filter); public static Tween TweenDiffusion(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.diffusion, - setter: diffusion => filter.diffusion = diffusion, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.diffusion, (source, value) => source.diffusion = value, to, duration) + .SetTarget(filter); public static Tween TweenReverbDelay(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.reverbDelay, - setter: reverbDelay => filter.reverbDelay = reverbDelay, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.reverbDelay, (source, value) => source.reverbDelay = value, to, duration) + .SetTarget(filter); public static Tween TweenReverbLevel(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.reverbLevel, - setter: reverbLevel => filter.reverbLevel = reverbLevel, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.reverbLevel, (source, value) => source.reverbLevel = value, to, duration) + .SetTarget(filter); public static Tween TweenReflectionsDelay(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.reflectionsDelay, - setter: reflectionsDelay => filter.reflectionsDelay = reflectionsDelay, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.reflectionsDelay, (source, value) => source.reflectionsDelay = value, to, duration) + .SetTarget(filter); public static Tween TweenReflectionsLevel(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.reflectionsLevel, - setter: reflectionsLevel => filter.reflectionsLevel = reflectionsLevel, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.reflectionsLevel, (source, value) => source.reflectionsLevel = value, to, duration) + .SetTarget(filter); public static Tween TweenDecayHFRatio(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.decayHFRatio, - setter: decayHFRatio => filter.decayHFRatio = decayHFRatio, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.decayHFRatio, (source, value) => source.decayHFRatio = value, to, duration) + .SetTarget(filter); public static Tween TweenDecayTime(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.decayTime, - setter: decayTime => filter.decayTime = decayTime, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.decayTime, (source, value) => source.decayTime = value, to, duration) + .SetTarget(filter); public static Tween TweenRoom(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.room, - setter: room => filter.room = room, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.room, (source, value) => source.room = value, to, duration) + .SetTarget(filter); public static Tween TweenRoomHF(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.roomHF, - setter: roomHF => filter.roomHF = roomHF, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.roomHF, (source, value) => source.roomHF = value, to, duration) + .SetTarget(filter); public static Tween TweenRoomLF(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.roomLF, - setter: roomLF => filter.roomLF = roomLF, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.roomLF, (source, value) => source.roomLF = value, to, duration) + .SetTarget(filter); public static Tween TweenDryLevel(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.dryLevel, - setter: dryLevel => filter.dryLevel = dryLevel, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.dryLevel, (source, value) => source.dryLevel = value, to, duration) + .SetTarget(filter); public static Tween TweenHFReference(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.hfReference, - setter: hfReference => filter.hfReference = hfReference, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.hfReference, (source, value) => source.hfReference = value, to, duration) + .SetTarget(filter); public static Tween TweenLFReference(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(getter: () => filter.lfReference, - setter: lfReference => filter.lfReference = lfReference, - to, duration).SetTarget(filter); - + Tweening.To(filter, (source) => source.lfReference, (source, value) => source.lfReference = value, to, duration) + .SetTarget(filter); } } diff --git a/Runtime/Extensions/Audio/AudioReverbZoneTweens.cs b/Runtime/Extensions/Audio/AudioReverbZoneTweens.cs index 322dd52..251b8d0 100644 --- a/Runtime/Extensions/Audio/AudioReverbZoneTweens.cs +++ b/Runtime/Extensions/Audio/AudioReverbZoneTweens.cs @@ -5,55 +5,44 @@ namespace Zigurous.Tweening public static class AudioReverbZoneTweens { public static Tween TweenMaxDistance(this AudioReverbZone filter, float to, float duration) => - Tweening.To(getter: () => filter.maxDistance, - setter: maxDistance => filter.maxDistance = maxDistance, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.maxDistance, (source, value) => source.maxDistance = value, to, duration) + .SetTarget(filter); public static Tween TweenMinDistance(this AudioReverbZone filter, float to, float duration) => - Tweening.To(getter: () => filter.minDistance, - setter: minDistance => filter.minDistance = minDistance, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.minDistance, (source, value) => source.minDistance = value, to, duration) + .SetTarget(filter); public static Tween TweenDiffusion(this AudioReverbZone filter, float to, float duration) => - Tweening.To(getter: () => filter.diffusion, - setter: diffusion => filter.diffusion = diffusion, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.diffusion, (source, value) => source.diffusion = value, to, duration) + .SetTarget(filter); public static Tween TweenDensity(this AudioReverbZone filter, float to, float duration) => - Tweening.To(getter: () => filter.density, - setter: density => filter.density = density, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.density, (source, value) => source.density = value, to, duration) + .SetTarget(filter); public static Tween TweenReverbDelay(this AudioReverbZone filter, float to, float duration) => - Tweening.To(getter: () => filter.reverbDelay, - setter: reverbDelay => filter.reverbDelay = reverbDelay, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.reverbDelay, (source, value) => source.reverbDelay = value, to, duration) + .SetTarget(filter); public static Tween TweenReflectionsDelay(this AudioReverbZone filter, float to, float duration) => - Tweening.To(getter: () => filter.reflectionsDelay, - setter: reflectionsDelay => filter.reflectionsDelay = reflectionsDelay, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.reflectionsDelay, (source, value) => source.reflectionsDelay = value, to, duration) + .SetTarget(filter); public static Tween TweenDecayHFRatio(this AudioReverbZone filter, float to, float duration) => - Tweening.To(getter: () => filter.decayHFRatio, - setter: decayHFRatio => filter.decayHFRatio = decayHFRatio, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.decayHFRatio, (source, value) => source.decayHFRatio = value, to, duration) + .SetTarget(filter); public static Tween TweenDecayTime(this AudioReverbZone filter, float to, float duration) => - Tweening.To(getter: () => filter.decayTime, - setter: decayTime => filter.decayTime = decayTime, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.decayTime, (source, value) => source.decayTime = value, to, duration) + .SetTarget(filter); public static Tween TweenHFReference(this AudioReverbZone filter, float to, float duration) => - Tweening.To(getter: () => filter.HFReference, - setter: HFReference => filter.HFReference = HFReference, - to, duration).SetTarget(filter); + Tweening.To(filter, (source) => source.HFReference, (source, value) => source.HFReference = value, to, duration) + .SetTarget(filter); public static Tween TweenLFReference(this AudioReverbZone filter, float to, float duration) => - Tweening.To(getter: () => filter.LFReference, - setter: LFReference => filter.LFReference = LFReference, - to, duration).SetTarget(filter); - + Tweening.To(filter, (source) => source.LFReference, (source, value) => source.LFReference = value, to, duration) + .SetTarget(filter); } } diff --git a/Runtime/Extensions/Audio/AudioSourceTweens.cs b/Runtime/Extensions/Audio/AudioSourceTweens.cs index 755992f..0116e97 100644 --- a/Runtime/Extensions/Audio/AudioSourceTweens.cs +++ b/Runtime/Extensions/Audio/AudioSourceTweens.cs @@ -4,56 +4,45 @@ namespace Zigurous.Tweening { public static class AudioSourceTweens { - public static Tween TweenTime(this AudioSource source, float to, float duration) => - Tweening.To(getter: () => source.time, - setter: time => source.time = time, - to, duration).SetTarget(source); - - public static Tween TweenPitch(this AudioSource source, float to, float duration) => - Tweening.To(getter: () => source.pitch, - setter: pitch => source.pitch = pitch, - to, duration).SetTarget(source); - - public static Tween TweenVolume(this AudioSource source, float to, float duration) => - Tweening.To(getter: () => source.volume, - setter: volume => source.volume = volume, - to, duration).SetTarget(source); - - public static Tween TweenPanStereo(this AudioSource source, float to, float duration) => - Tweening.To(getter: () => source.panStereo, - setter: panStereo => source.panStereo = panStereo, - to, duration).SetTarget(source); - - public static Tween TweenSpatialBlend(this AudioSource source, float to, float duration) => - Tweening.To(getter: () => source.spatialBlend, - setter: spatialBlend => source.spatialBlend = spatialBlend, - to, duration).SetTarget(source); - - public static Tween TweenReverbZoneMix(this AudioSource source, float to, float duration) => - Tweening.To(getter: () => source.reverbZoneMix, - setter: reverbZoneMix => source.reverbZoneMix = reverbZoneMix, - to, duration).SetTarget(source); - - public static Tween TweenDopplerLevel(this AudioSource source, float to, float duration) => - Tweening.To(getter: () => source.dopplerLevel, - setter: dopplerLevel => source.dopplerLevel = dopplerLevel, - to, duration).SetTarget(source); - - public static Tween TweenSpread(this AudioSource source, float to, float duration) => - Tweening.To(getter: () => source.spread, - setter: spread => source.spread = spread, - to, duration).SetTarget(source); - - public static Tween TweenMinDistance(this AudioSource source, float to, float duration) => - Tweening.To(getter: () => source.minDistance, - setter: minDistance => source.minDistance = minDistance, - to, duration).SetTarget(source); - - public static Tween TweenMaxDistance(this AudioSource source, float to, float duration) => - Tweening.To(getter: () => source.maxDistance, - setter: maxDistance => source.maxDistance = maxDistance, - to, duration).SetTarget(source); + public static Tween TweenTime(this AudioSource audioSource, float to, float duration) => + Tweening.To(audioSource, (source) => source.time, (source, value) => source.time = value, to, duration) + .SetTarget(audioSource); + public static Tween TweenPitch(this AudioSource audioSource, float to, float duration) => + Tweening.To(audioSource, (source) => source.pitch, (source, value) => source.pitch = value, to, duration) + .SetTarget(audioSource); + + public static Tween TweenVolume(this AudioSource audioSource, float to, float duration) => + Tweening.To(audioSource, (source) => source.volume, (source, value) => source.volume = value, to, duration) + .SetTarget(audioSource); + + public static Tween TweenPanStereo(this AudioSource audioSource, float to, float duration) => + Tweening.To(audioSource, (source) => source.panStereo, (source, value) => source.panStereo = value, to, duration) + .SetTarget(audioSource); + + public static Tween TweenSpatialBlend(this AudioSource audioSource, float to, float duration) => + Tweening.To(audioSource, (source) => source.spatialBlend, (source, value) => source.spatialBlend = value, to, duration) + .SetTarget(audioSource); + + public static Tween TweenReverbZoneMix(this AudioSource audioSource, float to, float duration) => + Tweening.To(audioSource, (source) => source.reverbZoneMix, (source, value) => source.reverbZoneMix = value, to, duration) + .SetTarget(audioSource); + + public static Tween TweenDopplerLevel(this AudioSource audioSource, float to, float duration) => + Tweening.To(audioSource, (source) => source.dopplerLevel, (source, value) => source.dopplerLevel = value, to, duration) + .SetTarget(audioSource); + + public static Tween TweenSpread(this AudioSource audioSource, float to, float duration) => + Tweening.To(audioSource, (source) => source.spread, (source, value) => source.spread = value, to, duration) + .SetTarget(audioSource); + + public static Tween TweenMinDistance(this AudioSource audioSource, float to, float duration) => + Tweening.To(audioSource, (source) => source.minDistance, (source, value) => source.minDistance = value, to, duration) + .SetTarget(audioSource); + + public static Tween TweenMaxDistance(this AudioSource audioSource, float to, float duration) => + Tweening.To(audioSource, (source) => source.maxDistance, (source, value) => source.maxDistance = value, to, duration) + .SetTarget(audioSource); } } diff --git a/Runtime/Extensions/Misc/AimConstraintTweens.cs b/Runtime/Extensions/Misc/AimConstraintTweens.cs index d506e0f..664cacf 100644 --- a/Runtime/Extensions/Misc/AimConstraintTweens.cs +++ b/Runtime/Extensions/Misc/AimConstraintTweens.cs @@ -6,35 +6,28 @@ namespace Zigurous.Tweening public static class AimConstraintTweens { public static Tween TweenWeight(this AimConstraint constraint, float to, float duration) => - Tweening.To(getter: () => constraint.weight, - setter: weight => constraint.weight = weight, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.weight, (source, value) => source.weight = value, to, duration) + .SetTarget(constraint); public static Tween TweenUpVector(this AimConstraint constraint, Vector3 to, float duration) => - Tweening.To(getter: () => constraint.upVector, - setter: upVector => constraint.upVector = upVector, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.upVector, (source, value) => source.upVector = value, to, duration) + .SetTarget(constraint); public static Tween TweenWorldUpVector(this AimConstraint constraint, Vector3 to, float duration) => - Tweening.To(getter: () => constraint.worldUpVector, - setter: worldUpVector => constraint.worldUpVector = worldUpVector, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.worldUpVector, (source, value) => source.worldUpVector = value, to, duration) + .SetTarget(constraint); public static Tween TweenAimVector(this AimConstraint constraint, Vector3 to, float duration) => - Tweening.To(getter: () => constraint.aimVector, - setter: aimVector => constraint.aimVector = aimVector, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.aimVector, (source, value) => source.aimVector = value, to, duration) + .SetTarget(constraint); public static Tween TweenRotationOffset(this AimConstraint constraint, Vector3 to, float duration) => - Tweening.To(getter: () => constraint.rotationOffset, - setter: rotationOffset => constraint.rotationOffset = rotationOffset, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.rotationOffset, (source, value) => source.rotationOffset = value, to, duration) + .SetTarget(constraint); public static Tween TweenRotationAtRest(this AimConstraint constraint, Vector3 to, float duration) => - Tweening.To(getter: () => constraint.rotationAtRest, - setter: rotationAtRest => constraint.rotationAtRest = rotationAtRest, - to, duration).SetTarget(constraint); - + Tweening.To(constraint, (source) => source.rotationAtRest, (source, value) => source.rotationAtRest = value, to, duration) + .SetTarget(constraint); } } diff --git a/Runtime/Extensions/Misc/GridTweens.cs b/Runtime/Extensions/Misc/GridTweens.cs index 4814673..8b33065 100644 --- a/Runtime/Extensions/Misc/GridTweens.cs +++ b/Runtime/Extensions/Misc/GridTweens.cs @@ -5,15 +5,12 @@ namespace Zigurous.Tweening public static class GridTweens { public static Tween TweenCellSize(this Grid grid, Vector3 to, float duration) => - Tweening.To(getter: () => grid.cellSize, - setter: cellSize => grid.cellSize = cellSize, - to, duration).SetTarget(grid); + Tweening.To(grid, (source) => source.cellSize, (source, value) => source.cellSize = value, to, duration) + .SetTarget(grid); public static Tween TweenCellGap(this Grid grid, Vector3 to, float duration) => - Tweening.To(getter: () => grid.cellGap, - setter: cellGap => grid.cellGap = cellGap, - to, duration).SetTarget(grid); - + Tweening.To(grid, (source) => source.cellGap, (source, value) => source.cellGap = value, to, duration) + .SetTarget(grid); } } diff --git a/Runtime/Extensions/Misc/LookAtConstraintTweens.cs b/Runtime/Extensions/Misc/LookAtConstraintTweens.cs index d36066a..0e8efcd 100644 --- a/Runtime/Extensions/Misc/LookAtConstraintTweens.cs +++ b/Runtime/Extensions/Misc/LookAtConstraintTweens.cs @@ -6,25 +6,20 @@ namespace Zigurous.Tweening public static class LookAtConstraintTweens { public static Tween TweenWeight(this LookAtConstraint constraint, float to, float duration) => - Tweening.To(getter: () => constraint.weight, - setter: weight => constraint.weight = weight, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.weight, (source, value) => source.weight = value, to, duration) + .SetTarget(constraint); public static Tween TweenRoll(this LookAtConstraint constraint, float to, float duration) => - Tweening.To(getter: () => constraint.roll, - setter: roll => constraint.roll = roll, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.roll, (source, value) => source.roll = value, to, duration) + .SetTarget(constraint); public static Tween TweenRotationOffset(this LookAtConstraint constraint, Vector3 to, float duration) => - Tweening.To(getter: () => constraint.rotationOffset, - setter: rotationOffset => constraint.rotationOffset = rotationOffset, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.rotationOffset, (source, value) => source.rotationOffset = value, to, duration) + .SetTarget(constraint); public static Tween TweenRotationAtRest(this LookAtConstraint constraint, Vector3 to, float duration) => - Tweening.To(getter: () => constraint.rotationAtRest, - setter: rotationAtRest => constraint.rotationAtRest = rotationAtRest, - to, duration).SetTarget(constraint); - + Tweening.To(constraint, (source) => source.rotationAtRest, (source, value) => source.rotationAtRest = value, to, duration) + .SetTarget(constraint); } } diff --git a/Runtime/Extensions/Misc/ParentConstraintTweens.cs b/Runtime/Extensions/Misc/ParentConstraintTweens.cs index b89c53d..c192c7b 100644 --- a/Runtime/Extensions/Misc/ParentConstraintTweens.cs +++ b/Runtime/Extensions/Misc/ParentConstraintTweens.cs @@ -6,20 +6,16 @@ namespace Zigurous.Tweening public static class ParentConstraintTweens { public static Tween TweenWeight(this ParentConstraint constraint, float to, float duration) => - Tweening.To(getter: () => constraint.weight, - setter: weight => constraint.weight = weight, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.weight, (source, value) => source.weight = value, to, duration) + .SetTarget(constraint); public static Tween TweenRotationAtRest(this ParentConstraint constraint, Vector3 to, float duration) => - Tweening.To(getter: () => constraint.rotationAtRest, - setter: rotationAtRest => constraint.rotationAtRest = rotationAtRest, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.rotationAtRest, (source, value) => source.rotationAtRest = value, to, duration) + .SetTarget(constraint); public static Tween TweenTranslationAtRest(this ParentConstraint constraint, Vector3 to, float duration) => - Tweening.To(getter: () => constraint.translationAtRest, - setter: translationAtRest => constraint.translationAtRest = translationAtRest, - to, duration).SetTarget(constraint); - + Tweening.To(constraint, (source) => source.translationAtRest, (source, value) => source.translationAtRest = value, to, duration) + .SetTarget(constraint); } } diff --git a/Runtime/Extensions/Misc/PositionConstraintTweens.cs b/Runtime/Extensions/Misc/PositionConstraintTweens.cs index 93bd121..871f637 100644 --- a/Runtime/Extensions/Misc/PositionConstraintTweens.cs +++ b/Runtime/Extensions/Misc/PositionConstraintTweens.cs @@ -6,20 +6,16 @@ namespace Zigurous.Tweening public static class PositionConstraintTweens { public static Tween TweenWeight(this PositionConstraint constraint, float to, float duration) => - Tweening.To(getter: () => constraint.weight, - setter: weight => constraint.weight = weight, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.weight, (source, value) => source.weight = value, to, duration) + .SetTarget(constraint); public static Tween TweenTranslationAtRest(this PositionConstraint constraint, Vector3 to, float duration) => - Tweening.To(getter: () => constraint.translationAtRest, - setter: translationAtRest => constraint.translationAtRest = translationAtRest, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.translationAtRest, (source, value) => source.translationAtRest = value, to, duration) + .SetTarget(constraint); public static Tween TweenTranslationOffset(this PositionConstraint constraint, Vector3 to, float duration) => - Tweening.To(getter: () => constraint.translationOffset, - setter: translationOffset => constraint.translationOffset = translationOffset, - to, duration).SetTarget(constraint); - + Tweening.To(constraint, (source) => source.translationOffset, (source, value) => source.translationOffset = value, to, duration) + .SetTarget(constraint); } } diff --git a/Runtime/Extensions/Misc/RectOffsetTweens.cs b/Runtime/Extensions/Misc/RectOffsetTweens.cs index dbbf610..6773789 100644 --- a/Runtime/Extensions/Misc/RectOffsetTweens.cs +++ b/Runtime/Extensions/Misc/RectOffsetTweens.cs @@ -5,25 +5,20 @@ namespace Zigurous.Tweening public static class RectOffsetTweens { public static Tween TweenLeft(this RectOffset offset, int to, float duration) => - Tweening.To(getter: () => offset.left, - setter: left => offset.left = left, - to, duration).SetId(offset.GetHashCode()); + Tweening.To(offset, (source) => source.left, (source, value) => source.left = value, to, duration) + .SetId(offset.GetHashCode()); public static Tween TweenRight(this RectOffset offset, int to, float duration) => - Tweening.To(getter: () => offset.right, - setter: right => offset.right = right, - to, duration).SetId(offset.GetHashCode()); + Tweening.To(offset, (source) => source.right, (source, value) => source.right = value, to, duration) + .SetId(offset.GetHashCode()); public static Tween TweenTop(this RectOffset offset, int to, float duration) => - Tweening.To(getter: () => offset.top, - setter: top => offset.top = top, - to, duration).SetId(offset.GetHashCode()); + Tweening.To(offset, (source) => source.top, (source, value) => source.top = value, to, duration) + .SetId(offset.GetHashCode()); public static Tween TweenBottom(this RectOffset offset, int to, float duration) => - Tweening.To(getter: () => offset.bottom, - setter: bottom => offset.bottom = bottom, - to, duration).SetId(offset.GetHashCode()); - + Tweening.To(offset, (source) => source.bottom, (source, value) => source.bottom = value, to, duration) + .SetId(offset.GetHashCode()); } } diff --git a/Runtime/Extensions/Misc/RotationConstraintTweens.cs b/Runtime/Extensions/Misc/RotationConstraintTweens.cs index 7ec36d2..8b6e64f 100644 --- a/Runtime/Extensions/Misc/RotationConstraintTweens.cs +++ b/Runtime/Extensions/Misc/RotationConstraintTweens.cs @@ -6,20 +6,16 @@ namespace Zigurous.Tweening public static class RotationConstraintTweens { public static Tween TweenWeight(this RotationConstraint constraint, float to, float duration) => - Tweening.To(getter: () => constraint.weight, - setter: weight => constraint.weight = weight, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.weight, (source, value) => source.weight = value, to, duration) + .SetTarget(constraint); public static Tween TweenRotationAtRest(this RotationConstraint constraint, Vector3 to, float duration) => - Tweening.To(getter: () => constraint.rotationAtRest, - setter: rotationAtRest => constraint.rotationAtRest = rotationAtRest, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.rotationAtRest, (source, value) => source.rotationAtRest = value, to, duration) + .SetTarget(constraint); public static Tween TweenRotationOffset(this RotationConstraint constraint, Vector3 to, float duration) => - Tweening.To(getter: () => constraint.rotationOffset, - setter: rotationOffset => constraint.rotationOffset = rotationOffset, - to, duration).SetTarget(constraint); - + Tweening.To(constraint, (source) => source.rotationOffset, (source, value) => source.rotationOffset = value, to, duration) + .SetTarget(constraint); } } diff --git a/Runtime/Extensions/Misc/ScaleConstraintTweens.cs b/Runtime/Extensions/Misc/ScaleConstraintTweens.cs index 1cda2e7..692c31f 100644 --- a/Runtime/Extensions/Misc/ScaleConstraintTweens.cs +++ b/Runtime/Extensions/Misc/ScaleConstraintTweens.cs @@ -6,20 +6,16 @@ namespace Zigurous.Tweening public static class ScaleConstraintTweens { public static Tween TweenWeight(this ScaleConstraint constraint, float to, float duration) => - Tweening.To(getter: () => constraint.weight, - setter: weight => constraint.weight = weight, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.weight, (source, value) => source.weight = value, to, duration) + .SetTarget(constraint); public static Tween TweenScaleAtRest(this ScaleConstraint constraint, Vector3 to, float duration) => - Tweening.To(getter: () => constraint.scaleAtRest, - setter: scaleAtRest => constraint.scaleAtRest = scaleAtRest, - to, duration).SetTarget(constraint); + Tweening.To(constraint, (source) => source.scaleAtRest, (source, value) => source.scaleAtRest = value, to, duration) + .SetTarget(constraint); public static Tween TweenScaleOffset(this ScaleConstraint constraint, Vector3 to, float duration) => - Tweening.To(getter: () => constraint.scaleOffset, - setter: scaleOffset => constraint.scaleOffset = scaleOffset, - to, duration).SetTarget(constraint); - + Tweening.To(constraint, (source) => source.scaleOffset, (source, value) => source.scaleOffset = value, to, duration) + .SetTarget(constraint); } } diff --git a/Runtime/Extensions/Misc/TransformTweens.cs b/Runtime/Extensions/Misc/TransformTweens.cs index 2e4494f..6631c20 100644 --- a/Runtime/Extensions/Misc/TransformTweens.cs +++ b/Runtime/Extensions/Misc/TransformTweens.cs @@ -5,74 +5,60 @@ namespace Zigurous.Tweening public static class TransformTweens { public static Tween TweenPosition(this Transform transform, Vector3 to, float duration) => - Tweening.To(getter: () => transform.position, - setter: position => transform.position = position, - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.position, (source, value) => source.position = value, to, duration) + .SetTarget(transform); public static Tween TweenPositionX(this Transform transform, float to, float duration) => - Tweening.To(getter: () => transform.position.x, - setter: x => transform.position = new Vector3(x, transform.position.y, transform.position.z), - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.position.x, (source, value) => source.position = new Vector3(value, source.position.y, source.position.z), to, duration) + .SetTarget(transform); public static Tween TweenPositionY(this Transform transform, float to, float duration) => - Tweening.To(getter: () => transform.position.y, - setter: y => transform.position = new Vector3(transform.position.x, y, transform.position.z), - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.position.y, (source, value) => source.position = new Vector3(source.position.x, value, source.position.z), to, duration) + .SetTarget(transform); public static Tween TweenPositionZ(this Transform transform, float to, float duration) => - Tweening.To(getter: () => transform.position.z, - setter: z => transform.position = new Vector3(transform.position.x, transform.position.y, z), - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.position.z, (source, value) => source.position = new Vector3(source.position.x, source.position.y, value), to, duration) + .SetTarget(transform); public static Tween TweenLocalPosition(this Transform transform, Vector3 to, float duration) => - Tweening.To(getter: () => transform.localPosition, - setter: position => transform.localPosition = position, - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.localPosition, (source, value) => source.localPosition = value, to, duration) + .SetTarget(transform); public static Tween TweenLocalPositionX(this Transform transform, float to, float duration) => - Tweening.To(getter: () => transform.localPosition.x, - setter: x => transform.localPosition = new Vector3(x, transform.localPosition.y, transform.localPosition.z), - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.localPosition.x, (source, value) => source.localPosition = new Vector3(value, source.localPosition.y, source.localPosition.z), to, duration) + .SetTarget(transform); public static Tween TweenLocalPositionY(this Transform transform, float to, float duration) => - Tweening.To(getter: () => transform.localPosition.y, - setter: y => transform.localPosition = new Vector3(transform.localPosition.x, y, transform.localPosition.z), - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.localPosition.y, (source, value) => source.localPosition = new Vector3(source.localPosition.x, value, source.localPosition.z), to, duration) + .SetTarget(transform); public static Tween TweenLocalPositionZ(this Transform transform, float to, float duration) => - Tweening.To(getter: () => transform.localPosition.z, - setter: z => transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, z), - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.localPosition.z, (source, value) => source.localPosition = new Vector3(source.localPosition.x, source.localPosition.y, value), to, duration) + .SetTarget(transform); public static Tween TweenScale(this Transform transform, Vector3 to, float duration) => - Tweening.To(getter: () => transform.localScale, - setter: scale => transform.localScale = scale, - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.localScale, (source, value) => source.localScale = value, to, duration) + .SetTarget(transform); public static Tween TweenScaleX(this Transform transform, float to, float duration) => - Tweening.To(getter: () => transform.localScale.x, - setter: x => transform.localScale = new Vector3(x, transform.localScale.y, transform.localScale.z), - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.localScale.x, (source, value) => source.localScale = new Vector3(value, source.localScale.y, source.localScale.z), to, duration) + .SetTarget(transform); public static Tween TweenScaleY(this Transform transform, float to, float duration) => - Tweening.To(getter: () => transform.localScale.y, - setter: y => transform.localScale = new Vector3(transform.localScale.x, y, transform.localScale.z), - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.localScale.y, (source, value) => source.localScale = new Vector3(source.localScale.x, value, source.localScale.z), to, duration) + .SetTarget(transform); public static Tween TweenScaleZ(this Transform transform, float to, float duration) => - Tweening.To(getter: () => transform.localScale.z, - setter: z => transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y, z), - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.localScale.z, (source, value) => source.localScale = new Vector3(source.localScale.x, source.localScale.y, value), to, duration) + .SetTarget(transform); public static Tween TweenRotation(this Transform transform, Quaternion to, float duration) => - Tweening.To(getter: () => transform.rotation, - setter: rotation => transform.rotation = rotation, - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.rotation, (source, value) => source.rotation = value, to, duration) + .SetTarget(transform); public static Tween TweenLocalRotation(this Transform transform, Quaternion to, float duration) => - Tweening.To(getter: () => transform.localRotation, - setter: rotation => transform.localRotation = rotation, - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.localRotation, (source, value) => source.localRotation = value, to, duration) + .SetTarget(transform); public static Tween TweenEulerAngles(this Transform transform, Vector3 to, float duration) => TweenRotation(transform, Quaternion.Euler(to), duration); @@ -97,7 +83,6 @@ public static Tween TweenLocalEulerAnglesY(this Transform transform, float to, f public static Tween TweenLocalEulerAnglesZ(this Transform transform, float to, float duration) => TweenLocalRotation(transform, Quaternion.Euler(transform.localEulerAngles.x, transform.localEulerAngles.y, to), duration); - } } diff --git a/Runtime/Extensions/Navigation/NavMeshAgentTweens.cs b/Runtime/Extensions/Navigation/NavMeshAgentTweens.cs index 57ea45f..e507091 100644 --- a/Runtime/Extensions/Navigation/NavMeshAgentTweens.cs +++ b/Runtime/Extensions/Navigation/NavMeshAgentTweens.cs @@ -6,55 +6,44 @@ namespace Zigurous.Tweening public static class NavMeshAgentTweens { public static Tween TweenSpeed(this NavMeshAgent agent, float to, float duration) => - Tweening.To(getter: () => agent.speed, - setter: speed => agent.speed = speed, - to, duration).SetTarget(agent); + Tweening.To(agent, (source) => source.speed, (source, value) => source.speed = value, to, duration) + .SetTarget(agent); public static Tween TweenAngularSpeed(this NavMeshAgent agent, float to, float duration) => - Tweening.To(getter: () => agent.angularSpeed, - setter: angularSpeed => agent.angularSpeed = angularSpeed, - to, duration).SetTarget(agent); + Tweening.To(agent, (source) => source.angularSpeed, (source, value) => source.angularSpeed = value, to, duration) + .SetTarget(agent); public static Tween TweenAcceleration(this NavMeshAgent agent, float to, float duration) => - Tweening.To(getter: () => agent.acceleration, - setter: acceleration => agent.acceleration = acceleration, - to, duration).SetTarget(agent); + Tweening.To(agent, (source) => source.acceleration, (source, value) => source.acceleration = value, to, duration) + .SetTarget(agent); public static Tween TweenRadius(this NavMeshAgent agent, float to, float duration) => - Tweening.To(getter: () => agent.radius, - setter: radius => agent.radius = radius, - to, duration).SetTarget(agent); + Tweening.To(agent, (source) => source.radius, (source, value) => source.radius = value, to, duration) + .SetTarget(agent); public static Tween TweenHeight(this NavMeshAgent agent, float to, float duration) => - Tweening.To(getter: () => agent.height, - setter: height => agent.height = height, - to, duration).SetTarget(agent); + Tweening.To(agent, (source) => source.height, (source, value) => source.height = value, to, duration) + .SetTarget(agent); public static Tween TweenBaseOffset(this NavMeshAgent agent, float to, float duration) => - Tweening.To(getter: () => agent.baseOffset, - setter: baseOffset => agent.baseOffset = baseOffset, - to, duration).SetTarget(agent); + Tweening.To(agent, (source) => source.baseOffset, (source, value) => source.baseOffset = value, to, duration) + .SetTarget(agent); public static Tween TweenNextPosition(this NavMeshAgent agent, Vector3 to, float duration) => - Tweening.To(getter: () => agent.nextPosition, - setter: nextPosition => agent.nextPosition = nextPosition, - to, duration).SetTarget(agent); + Tweening.To(agent, (source) => source.nextPosition, (source, value) => source.nextPosition = value, to, duration) + .SetTarget(agent); public static Tween TweenDestination(this NavMeshAgent agent, Vector3 to, float duration) => - Tweening.To(getter: () => agent.destination, - setter: destination => agent.destination = destination, - to, duration).SetTarget(agent); + Tweening.To(agent, (source) => source.destination, (source, value) => source.destination = value, to, duration) + .SetTarget(agent); public static Tween TweenVelocity(this NavMeshAgent agent, Vector3 to, float duration) => - Tweening.To(getter: () => agent.velocity, - setter: velocity => agent.velocity = velocity, - to, duration).SetTarget(agent); + Tweening.To(agent, (source) => source.velocity, (source, value) => source.velocity = value, to, duration) + .SetTarget(agent); public static Tween TweenStoppingDistance(this NavMeshAgent agent, float to, float duration) => - Tweening.To(getter: () => agent.stoppingDistance, - setter: stoppingDistance => agent.stoppingDistance = stoppingDistance, - to, duration).SetTarget(agent); - + Tweening.To(agent, (source) => source.stoppingDistance, (source, value) => source.stoppingDistance = value, to, duration) + .SetTarget(agent); } } diff --git a/Runtime/Extensions/Navigation/NavMeshObstacleTweens.cs b/Runtime/Extensions/Navigation/NavMeshObstacleTweens.cs index 01bf08b..333ff9f 100644 --- a/Runtime/Extensions/Navigation/NavMeshObstacleTweens.cs +++ b/Runtime/Extensions/Navigation/NavMeshObstacleTweens.cs @@ -6,30 +6,24 @@ namespace Zigurous.Tweening public static class NavMeshObstacleTweens { public static Tween TweenHeight(this NavMeshObstacle obstacle, float to, float duration) => - Tweening.To(getter: () => obstacle.height, - setter: height => obstacle.height = height, - to, duration).SetTarget(obstacle); + Tweening.To(obstacle, (source) => source.height, (source, value) => source.height = value, to, duration) + .SetTarget(obstacle); public static Tween TweenRadius(this NavMeshObstacle obstacle, float to, float duration) => - Tweening.To(getter: () => obstacle.radius, - setter: radius => obstacle.radius = radius, - to, duration).SetTarget(obstacle); + Tweening.To(obstacle, (source) => source.radius, (source, value) => source.radius = value, to, duration) + .SetTarget(obstacle); public static Tween TweenSize(this NavMeshObstacle obstacle, Vector3 to, float duration) => - Tweening.To(getter: () => obstacle.size, - setter: size => obstacle.size = size, - to, duration).SetTarget(obstacle); + Tweening.To(obstacle, (source) => source.size, (source, value) => source.size = value, to, duration) + .SetTarget(obstacle); public static Tween TweenCenter(this NavMeshObstacle obstacle, Vector3 to, float duration) => - Tweening.To(getter: () => obstacle.center, - setter: center => obstacle.center = center, - to, duration).SetTarget(obstacle); + Tweening.To(obstacle, (source) => source.center, (source, value) => source.center = value, to, duration) + .SetTarget(obstacle); public static Tween TweenVelocity(this NavMeshObstacle obstacle, Vector3 to, float duration) => - Tweening.To(getter: () => obstacle.velocity, - setter: velocity => obstacle.velocity = velocity, - to, duration).SetTarget(obstacle); - + Tweening.To(obstacle, (source) => source.velocity, (source, value) => source.velocity = value, to, duration) + .SetTarget(obstacle); } } diff --git a/Runtime/Extensions/Physics/BoxColliderTweens.cs b/Runtime/Extensions/Physics/BoxColliderTweens.cs index 8fc0c47..1f8af2a 100644 --- a/Runtime/Extensions/Physics/BoxColliderTweens.cs +++ b/Runtime/Extensions/Physics/BoxColliderTweens.cs @@ -5,15 +5,12 @@ namespace Zigurous.Tweening public static class BoxColliderTweens { public static Tween TweenCenter(this BoxCollider collider, Vector3 to, float duration) => - Tweening.To(getter: () => collider.center, - setter: center => collider.center = center, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.center, (source, value) => source.center = value, to, duration) + .SetTarget(collider); public static Tween TweenSize(this BoxCollider collider, Vector3 to, float duration) => - Tweening.To(getter: () => collider.size, - setter: size => collider.size = size, - to, duration).SetTarget(collider); - + Tweening.To(collider, (source) => source.size, (source, value) => source.size = value, to, duration) + .SetTarget(collider); } } diff --git a/Runtime/Extensions/Physics/CapsuleColliderTweens.cs b/Runtime/Extensions/Physics/CapsuleColliderTweens.cs index ac96fdd..3d5b218 100644 --- a/Runtime/Extensions/Physics/CapsuleColliderTweens.cs +++ b/Runtime/Extensions/Physics/CapsuleColliderTweens.cs @@ -5,20 +5,16 @@ namespace Zigurous.Tweening public static class CapsuleColliderTweens { public static Tween TweenCenter(this CapsuleCollider collider, Vector3 to, float duration) => - Tweening.To(getter: () => collider.center, - setter: center => collider.center = center, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.center, (source, value) => source.center = value, to, duration) + .SetTarget(collider); public static Tween TweenRadius(this CapsuleCollider collider, float to, float duration) => - Tweening.To(getter: () => collider.radius, - setter: radius => collider.radius = radius, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.radius, (source, value) => source.radius = value, to, duration) + .SetTarget(collider); public static Tween TweenHeight(this CapsuleCollider collider, float to, float duration) => - Tweening.To(getter: () => collider.height, - setter: height => collider.height = height, - to, duration).SetTarget(collider); - + Tweening.To(collider, (source) => source.height, (source, value) => source.height = value, to, duration) + .SetTarget(collider); } } diff --git a/Runtime/Extensions/Physics/CharacterControllerTweens.cs b/Runtime/Extensions/Physics/CharacterControllerTweens.cs index 32fcc15..9070810 100644 --- a/Runtime/Extensions/Physics/CharacterControllerTweens.cs +++ b/Runtime/Extensions/Physics/CharacterControllerTweens.cs @@ -5,40 +5,32 @@ namespace Zigurous.Tweening public static class CharacterControllerTweens { public static Tween TweenCenter(this CharacterController character, Vector3 to, float duration) => - Tweening.To(getter: () => character.center, - setter: center => character.center = center, - to, duration).SetTarget(character); + Tweening.To(character, (source) => source.center, (source, value) => source.center = value, to, duration) + .SetTarget(character); public static Tween TweenRadius(this CharacterController character, float to, float duration) => - Tweening.To(getter: () => character.radius, - setter: radius => character.radius = radius, - to, duration).SetTarget(character); + Tweening.To(character, (source) => source.radius, (source, value) => source.radius = value, to, duration) + .SetTarget(character); public static Tween TweenHeight(this CharacterController character, float to, float duration) => - Tweening.To(getter: () => character.height, - setter: height => character.height = height, - to, duration).SetTarget(character); + Tweening.To(character, (source) => source.height, (source, value) => source.height = value, to, duration) + .SetTarget(character); public static Tween TweenSlopeLimit(this CharacterController character, float to, float duration) => - Tweening.To(getter: () => character.slopeLimit, - setter: slopeLimit => character.slopeLimit = slopeLimit, - to, duration).SetTarget(character); + Tweening.To(character, (source) => source.slopeLimit, (source, value) => source.slopeLimit = value, to, duration) + .SetTarget(character); public static Tween TweenStepOffset(this CharacterController character, float to, float duration) => - Tweening.To(getter: () => character.stepOffset, - setter: stepOffset => character.stepOffset = stepOffset, - to, duration).SetTarget(character); + Tweening.To(character, (source) => source.stepOffset, (source, value) => source.stepOffset = value, to, duration) + .SetTarget(character); public static Tween TweenSkinWidth(this CharacterController character, float to, float duration) => - Tweening.To(getter: () => character.skinWidth, - setter: skinWidth => character.skinWidth = skinWidth, - to, duration).SetTarget(character); + Tweening.To(character, (source) => source.skinWidth, (source, value) => source.skinWidth = value, to, duration) + .SetTarget(character); public static Tween TweenMinMoveDistance(this CharacterController character, float to, float duration) => - Tweening.To(getter: () => character.minMoveDistance, - setter: minMoveDistance => character.minMoveDistance = minMoveDistance, - to, duration).SetTarget(character); - + Tweening.To(character, (source) => source.minMoveDistance, (source, value) => source.minMoveDistance = value, to, duration) + .SetTarget(character); } } diff --git a/Runtime/Extensions/Physics/CharacterJointTweens.cs b/Runtime/Extensions/Physics/CharacterJointTweens.cs index 953abf1..4cc2e61 100644 --- a/Runtime/Extensions/Physics/CharacterJointTweens.cs +++ b/Runtime/Extensions/Physics/CharacterJointTweens.cs @@ -5,20 +5,16 @@ namespace Zigurous.Tweening public static class CharacterJointTweens { public static Tween TweenSwingAxis(this CharacterJoint joint, Vector3 to, float duration) => - Tweening.To(getter: () => joint.swingAxis, - setter: swingAxis => joint.swingAxis = swingAxis, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.swingAxis, (source, value) => source.swingAxis = value, to, duration) + .SetTarget(joint); public static Tween TweenProjectionDistance(this CharacterJoint joint, float to, float duration) => - Tweening.To(getter: () => joint.projectionDistance, - setter: projectionDistance => joint.projectionDistance = projectionDistance, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.projectionDistance, (source, value) => source.projectionDistance = value, to, duration) + .SetTarget(joint); public static Tween TweenProjectionAngle(this CharacterJoint joint, float to, float duration) => - Tweening.To(getter: () => joint.projectionAngle, - setter: projectionAngle => joint.projectionAngle = projectionAngle, - to, duration).SetTarget(joint); - + Tweening.To(joint, (source) => source.projectionAngle, (source, value) => source.projectionAngle = value, to, duration) + .SetTarget(joint); } } diff --git a/Runtime/Extensions/Physics/ClothTweens.cs b/Runtime/Extensions/Physics/ClothTweens.cs index 07d0f77..a0540b8 100644 --- a/Runtime/Extensions/Physics/ClothTweens.cs +++ b/Runtime/Extensions/Physics/ClothTweens.cs @@ -5,70 +5,56 @@ namespace Zigurous.Tweening public static class ClothTweens { public static Tween TweenDamping(this Cloth cloth, float to, float duration) => - Tweening.To(getter: () => cloth.damping, - setter: damping => cloth.damping = damping, - to, duration).SetTarget(cloth); + Tweening.To(cloth, (source) => source.damping, (source, value) => source.damping = value, to, duration) + .SetTarget(cloth); public static Tween TweenFriction(this Cloth cloth, float to, float duration) => - Tweening.To(getter: () => cloth.friction, - setter: friction => cloth.friction = friction, - to, duration).SetTarget(cloth); + Tweening.To(cloth, (source) => source.friction, (source, value) => source.friction = value, to, duration) + .SetTarget(cloth); public static Tween TweenCollisionMassScale(this Cloth cloth, float to, float duration) => - Tweening.To(getter: () => cloth.collisionMassScale, - setter: collisionMassScale => cloth.collisionMassScale = collisionMassScale, - to, duration).SetTarget(cloth); + Tweening.To(cloth, (source) => source.collisionMassScale, (source, value) => source.collisionMassScale = value, to, duration) + .SetTarget(cloth); public static Tween TweenWorldVelocityScale(this Cloth cloth, float to, float duration) => - Tweening.To(getter: () => cloth.worldVelocityScale, - setter: worldVelocityScale => cloth.worldVelocityScale = worldVelocityScale, - to, duration).SetTarget(cloth); + Tweening.To(cloth, (source) => source.worldVelocityScale, (source, value) => source.worldVelocityScale = value, to, duration) + .SetTarget(cloth); public static Tween TweenWorldAccelerationScale(this Cloth cloth, float to, float duration) => - Tweening.To(getter: () => cloth.worldAccelerationScale, - setter: worldAccelerationScale => cloth.worldAccelerationScale = worldAccelerationScale, - to, duration).SetTarget(cloth); + Tweening.To(cloth, (source) => source.worldAccelerationScale, (source, value) => source.worldAccelerationScale = value, to, duration) + .SetTarget(cloth); public static Tween TweenExternalAcceleration(this Cloth cloth, Vector3 to, float duration) => - Tweening.To(getter: () => cloth.externalAcceleration, - setter: externalAcceleration => cloth.externalAcceleration = externalAcceleration, - to, duration).SetTarget(cloth); + Tweening.To(cloth, (source) => source.externalAcceleration, (source, value) => source.externalAcceleration = value, to, duration) + .SetTarget(cloth); public static Tween TweenRandomAcceleration(this Cloth cloth, Vector3 to, float duration) => - Tweening.To(getter: () => cloth.randomAcceleration, - setter: randomAcceleration => cloth.randomAcceleration = randomAcceleration, - to, duration).SetTarget(cloth); + Tweening.To(cloth, (source) => source.randomAcceleration, (source, value) => source.randomAcceleration = value, to, duration) + .SetTarget(cloth); public static Tween TweenStiffnessFrequency(this Cloth cloth, float to, float duration) => - Tweening.To(getter: () => cloth.stiffnessFrequency, - setter: stiffnessFrequency => cloth.stiffnessFrequency = stiffnessFrequency, - to, duration).SetTarget(cloth); + Tweening.To(cloth, (source) => source.stiffnessFrequency, (source, value) => source.stiffnessFrequency = value, to, duration) + .SetTarget(cloth); public static Tween TweenSelfCollisionDistance(this Cloth cloth, float to, float duration) => - Tweening.To(getter: () => cloth.selfCollisionDistance, - setter: selfCollisionDistance => cloth.selfCollisionDistance = selfCollisionDistance, - to, duration).SetTarget(cloth); + Tweening.To(cloth, (source) => source.selfCollisionDistance, (source, value) => source.selfCollisionDistance = value, to, duration) + .SetTarget(cloth); public static Tween TweenSelfCollisionStiffness(this Cloth cloth, float to, float duration) => - Tweening.To(getter: () => cloth.selfCollisionStiffness, - setter: selfCollisionStiffness => cloth.selfCollisionStiffness = selfCollisionStiffness, - to, duration).SetTarget(cloth); + Tweening.To(cloth, (source) => source.selfCollisionStiffness, (source, value) => source.selfCollisionStiffness = value, to, duration) + .SetTarget(cloth); public static Tween TweenStretchingStiffness(this Cloth cloth, float to, float duration) => - Tweening.To(getter: () => cloth.stretchingStiffness, - setter: stretchingStiffness => cloth.stretchingStiffness = stretchingStiffness, - to, duration).SetTarget(cloth); + Tweening.To(cloth, (source) => source.stretchingStiffness, (source, value) => source.stretchingStiffness = value, to, duration) + .SetTarget(cloth); public static Tween TweenBendingStiffness(this Cloth cloth, float to, float duration) => - Tweening.To(getter: () => cloth.bendingStiffness, - setter: bendingStiffness => cloth.bendingStiffness = bendingStiffness, - to, duration).SetTarget(cloth); + Tweening.To(cloth, (source) => source.bendingStiffness, (source, value) => source.bendingStiffness = value, to, duration) + .SetTarget(cloth); public static Tween TweenSleepThreshold(this Cloth cloth, float to, float duration) => - Tweening.To(getter: () => cloth.sleepThreshold, - setter: sleepThreshold => cloth.sleepThreshold = sleepThreshold, - to, duration).SetTarget(cloth); - + Tweening.To(cloth, (source) => source.sleepThreshold, (source, value) => source.sleepThreshold = value, to, duration) + .SetTarget(cloth); } } diff --git a/Runtime/Extensions/Physics/ColliderTweens.cs b/Runtime/Extensions/Physics/ColliderTweens.cs index 8d7f992..4016634 100644 --- a/Runtime/Extensions/Physics/ColliderTweens.cs +++ b/Runtime/Extensions/Physics/ColliderTweens.cs @@ -5,10 +5,8 @@ namespace Zigurous.Tweening public static class ColliderTweens { public static Tween TweenContactOffset(this Collider collider, float to, float duration) => - Tweening.To(getter: () => collider.contactOffset, - setter: contactOffset => collider.contactOffset = contactOffset, - to, duration).SetTarget(collider); - + Tweening.To(collider, (source) => source.contactOffset, (source, value) => source.contactOffset = value, to, duration) + .SetTarget(collider); } } diff --git a/Runtime/Extensions/Physics/ConfigurableJointTweens.cs b/Runtime/Extensions/Physics/ConfigurableJointTweens.cs index 7946a8e..49dc075 100644 --- a/Runtime/Extensions/Physics/ConfigurableJointTweens.cs +++ b/Runtime/Extensions/Physics/ConfigurableJointTweens.cs @@ -5,40 +5,32 @@ namespace Zigurous.Tweening public static class ConfigurableJointTweens { public static Tween TweenProjectionAngle(this ConfigurableJoint joint, float to, float duration) => - Tweening.To(getter: () => joint.projectionAngle, - setter: projectionAngle => joint.projectionAngle = projectionAngle, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.projectionAngle, (source, value) => source.projectionAngle = value, to, duration) + .SetTarget(joint); public static Tween TweenProjectionDistance(this ConfigurableJoint joint, float to, float duration) => - Tweening.To(getter: () => joint.projectionDistance, - setter: projectionDistance => joint.projectionDistance = projectionDistance, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.projectionDistance, (source, value) => source.projectionDistance = value, to, duration) + .SetTarget(joint); public static Tween TweenTargetVelocity(this ConfigurableJoint joint, Vector3 to, float duration) => - Tweening.To(getter: () => joint.targetVelocity, - setter: targetVelocity => joint.targetVelocity = targetVelocity, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.targetVelocity, (source, value) => source.targetVelocity = value, to, duration) + .SetTarget(joint); public static Tween TweenTargetAngularVelocity(this ConfigurableJoint joint, Vector3 to, float duration) => - Tweening.To(getter: () => joint.targetAngularVelocity, - setter: targetAngularVelocity => joint.targetAngularVelocity = targetAngularVelocity, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.targetAngularVelocity, (source, value) => source.targetAngularVelocity = value, to, duration) + .SetTarget(joint); public static Tween TweenTargetPosition(this ConfigurableJoint joint, Vector3 to, float duration) => - Tweening.To(getter: () => joint.targetPosition, - setter: targetPosition => joint.targetPosition = targetPosition, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.targetPosition, (source, value) => source.targetPosition = value, to, duration) + .SetTarget(joint); public static Tween TweenTargetRotation(this ConfigurableJoint joint, Quaternion to, float duration) => - Tweening.To(getter: () => joint.targetRotation, - setter: targetRotation => joint.targetRotation = targetRotation, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.targetRotation, (source, value) => source.targetRotation = value, to, duration) + .SetTarget(joint); public static Tween TweenSecondaryAxis(this ConfigurableJoint joint, Vector3 to, float duration) => - Tweening.To(getter: () => joint.secondaryAxis, - setter: secondaryAxis => joint.secondaryAxis = secondaryAxis, - to, duration).SetTarget(joint); - + Tweening.To(joint, (source) => source.secondaryAxis, (source, value) => source.secondaryAxis = value, to, duration) + .SetTarget(joint); } } diff --git a/Runtime/Extensions/Physics/ConstantForceTweens.cs b/Runtime/Extensions/Physics/ConstantForceTweens.cs index 16a75ce..3217e9a 100644 --- a/Runtime/Extensions/Physics/ConstantForceTweens.cs +++ b/Runtime/Extensions/Physics/ConstantForceTweens.cs @@ -5,25 +5,20 @@ namespace Zigurous.Tweening public static class ConstantForceTweens { public static Tween TweenForce(this ConstantForce constantForce, Vector3 to, float duration) => - Tweening.To(getter: () => constantForce.force, - setter: force => constantForce.force = force, - to, duration).SetTarget(constantForce); + Tweening.To(constantForce, (source) => source.force, (source, value) => source.force = value, to, duration) + .SetTarget(constantForce); public static Tween TweenRelativeForce(this ConstantForce constantForce, Vector3 to, float duration) => - Tweening.To(getter: () => constantForce.relativeForce, - setter: relativeForce => constantForce.relativeForce = relativeForce, - to, duration).SetTarget(constantForce); + Tweening.To(constantForce, (source) => source.relativeForce, (source, value) => source.relativeForce = value, to, duration) + .SetTarget(constantForce); public static Tween TweenTorque(this ConstantForce constantForce, Vector3 to, float duration) => - Tweening.To(getter: () => constantForce.torque, - setter: torque => constantForce.torque = torque, - to, duration).SetTarget(constantForce); + Tweening.To(constantForce, (source) => source.torque, (source, value) => source.torque = value, to, duration) + .SetTarget(constantForce); public static Tween TweenRelativeTorque(this ConstantForce constantForce, Vector3 to, float duration) => - Tweening.To(getter: () => constantForce.relativeTorque, - setter: relativeTorque => constantForce.relativeTorque = relativeTorque, - to, duration).SetTarget(constantForce); - + Tweening.To(constantForce, (source) => source.relativeTorque, (source, value) => source.relativeTorque = value, to, duration) + .SetTarget(constantForce); } } diff --git a/Runtime/Extensions/Physics/JointTweens.cs b/Runtime/Extensions/Physics/JointTweens.cs index 234bc61..e0a830f 100644 --- a/Runtime/Extensions/Physics/JointTweens.cs +++ b/Runtime/Extensions/Physics/JointTweens.cs @@ -5,40 +5,32 @@ namespace Zigurous.Tweening public static class JointTweens { public static Tween TweenAxis(this Joint joint, Vector3 to, float duration) => - Tweening.To(getter: () => joint.axis, - setter: axis => joint.axis = axis, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.axis, (source, value) => source.axis = value, to, duration) + .SetTarget(joint); public static Tween TweenAnchor(this Joint joint, Vector3 to, float duration) => - Tweening.To(getter: () => joint.anchor, - setter: anchor => joint.anchor = anchor, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.anchor, (source, value) => source.anchor = value, to, duration) + .SetTarget(joint); public static Tween TweenConnectedAnchor(this Joint joint, Vector3 to, float duration) => - Tweening.To(getter: () => joint.connectedAnchor, - setter: connectedAnchor => joint.connectedAnchor = connectedAnchor, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.connectedAnchor, (source, value) => source.connectedAnchor = value, to, duration) + .SetTarget(joint); public static Tween TweenBreakForce(this Joint joint, float to, float duration) => - Tweening.To(getter: () => joint.breakForce, - setter: breakForce => joint.breakForce = breakForce, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.breakForce, (source, value) => source.breakForce = value, to, duration) + .SetTarget(joint); public static Tween TweenBreakTorque(this Joint joint, float to, float duration) => - Tweening.To(getter: () => joint.breakTorque, - setter: breakTorque => joint.breakTorque = breakTorque, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.breakTorque, (source, value) => source.breakTorque = value, to, duration) + .SetTarget(joint); public static Tween TweenMassScale(this Joint joint, float to, float duration) => - Tweening.To(getter: () => joint.massScale, - setter: massScale => joint.massScale = massScale, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.massScale, (source, value) => source.massScale = value, to, duration) + .SetTarget(joint); public static Tween TweenConnectedMassScale(this Joint joint, float to, float duration) => - Tweening.To(getter: () => joint.connectedMassScale, - setter: connectedMassScale => joint.connectedMassScale = connectedMassScale, - to, duration).SetTarget(joint); - + Tweening.To(joint, (source) => source.connectedMassScale, (source, value) => source.connectedMassScale = value, to, duration) + .SetTarget(joint); } } diff --git a/Runtime/Extensions/Physics/PhysicMaterialTweens.cs b/Runtime/Extensions/Physics/PhysicMaterialTweens.cs index f6c35f9..0914b9d 100644 --- a/Runtime/Extensions/Physics/PhysicMaterialTweens.cs +++ b/Runtime/Extensions/Physics/PhysicMaterialTweens.cs @@ -5,20 +5,16 @@ namespace Zigurous.Tweening public static class PhysicMaterialTweens { public static Tween TweenBounciness(this PhysicMaterial material, float to, float duration) => - Tweening.To(getter: () => material.bounciness, - setter: bounciness => material.bounciness = bounciness, - to, duration).SetId(material.GetHashCode()); + Tweening.To(material, (source) => source.bounciness, (source, value) => source.bounciness = value, to, duration) + .SetId(material.GetHashCode()); public static Tween TweenDynamicFriction(this PhysicMaterial material, float to, float duration) => - Tweening.To(getter: () => material.dynamicFriction, - setter: friction => material.dynamicFriction = friction, - to, duration).SetId(material.GetHashCode()); + Tweening.To(material, (source) => source.dynamicFriction, (source, value) => source.dynamicFriction = value, to, duration) + .SetId(material.GetHashCode()); public static Tween TweenStaticFriction(this PhysicMaterial material, float to, float duration) => - Tweening.To(getter: () => material.staticFriction, - setter: friction => material.staticFriction = friction, - to, duration).SetId(material.GetHashCode()); - + Tweening.To(material, (source) => source.staticFriction, (source, value) => source.staticFriction = value, to, duration) + .SetId(material.GetHashCode()); } } diff --git a/Runtime/Extensions/Physics/RigidbodyTweens.cs b/Runtime/Extensions/Physics/RigidbodyTweens.cs index 4f50321..9ad4af5 100644 --- a/Runtime/Extensions/Physics/RigidbodyTweens.cs +++ b/Runtime/Extensions/Physics/RigidbodyTweens.cs @@ -5,70 +5,56 @@ namespace Zigurous.Tweening public static class RigidbodyTweens { public static Tween TweenPosition(this Rigidbody rigidbody, Vector3 to, float duration) => - Tweening.To(getter: () => rigidbody.position, - setter: position => rigidbody.position = position, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.position, (source, value) => source.position = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenRotation(this Rigidbody rigidbody, Quaternion to, float duration) => - Tweening.To(getter: () => rigidbody.rotation, - setter: rotation => rigidbody.rotation = rotation, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.rotation, (source, value) => source.rotation = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenVelocity(this Rigidbody rigidbody, Vector3 to, float duration) => - Tweening.To(getter: () => rigidbody.velocity, - setter: velocity => rigidbody.velocity = velocity, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.velocity, (source, value) => source.velocity = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenAngularVelocity(this Rigidbody rigidbody, Vector3 to, float duration) => - Tweening.To(getter: () => rigidbody.angularVelocity, - setter: angularVelocity => rigidbody.angularVelocity = angularVelocity, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.angularVelocity, (source, value) => source.angularVelocity = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenMaxAngularVelocity(this Rigidbody rigidbody, float to, float duration) => - Tweening.To(getter: () => rigidbody.maxAngularVelocity, - setter: maxAngularVelocity => rigidbody.maxAngularVelocity = maxAngularVelocity, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.maxAngularVelocity, (source, value) => source.maxAngularVelocity = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenMaxDepenetrationVelocity(this Rigidbody rigidbody, float to, float duration) => - Tweening.To(getter: () => rigidbody.maxDepenetrationVelocity, - setter: maxDepenetrationVelocity => rigidbody.maxDepenetrationVelocity = maxDepenetrationVelocity, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.maxDepenetrationVelocity, (source, value) => source.maxDepenetrationVelocity = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenMass(this Rigidbody rigidbody, float to, float duration) => - Tweening.To(getter: () => rigidbody.mass, - setter: mass => rigidbody.mass = mass, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.mass, (source, value) => source.mass = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenCenterOfMass(this Rigidbody rigidbody, Vector3 to, float duration) => - Tweening.To(getter: () => rigidbody.centerOfMass, - setter: centerOfMass => rigidbody.centerOfMass = centerOfMass, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.centerOfMass, (source, value) => source.centerOfMass = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenDrag(this Rigidbody rigidbody, float to, float duration) => - Tweening.To(getter: () => rigidbody.drag, - setter: drag => rigidbody.drag = drag, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.drag, (source, value) => source.drag = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenAngularDrag(this Rigidbody rigidbody, float to, float duration) => - Tweening.To(getter: () => rigidbody.angularDrag, - setter: angularDrag => rigidbody.angularDrag = angularDrag, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.angularDrag, (source, value) => source.angularDrag = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenInertiaTensor(this Rigidbody rigidbody, Vector3 to, float duration) => - Tweening.To(getter: () => rigidbody.inertiaTensor, - setter: inertiaTensor => rigidbody.inertiaTensor = inertiaTensor, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.inertiaTensor, (source, value) => source.inertiaTensor = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenInertiaTensorRotation(this Rigidbody rigidbody, Quaternion to, float duration) => - Tweening.To(getter: () => rigidbody.inertiaTensorRotation, - setter: inertiaTensorRotation => rigidbody.inertiaTensorRotation = inertiaTensorRotation, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.inertiaTensorRotation, (source, value) => source.inertiaTensorRotation = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenSleepThreshold(this Rigidbody rigidbody, float to, float duration) => - Tweening.To(getter: () => rigidbody.sleepThreshold, - setter: sleepThreshold => rigidbody.sleepThreshold = sleepThreshold, - to, duration).SetTarget(rigidbody); - + Tweening.To(rigidbody, (source) => source.sleepThreshold, (source, value) => source.sleepThreshold = value, to, duration) + .SetTarget(rigidbody); } } diff --git a/Runtime/Extensions/Physics/SphereColliderTweens.cs b/Runtime/Extensions/Physics/SphereColliderTweens.cs index 892b6d9..3f33598 100644 --- a/Runtime/Extensions/Physics/SphereColliderTweens.cs +++ b/Runtime/Extensions/Physics/SphereColliderTweens.cs @@ -5,15 +5,12 @@ namespace Zigurous.Tweening public static class SphereColliderTweens { public static Tween TweenCenter(this SphereCollider collider, Vector3 to, float duration) => - Tweening.To(getter: () => collider.center, - setter: center => collider.center = center, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.center, (source, value) => source.center = value, to, duration) + .SetTarget(collider); public static Tween TweenRadius(this SphereCollider collider, float to, float duration) => - Tweening.To(getter: () => collider.radius, - setter: radius => collider.radius = radius, - to, duration).SetTarget(collider); - + Tweening.To(collider, (source) => source.radius, (source, value) => source.radius = value, to, duration) + .SetTarget(collider); } } diff --git a/Runtime/Extensions/Physics/SpringJointTweens.cs b/Runtime/Extensions/Physics/SpringJointTweens.cs index da2b2aa..05e33c0 100644 --- a/Runtime/Extensions/Physics/SpringJointTweens.cs +++ b/Runtime/Extensions/Physics/SpringJointTweens.cs @@ -5,30 +5,24 @@ namespace Zigurous.Tweening public static class SpringJointTweens { public static Tween TweenSpring(this SpringJoint joint, float to, float duration) => - Tweening.To(getter: () => joint.spring, - setter: spring => joint.spring = spring, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.spring, (source, value) => source.spring = value, to, duration) + .SetTarget(joint); public static Tween TweenDamper(this SpringJoint joint, float to, float duration) => - Tweening.To(getter: () => joint.damper, - setter: damper => joint.damper = damper, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.damper, (source, value) => source.damper = value, to, duration) + .SetTarget(joint); public static Tween TweenMinDistance(this SpringJoint joint, float to, float duration) => - Tweening.To(getter: () => joint.minDistance, - setter: minDistance => joint.minDistance = minDistance, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.minDistance, (source, value) => source.minDistance = value, to, duration) + .SetTarget(joint); public static Tween TweenMaxDistance(this SpringJoint joint, float to, float duration) => - Tweening.To(getter: () => joint.maxDistance, - setter: maxDistance => joint.maxDistance = maxDistance, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.maxDistance, (source, value) => source.maxDistance = value, to, duration) + .SetTarget(joint); public static Tween TweenTolerance(this SpringJoint joint, float to, float duration) => - Tweening.To(getter: () => joint.tolerance, - setter: tolerance => joint.tolerance = tolerance, - to, duration).SetTarget(joint); - + Tweening.To(joint, (source) => source.tolerance, (source, value) => source.tolerance = value, to, duration) + .SetTarget(joint); } } diff --git a/Runtime/Extensions/Physics/WheelColliderTweens.cs b/Runtime/Extensions/Physics/WheelColliderTweens.cs index f1bbc36..8ab9902 100644 --- a/Runtime/Extensions/Physics/WheelColliderTweens.cs +++ b/Runtime/Extensions/Physics/WheelColliderTweens.cs @@ -5,55 +5,44 @@ namespace Zigurous.Tweening public static class WheelColliderTweens { public static Tween TweenForceAppPointDistance(this WheelCollider collider, float to, float duration) => - Tweening.To(getter: () => collider.forceAppPointDistance, - setter: forceAppPointDistance => collider.forceAppPointDistance = forceAppPointDistance, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.forceAppPointDistance, (source, value) => source.forceAppPointDistance = value, to, duration) + .SetTarget(collider); public static Tween TweenSteerAngle(this WheelCollider collider, float to, float duration) => - Tweening.To(getter: () => collider.steerAngle, - setter: steerAngle => collider.steerAngle = steerAngle, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.steerAngle, (source, value) => source.steerAngle = value, to, duration) + .SetTarget(collider); public static Tween TweenBreakTorque(this WheelCollider collider, float to, float duration) => - Tweening.To(getter: () => collider.brakeTorque, - setter: brakeTorque => collider.brakeTorque = brakeTorque, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.brakeTorque, (source, value) => source.brakeTorque = value, to, duration) + .SetTarget(collider); public static Tween TweenMotorTorque(this WheelCollider collider, float to, float duration) => - Tweening.To(getter: () => collider.motorTorque, - setter: motorTorque => collider.motorTorque = motorTorque, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.motorTorque, (source, value) => source.motorTorque = value, to, duration) + .SetTarget(collider); public static Tween TweenWheelDampingRate(this WheelCollider collider, float to, float duration) => - Tweening.To(getter: () => collider.wheelDampingRate, - setter: wheelDampingRate => collider.wheelDampingRate = wheelDampingRate, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.wheelDampingRate, (source, value) => source.wheelDampingRate = value, to, duration) + .SetTarget(collider); public static Tween TweenMass(this WheelCollider collider, float to, float duration) => - Tweening.To(getter: () => collider.mass, - setter: mass => collider.mass = mass, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.mass, (source, value) => source.mass = value, to, duration) + .SetTarget(collider); public static Tween TweenSprungMass(this WheelCollider collider, float to, float duration) => - Tweening.To(getter: () => collider.sprungMass, - setter: sprungMass => collider.sprungMass = sprungMass, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.sprungMass, (source, value) => source.sprungMass = value, to, duration) + .SetTarget(collider); public static Tween TweenSuspensionDistance(this WheelCollider collider, float to, float duration) => - Tweening.To(getter: () => collider.suspensionDistance, - setter: suspensionDistance => collider.suspensionDistance = suspensionDistance, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.suspensionDistance, (source, value) => source.suspensionDistance = value, to, duration) + .SetTarget(collider); public static Tween TweenRadius(this WheelCollider collider, float to, float duration) => - Tweening.To(getter: () => collider.radius, - setter: radius => collider.radius = radius, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.radius, (source, value) => source.radius = value, to, duration) + .SetTarget(collider); public static Tween TweenCenter(this WheelCollider collider, Vector3 to, float duration) => - Tweening.To(getter: () => collider.center, - setter: center => collider.center = center, - to, duration).SetTarget(collider); - + Tweening.To(collider, (source) => source.center, (source, value) => source.center = value, to, duration) + .SetTarget(collider); } } diff --git a/Runtime/Extensions/Physics2D/AnchoredJoint2DTweens.cs b/Runtime/Extensions/Physics2D/AnchoredJoint2DTweens.cs index 17ce1ef..895fba5 100644 --- a/Runtime/Extensions/Physics2D/AnchoredJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/AnchoredJoint2DTweens.cs @@ -5,15 +5,12 @@ namespace Zigurous.Tweening public static class AnchoredJoint2DTweens { public static Tween TweenAnchor(this AnchoredJoint2D joint, Vector2 to, float duration) => - Tweening.To(getter: () => joint.anchor, - setter: anchor => joint.anchor = anchor, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.anchor, (source, value) => source.anchor = value, to, duration) + .SetTarget(joint); public static Tween TweenConnectedAnchor(this AnchoredJoint2D joint, Vector2 to, float duration) => - Tweening.To(getter: () => joint.connectedAnchor, - setter: connectedAnchor => joint.connectedAnchor = connectedAnchor, - to, duration).SetTarget(joint); - + Tweening.To(joint, (source) => source.connectedAnchor, (source, value) => source.connectedAnchor = value, to, duration) + .SetTarget(joint); } } diff --git a/Runtime/Extensions/Physics2D/AreaEffector2DTweens.cs b/Runtime/Extensions/Physics2D/AreaEffector2DTweens.cs index a31534b..68d3f2c 100644 --- a/Runtime/Extensions/Physics2D/AreaEffector2DTweens.cs +++ b/Runtime/Extensions/Physics2D/AreaEffector2DTweens.cs @@ -5,30 +5,24 @@ namespace Zigurous.Tweening public static class AreaEffector2DTweens { public static Tween TweenForceAngle(this AreaEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.forceAngle, - setter: forceAngle => effector.forceAngle = forceAngle, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.forceAngle, (source, value) => source.forceAngle = value, to, duration) + .SetTarget(effector); public static Tween TweenForceMagnitude(this AreaEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.forceMagnitude, - setter: forceMagnitude => effector.forceMagnitude = forceMagnitude, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.forceMagnitude, (source, value) => source.forceMagnitude = value, to, duration) + .SetTarget(effector); public static Tween TweenForceVariation(this AreaEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.forceVariation, - setter: forceVariation => effector.forceVariation = forceVariation, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.forceVariation, (source, value) => source.forceVariation = value, to, duration) + .SetTarget(effector); public static Tween TweenDrag(this AreaEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.drag, - setter: drag => effector.drag = drag, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.drag, (source, value) => source.drag = value, to, duration) + .SetTarget(effector); public static Tween TweenAngularDrag(this AreaEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.angularDrag, - setter: angularDrag => effector.angularDrag = angularDrag, - to, duration).SetTarget(effector); - + Tweening.To(effector, (source) => source.angularDrag, (source, value) => source.angularDrag = value, to, duration) + .SetTarget(effector); } } diff --git a/Runtime/Extensions/Physics2D/BoxCollider2DTweens.cs b/Runtime/Extensions/Physics2D/BoxCollider2DTweens.cs index 4eeffdf..8cdadad 100644 --- a/Runtime/Extensions/Physics2D/BoxCollider2DTweens.cs +++ b/Runtime/Extensions/Physics2D/BoxCollider2DTweens.cs @@ -5,15 +5,12 @@ namespace Zigurous.Tweening public static class BoxCollider2DTweens { public static Tween TweenSize(this BoxCollider2D collider, Vector2 to, float duration) => - Tweening.To(getter: () => collider.size, - setter: size => collider.size = size, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.size, (source, value) => source.size = value, to, duration) + .SetTarget(collider); public static Tween TweenEdgeRadius(this BoxCollider2D collider, float to, float duration) => - Tweening.To(getter: () => collider.edgeRadius, - setter: edgeRadius => collider.edgeRadius = edgeRadius, - to, duration).SetTarget(collider); - + Tweening.To(collider, (source) => source.edgeRadius, (source, value) => source.edgeRadius = value, to, duration) + .SetTarget(collider); } } diff --git a/Runtime/Extensions/Physics2D/BuoyancyEffector2DTweens.cs b/Runtime/Extensions/Physics2D/BuoyancyEffector2DTweens.cs index f76cc90..a66a7d5 100644 --- a/Runtime/Extensions/Physics2D/BuoyancyEffector2DTweens.cs +++ b/Runtime/Extensions/Physics2D/BuoyancyEffector2DTweens.cs @@ -5,40 +5,32 @@ namespace Zigurous.Tweening public static class BuoyancyEffector2DTweens { public static Tween TweenSurfaceLevel(this BuoyancyEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.surfaceLevel, - setter: surfaceLevel => effector.surfaceLevel = surfaceLevel, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.surfaceLevel, (source, value) => source.surfaceLevel = value, to, duration) + .SetTarget(effector); public static Tween TweenDensity(this BuoyancyEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.density, - setter: density => effector.density = density, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.density, (source, value) => source.density = value, to, duration) + .SetTarget(effector); public static Tween TweenLinearDrag(this BuoyancyEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.linearDrag, - setter: linearDrag => effector.linearDrag = linearDrag, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.linearDrag, (source, value) => source.linearDrag = value, to, duration) + .SetTarget(effector); public static Tween TweenAngularDrag(this BuoyancyEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.angularDrag, - setter: angularDrag => effector.angularDrag = angularDrag, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.angularDrag, (source, value) => source.angularDrag = value, to, duration) + .SetTarget(effector); public static Tween TweenFlowAngle(this BuoyancyEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.flowAngle, - setter: flowAngle => effector.flowAngle = flowAngle, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.flowAngle, (source, value) => source.flowAngle = value, to, duration) + .SetTarget(effector); public static Tween TweenFlowMagnitude(this BuoyancyEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.flowMagnitude, - setter: flowMagnitude => effector.flowMagnitude = flowMagnitude, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.flowMagnitude, (source, value) => source.flowMagnitude = value, to, duration) + .SetTarget(effector); public static Tween TweenFlowVariation(this BuoyancyEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.flowVariation, - setter: flowVariation => effector.flowVariation = flowVariation, - to, duration).SetTarget(effector); - + Tweening.To(effector, (source) => source.flowVariation, (source, value) => source.flowVariation = value, to, duration) + .SetTarget(effector); } } diff --git a/Runtime/Extensions/Physics2D/CapsuleCollider2DTweens.cs b/Runtime/Extensions/Physics2D/CapsuleCollider2DTweens.cs index 4e18f3a..ca5838c 100644 --- a/Runtime/Extensions/Physics2D/CapsuleCollider2DTweens.cs +++ b/Runtime/Extensions/Physics2D/CapsuleCollider2DTweens.cs @@ -5,10 +5,8 @@ namespace Zigurous.Tweening public static class CapsuleCollider2DTweens { public static Tween TweenSize(this CapsuleCollider2D collider, Vector2 to, float duration) => - Tweening.To(getter: () => collider.size, - setter: size => collider.size = size, - to, duration).SetTarget(collider); - + Tweening.To(collider, (source) => source.size, (source, value) => source.size = value, to, duration) + .SetTarget(collider); } } diff --git a/Runtime/Extensions/Physics2D/CircleCollider2DTweens.cs b/Runtime/Extensions/Physics2D/CircleCollider2DTweens.cs index 517c10c..f8fac5e 100644 --- a/Runtime/Extensions/Physics2D/CircleCollider2DTweens.cs +++ b/Runtime/Extensions/Physics2D/CircleCollider2DTweens.cs @@ -5,10 +5,8 @@ namespace Zigurous.Tweening public static class CircleCollider2DTweens { public static Tween TweenRadius(this CircleCollider2D collider, float to, float duration) => - Tweening.To(getter: () => collider.radius, - setter: radius => collider.radius = radius, - to, duration).SetTarget(collider); - + Tweening.To(collider, (source) => source.radius, (source, value) => source.radius = value, to, duration) + .SetTarget(collider); } } diff --git a/Runtime/Extensions/Physics2D/Collider2DTweens.cs b/Runtime/Extensions/Physics2D/Collider2DTweens.cs index 3a60d2f..c1104b7 100644 --- a/Runtime/Extensions/Physics2D/Collider2DTweens.cs +++ b/Runtime/Extensions/Physics2D/Collider2DTweens.cs @@ -5,15 +5,12 @@ namespace Zigurous.Tweening public static class Collider2DTweens { public static Tween TweenDensity(this Collider2D collider, float to, float duration) => - Tweening.To(getter: () => collider.density, - setter: density => collider.density = density, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.density, (source, value) => source.density = value, to, duration) + .SetTarget(collider); public static Tween TweenOffset(this Collider2D collider, Vector2 to, float duration) => - Tweening.To(getter: () => collider.offset, - setter: offset => collider.offset = offset, - to, duration).SetTarget(collider); - + Tweening.To(collider, (source) => source.offset, (source, value) => source.offset = value, to, duration) + .SetTarget(collider); } } diff --git a/Runtime/Extensions/Physics2D/CompositeCollider2DTweens.cs b/Runtime/Extensions/Physics2D/CompositeCollider2DTweens.cs index 23bc50c..4c2f8cc 100644 --- a/Runtime/Extensions/Physics2D/CompositeCollider2DTweens.cs +++ b/Runtime/Extensions/Physics2D/CompositeCollider2DTweens.cs @@ -5,20 +5,16 @@ namespace Zigurous.Tweening public static class CompositeCollider2DTweens { public static Tween TweenVertexDistance(this CompositeCollider2D collider, float to, float duration) => - Tweening.To(getter: () => collider.vertexDistance, - setter: vertexDistance => collider.vertexDistance = vertexDistance, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.vertexDistance, (source, value) => source.vertexDistance = value, to, duration) + .SetTarget(collider); public static Tween TweenEdgeRadius(this CompositeCollider2D collider, float to, float duration) => - Tweening.To(getter: () => collider.edgeRadius, - setter: edgeRadius => collider.edgeRadius = edgeRadius, - to, duration).SetTarget(collider); + Tweening.To(collider, (source) => source.edgeRadius, (source, value) => source.edgeRadius = value, to, duration) + .SetTarget(collider); public static Tween TweenOffsetDistance(this CompositeCollider2D collider, float to, float duration) => - Tweening.To(getter: () => collider.offsetDistance, - setter: offsetDistance => collider.offsetDistance = offsetDistance, - to, duration).SetTarget(collider); - + Tweening.To(collider, (source) => source.offsetDistance, (source, value) => source.offsetDistance = value, to, duration) + .SetTarget(collider); } } diff --git a/Runtime/Extensions/Physics2D/ConstantForce2DTweens.cs b/Runtime/Extensions/Physics2D/ConstantForce2DTweens.cs index 6f0218b..f1914d5 100644 --- a/Runtime/Extensions/Physics2D/ConstantForce2DTweens.cs +++ b/Runtime/Extensions/Physics2D/ConstantForce2DTweens.cs @@ -5,20 +5,16 @@ namespace Zigurous.Tweening public static class ConstantForce2DTweens { public static Tween TweenForce(this ConstantForce2D constantForce, Vector2 to, float duration) => - Tweening.To(getter: () => constantForce.force, - setter: force => constantForce.force = force, - to, duration).SetTarget(constantForce); + Tweening.To(constantForce, (source) => source.force, (source, value) => source.force = value, to, duration) + .SetTarget(constantForce); public static Tween TweenRelativeForce(this ConstantForce2D constantForce, Vector2 to, float duration) => - Tweening.To(getter: () => constantForce.relativeForce, - setter: relativeForce => constantForce.relativeForce = relativeForce, - to, duration).SetTarget(constantForce); + Tweening.To(constantForce, (source) => source.relativeForce, (source, value) => source.relativeForce = value, to, duration) + .SetTarget(constantForce); public static Tween TweenTorque(this ConstantForce2D constantForce, float to, float duration) => - Tweening.To(getter: () => constantForce.torque, - setter: torque => constantForce.torque = torque, - to, duration).SetTarget(constantForce); - + Tweening.To(constantForce, (source) => source.torque, (source, value) => source.torque = value, to, duration) + .SetTarget(constantForce); } } diff --git a/Runtime/Extensions/Physics2D/DistanceJoint2DTweens.cs b/Runtime/Extensions/Physics2D/DistanceJoint2DTweens.cs index 617b7c0..4027e69 100644 --- a/Runtime/Extensions/Physics2D/DistanceJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/DistanceJoint2DTweens.cs @@ -5,10 +5,8 @@ namespace Zigurous.Tweening public static class DistanceJoint2DTweens { public static Tween TweenDistance(this DistanceJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.distance, - setter: distance => joint.distance = distance, - to, duration).SetTarget(joint); - + Tweening.To(joint, (source) => source.distance, (source, value) => source.distance = value, to, duration) + .SetTarget(joint); } } diff --git a/Runtime/Extensions/Physics2D/EdgeCollider2DTweens.cs b/Runtime/Extensions/Physics2D/EdgeCollider2DTweens.cs index 1ae0134..2feada7 100644 --- a/Runtime/Extensions/Physics2D/EdgeCollider2DTweens.cs +++ b/Runtime/Extensions/Physics2D/EdgeCollider2DTweens.cs @@ -5,10 +5,8 @@ namespace Zigurous.Tweening public static class EdgeCollider2DTweens { public static Tween TweenEdgeRadius(this EdgeCollider2D collider, float to, float duration) => - Tweening.To(getter: () => collider.edgeRadius, - setter: edgeRadius => collider.edgeRadius = edgeRadius, - to, duration).SetTarget(collider); - + Tweening.To(collider, (source) => source.edgeRadius, (source, value) => source.edgeRadius = value, to, duration) + .SetTarget(collider); } } diff --git a/Runtime/Extensions/Physics2D/FixedJoint2DTweens.cs b/Runtime/Extensions/Physics2D/FixedJoint2DTweens.cs index a6af2f7..fe531da 100644 --- a/Runtime/Extensions/Physics2D/FixedJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/FixedJoint2DTweens.cs @@ -5,15 +5,12 @@ namespace Zigurous.Tweening public static class FixedJoint2DTweens { public static Tween TweenDampingRatio(this FixedJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.dampingRatio, - setter: dampingRatio => joint.dampingRatio = dampingRatio, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.dampingRatio, (source, value) => source.dampingRatio = value, to, duration) + .SetTarget(joint); public static Tween TweenFrequency(this FixedJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.frequency, - setter: frequency => joint.frequency = frequency, - to, duration).SetTarget(joint); - + Tweening.To(joint, (source) => source.frequency, (source, value) => source.frequency = value, to, duration) + .SetTarget(joint); } } diff --git a/Runtime/Extensions/Physics2D/FrictionJoint2DTweens.cs b/Runtime/Extensions/Physics2D/FrictionJoint2DTweens.cs index ff0cfe4..e99f234 100644 --- a/Runtime/Extensions/Physics2D/FrictionJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/FrictionJoint2DTweens.cs @@ -5,15 +5,12 @@ namespace Zigurous.Tweening public static class FrictionJoint2DTweens { public static Tween TweenMaxForce(this FrictionJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.maxForce, - setter: maxForce => joint.maxForce = maxForce, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.maxForce, (source, value) => source.maxForce = value, to, duration) + .SetTarget(joint); public static Tween TweenMaxTorque(this FrictionJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.maxTorque, - setter: maxTorque => joint.maxTorque = maxTorque, - to, duration).SetTarget(joint); - + Tweening.To(joint, (source) => source.maxTorque, (source, value) => source.maxTorque = value, to, duration) + .SetTarget(joint); } } diff --git a/Runtime/Extensions/Physics2D/Joint2DTweens.cs b/Runtime/Extensions/Physics2D/Joint2DTweens.cs index a5b9bde..dde26c9 100644 --- a/Runtime/Extensions/Physics2D/Joint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/Joint2DTweens.cs @@ -5,15 +5,12 @@ namespace Zigurous.Tweening public static class Joint2DTweens { public static Tween TweenBreakForce(this Joint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.breakForce, - setter: breakForce => joint.breakForce = breakForce, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.breakForce, (source, value) => source.breakForce = value, to, duration) + .SetTarget(joint); public static Tween TweenBreakTorque(this Joint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.breakTorque, - setter: breakTorque => joint.breakTorque = breakTorque, - to, duration).SetTarget(joint); - + Tweening.To(joint, (source) => source.breakTorque, (source, value) => source.breakTorque = value, to, duration) + .SetTarget(joint); } } diff --git a/Runtime/Extensions/Physics2D/PhysicsMaterial2DTweens.cs b/Runtime/Extensions/Physics2D/PhysicsMaterial2DTweens.cs index 67eb9c2..4750ebb 100644 --- a/Runtime/Extensions/Physics2D/PhysicsMaterial2DTweens.cs +++ b/Runtime/Extensions/Physics2D/PhysicsMaterial2DTweens.cs @@ -5,15 +5,12 @@ namespace Zigurous.Tweening public static class PhysicsMaterial2DTweens { public static Tween TweenBounciness(this PhysicsMaterial2D material, float to, float duration) => - Tweening.To(getter: () => material.bounciness, - setter: bounciness => material.bounciness = bounciness, - to, duration).SetId(material.GetHashCode()); + Tweening.To(material, (source) => source.bounciness, (source, value) => source.bounciness = value, to, duration) + .SetId(material.GetHashCode()); public static Tween TweenFriction(this PhysicsMaterial2D material, float to, float duration) => - Tweening.To(getter: () => material.friction, - setter: friction => material.friction = friction, - to, duration).SetId(material.GetHashCode()); - + Tweening.To(material, (source) => source.friction, (source, value) => source.friction = value, to, duration) + .SetId(material.GetHashCode()); } } diff --git a/Runtime/Extensions/Physics2D/PlatformEffector2DTweens.cs b/Runtime/Extensions/Physics2D/PlatformEffector2DTweens.cs index 2072133..ce33d80 100644 --- a/Runtime/Extensions/Physics2D/PlatformEffector2DTweens.cs +++ b/Runtime/Extensions/Physics2D/PlatformEffector2DTweens.cs @@ -5,20 +5,16 @@ namespace Zigurous.Tweening public static class PlatformEffector2DTweens { public static Tween TweenSurfaceArc(this PlatformEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.surfaceArc, - setter: surfaceArc => effector.surfaceArc = surfaceArc, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.surfaceArc, (source, value) => source.surfaceArc = value, to, duration) + .SetTarget(effector); public static Tween TweenSideArc(this PlatformEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.sideArc, - setter: sideArc => effector.sideArc = sideArc, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.sideArc, (source, value) => source.sideArc = value, to, duration) + .SetTarget(effector); public static Tween TweenRotationalOffset(this PlatformEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.rotationalOffset, - setter: rotationalOffset => effector.rotationalOffset = rotationalOffset, - to, duration).SetTarget(effector); - + Tweening.To(effector, (source) => source.rotationalOffset, (source, value) => source.rotationalOffset = value, to, duration) + .SetTarget(effector); } } diff --git a/Runtime/Extensions/Physics2D/PointEffector2DTweens.cs b/Runtime/Extensions/Physics2D/PointEffector2DTweens.cs index 6a8a9aa..f182891 100644 --- a/Runtime/Extensions/Physics2D/PointEffector2DTweens.cs +++ b/Runtime/Extensions/Physics2D/PointEffector2DTweens.cs @@ -5,30 +5,24 @@ namespace Zigurous.Tweening public static class PointEffector2DTweens { public static Tween TweenDrag(this PointEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.drag, - setter: drag => effector.drag = drag, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.drag, (source, value) => source.drag = value, to, duration) + .SetTarget(effector); public static Tween TweenAngularDrag(this PointEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.angularDrag, - setter: angularDrag => effector.angularDrag = angularDrag, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.angularDrag, (source, value) => source.angularDrag = value, to, duration) + .SetTarget(effector); public static Tween TweenForceMagnitude(this PointEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.forceMagnitude, - setter: forceMagnitude => effector.forceMagnitude = forceMagnitude, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.forceMagnitude, (source, value) => source.forceMagnitude = value, to, duration) + .SetTarget(effector); public static Tween TweenForceVariation(this PointEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.forceVariation, - setter: forceVariation => effector.forceVariation = forceVariation, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.forceVariation, (source, value) => source.forceVariation = value, to, duration) + .SetTarget(effector); public static Tween TweenDistanceScale(this PointEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.distanceScale, - setter: distanceScale => effector.distanceScale = distanceScale, - to, duration).SetTarget(effector); - + Tweening.To(effector, (source) => source.distanceScale, (source, value) => source.distanceScale = value, to, duration) + .SetTarget(effector); } } diff --git a/Runtime/Extensions/Physics2D/RelativeJoint2DTweens.cs b/Runtime/Extensions/Physics2D/RelativeJoint2DTweens.cs index b17f37c..72915fd 100644 --- a/Runtime/Extensions/Physics2D/RelativeJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/RelativeJoint2DTweens.cs @@ -5,30 +5,24 @@ namespace Zigurous.Tweening public static class RelativeJoint2DTweens { public static Tween TweenMaxForce(this RelativeJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.maxForce, - setter: maxForce => joint.maxForce = maxForce, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.maxForce, (source, value) => source.maxForce = value, to, duration) + .SetTarget(joint); public static Tween TweenMaxTorque(this RelativeJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.maxTorque, - setter: maxTorque => joint.maxTorque = maxTorque, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.maxTorque, (source, value) => source.maxTorque = value, to, duration) + .SetTarget(joint); public static Tween TweenCorrectionScale(this RelativeJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.correctionScale, - setter: correctionScale => joint.correctionScale = correctionScale, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.correctionScale, (source, value) => source.correctionScale = value, to, duration) + .SetTarget(joint); public static Tween TweenLinearOffset(this RelativeJoint2D joint, Vector2 to, float duration) => - Tweening.To(getter: () => joint.linearOffset, - setter: linearOffset => joint.linearOffset = linearOffset, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.linearOffset, (source, value) => source.linearOffset = value, to, duration) + .SetTarget(joint); public static Tween TweenAngularOffset(this RelativeJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.angularOffset, - setter: angularOffset => joint.angularOffset = angularOffset, - to, duration).SetTarget(joint); - + Tweening.To(joint, (source) => source.angularOffset, (source, value) => source.angularOffset = value, to, duration) + .SetTarget(joint); } } diff --git a/Runtime/Extensions/Physics2D/Rigidbody2DTweens.cs b/Runtime/Extensions/Physics2D/Rigidbody2DTweens.cs index 8c46cd5..542c88c 100644 --- a/Runtime/Extensions/Physics2D/Rigidbody2DTweens.cs +++ b/Runtime/Extensions/Physics2D/Rigidbody2DTweens.cs @@ -5,55 +5,44 @@ namespace Zigurous.Tweening public static class Rigidbody2DTweens { public static Tween TweenPosition(this Rigidbody2D rigidbody, Vector2 to, float duration) => - Tweening.To(getter: () => rigidbody.position, - setter: position => rigidbody.position = position, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.position, (source, value) => source.position = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenRotation(this Rigidbody2D rigidbody, float to, float duration) => - Tweening.To(getter: () => rigidbody.rotation, - setter: rotation => rigidbody.rotation = rotation, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.rotation, (source, value) => source.rotation = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenVelocity(this Rigidbody2D rigidbody, Vector2 to, float duration) => - Tweening.To(getter: () => rigidbody.velocity, - setter: velocity => rigidbody.velocity = velocity, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.velocity, (source, value) => source.velocity = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenAngularVelocity(this Rigidbody2D rigidbody, float to, float duration) => - Tweening.To(getter: () => rigidbody.angularVelocity, - setter: angularVelocity => rigidbody.angularVelocity = angularVelocity, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.angularVelocity, (source, value) => source.angularVelocity = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenMass(this Rigidbody2D rigidbody, float to, float duration) => - Tweening.To(getter: () => rigidbody.mass, - setter: mass => rigidbody.mass = mass, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.mass, (source, value) => source.mass = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenCenterOfMass(this Rigidbody2D rigidbody, Vector2 to, float duration) => - Tweening.To(getter: () => rigidbody.centerOfMass, - setter: centerOfMass => rigidbody.centerOfMass = centerOfMass, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.centerOfMass, (source, value) => source.centerOfMass = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenDrag(this Rigidbody2D rigidbody, float to, float duration) => - Tweening.To(getter: () => rigidbody.drag, - setter: drag => rigidbody.drag = drag, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.drag, (source, value) => source.drag = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenAngularDrag(this Rigidbody2D rigidbody, float to, float duration) => - Tweening.To(getter: () => rigidbody.angularDrag, - setter: angularDrag => rigidbody.angularDrag = angularDrag, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.angularDrag, (source, value) => source.angularDrag = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenInertia(this Rigidbody2D rigidbody, float to, float duration) => - Tweening.To(getter: () => rigidbody.inertia, - setter: inertia => rigidbody.inertia = inertia, - to, duration).SetTarget(rigidbody); + Tweening.To(rigidbody, (source) => source.inertia, (source, value) => source.inertia = value, to, duration) + .SetTarget(rigidbody); public static Tween TweenGravityScale(this Rigidbody2D rigidbody, float to, float duration) => - Tweening.To(getter: () => rigidbody.gravityScale, - setter: gravityScale => rigidbody.gravityScale = gravityScale, - to, duration).SetTarget(rigidbody); - + Tweening.To(rigidbody, (source) => source.gravityScale, (source, value) => source.gravityScale = value, to, duration) + .SetTarget(rigidbody); } } diff --git a/Runtime/Extensions/Physics2D/SliderJoint2DTweens.cs b/Runtime/Extensions/Physics2D/SliderJoint2DTweens.cs index e2ec77f..6758408 100644 --- a/Runtime/Extensions/Physics2D/SliderJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/SliderJoint2DTweens.cs @@ -5,10 +5,8 @@ namespace Zigurous.Tweening public static class SliderJoint2DTweens { public static Tween TweenAngle(this SliderJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.angle, - setter: angle => joint.angle = angle, - to, duration).SetTarget(joint); - + Tweening.To(joint, (source) => source.angle, (source, value) => source.angle = value, to, duration) + .SetTarget(joint); } } diff --git a/Runtime/Extensions/Physics2D/SpringJoint2DTweens.cs b/Runtime/Extensions/Physics2D/SpringJoint2DTweens.cs index 7a68a27..7a834b6 100644 --- a/Runtime/Extensions/Physics2D/SpringJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/SpringJoint2DTweens.cs @@ -5,20 +5,16 @@ namespace Zigurous.Tweening public static class SpringJoint2DTweens { public static Tween TweenDistance(this SpringJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.distance, - setter: distance => joint.distance = distance, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.distance, (source, value) => source.distance = value, to, duration) + .SetTarget(joint); public static Tween TweenDampingRatio(this SpringJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.dampingRatio, - setter: dampingRatio => joint.dampingRatio = dampingRatio, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.dampingRatio, (source, value) => source.dampingRatio = value, to, duration) + .SetTarget(joint); public static Tween TweenFrequency(this SpringJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.frequency, - setter: frequency => joint.frequency = frequency, - to, duration).SetTarget(joint); - + Tweening.To(joint, (source) => source.frequency, (source, value) => source.frequency = value, to, duration) + .SetTarget(joint); } } diff --git a/Runtime/Extensions/Physics2D/SurfaceEffector2DTweens.cs b/Runtime/Extensions/Physics2D/SurfaceEffector2DTweens.cs index bd96bfe..317d1b9 100644 --- a/Runtime/Extensions/Physics2D/SurfaceEffector2DTweens.cs +++ b/Runtime/Extensions/Physics2D/SurfaceEffector2DTweens.cs @@ -5,20 +5,16 @@ namespace Zigurous.Tweening public static class SurfaceEffector2DTweens { public static Tween TweenSpeed(this SurfaceEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.speed, - setter: speed => effector.speed = speed, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.speed, (source, value) => source.speed = value, to, duration) + .SetTarget(effector); public static Tween TweenSpeedVariation(this SurfaceEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.speedVariation, - setter: speedVariation => effector.speedVariation = speedVariation, - to, duration).SetTarget(effector); + Tweening.To(effector, (source) => source.speedVariation, (source, value) => source.speedVariation = value, to, duration) + .SetTarget(effector); public static Tween TweenForceScale(this SurfaceEffector2D effector, float to, float duration) => - Tweening.To(getter: () => effector.forceScale, - setter: forceScale => effector.forceScale = forceScale, - to, duration).SetTarget(effector); - + Tweening.To(effector, (source) => source.forceScale, (source, value) => source.forceScale = value, to, duration) + .SetTarget(effector); } } diff --git a/Runtime/Extensions/Physics2D/TargetJoint2DTweens.cs b/Runtime/Extensions/Physics2D/TargetJoint2DTweens.cs index faa57c2..6d0be5a 100644 --- a/Runtime/Extensions/Physics2D/TargetJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/TargetJoint2DTweens.cs @@ -5,30 +5,24 @@ namespace Zigurous.Tweening public static class TargetJoint2DTweens { public static Tween TweenAnchor(this TargetJoint2D joint, Vector2 to, float duration) => - Tweening.To(getter: () => joint.anchor, - setter: anchor => joint.anchor = anchor, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.anchor, (source, value) => source.anchor = value, to, duration) + .SetTarget(joint); public static Tween TweenTarget(this TargetJoint2D joint, Vector2 to, float duration) => - Tweening.To(getter: () => joint.target, - setter: target => joint.target = target, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.target, (source, value) => source.target = value, to, duration) + .SetTarget(joint); public static Tween TweenMaxForce(this TargetJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.maxForce, - setter: maxForce => joint.maxForce = maxForce, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.maxForce, (source, value) => source.maxForce = value, to, duration) + .SetTarget(joint); public static Tween TweenDampingRatio(this TargetJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.dampingRatio, - setter: dampingRatio => joint.dampingRatio = dampingRatio, - to, duration).SetTarget(joint); + Tweening.To(joint, (source) => source.dampingRatio, (source, value) => source.dampingRatio = value, to, duration) + .SetTarget(joint); public static Tween TweenFrequency(this TargetJoint2D joint, float to, float duration) => - Tweening.To(getter: () => joint.frequency, - setter: frequency => joint.frequency = frequency, - to, duration).SetTarget(joint); - + Tweening.To(joint, (source) => source.frequency, (source, value) => source.frequency = value, to, duration) + .SetTarget(joint); } } diff --git a/Runtime/Extensions/Rendering/AnimatorTweens.cs b/Runtime/Extensions/Rendering/AnimatorTweens.cs index e0e7f21..ed93322 100644 --- a/Runtime/Extensions/Rendering/AnimatorTweens.cs +++ b/Runtime/Extensions/Rendering/AnimatorTweens.cs @@ -5,40 +5,32 @@ namespace Zigurous.Tweening public static class AnimatorTweens { public static Tween TweenSpeed(this Animator animator, float to, float duration) => - Tweening.To(getter: () => animator.speed, - setter: speed => animator.speed = speed, - to, duration).SetTarget(animator); + Tweening.To(animator, (source) => source.speed, (source, value) => source.speed = value, to, duration) + .SetTarget(animator); public static Tween TweenPlaybackTime(this Animator animator, float to, float duration) => - Tweening.To(getter: () => animator.playbackTime, - setter: playbackTime => animator.playbackTime = playbackTime, - to, duration).SetTarget(animator); + Tweening.To(animator, (source) => source.playbackTime, (source, value) => source.playbackTime = value, to, duration) + .SetTarget(animator); public static Tween TweenBodyRotation(this Animator animator, Quaternion to, float duration) => - Tweening.To(getter: () => animator.bodyRotation, - setter: bodyRotation => animator.bodyRotation = bodyRotation, - to, duration).SetTarget(animator); + Tweening.To(animator, (source) => source.bodyRotation, (source, value) => source.bodyRotation = value, to, duration) + .SetTarget(animator); public static Tween TweenBodyPosition(this Animator animator, Vector3 to, float duration) => - Tweening.To(getter: () => animator.bodyPosition, - setter: bodyPosition => animator.bodyPosition = bodyPosition, - to, duration).SetTarget(animator); + Tweening.To(animator, (source) => source.bodyPosition, (source, value) => source.bodyPosition = value, to, duration) + .SetTarget(animator); public static Tween TweenRootRotation(this Animator animator, Quaternion to, float duration) => - Tweening.To(getter: () => animator.rootRotation, - setter: rootRotation => animator.rootRotation = rootRotation, - to, duration).SetTarget(animator); + Tweening.To(animator, (source) => source.rootRotation, (source, value) => source.rootRotation = value, to, duration) + .SetTarget(animator); public static Tween TweenRootPosition(this Animator animator, Vector3 to, float duration) => - Tweening.To(getter: () => animator.rootPosition, - setter: rootPosition => animator.rootPosition = rootPosition, - to, duration).SetTarget(animator); + Tweening.To(animator, (source) => source.rootPosition, (source, value) => source.rootPosition = value, to, duration) + .SetTarget(animator); public static Tween TweenFeetPivotActive(this Animator animator, float to, float duration) => - Tweening.To(getter: () => animator.feetPivotActive, - setter: feetPivotActive => animator.feetPivotActive = feetPivotActive, - to, duration).SetTarget(animator); - + Tweening.To(animator, (source) => source.feetPivotActive, (source, value) => source.feetPivotActive = value, to, duration) + .SetTarget(animator); } } diff --git a/Runtime/Extensions/Rendering/CameraTweens.cs b/Runtime/Extensions/Rendering/CameraTweens.cs index 2aeccef..9ca14e8 100644 --- a/Runtime/Extensions/Rendering/CameraTweens.cs +++ b/Runtime/Extensions/Rendering/CameraTweens.cs @@ -5,75 +5,60 @@ namespace Zigurous.Tweening public static class CameraTweens { public static Tween TweenBackgroundColor(this Camera camera, Color to, float duration) => - Tweening.To(getter: () => camera.backgroundColor, - setter: backgroundColor => camera.backgroundColor = backgroundColor, - to, duration).SetTarget(camera); + Tweening.To(camera, (source) => source.backgroundColor, (source, value) => source.backgroundColor = value, to, duration) + .SetTarget(camera); public static Tween TweenAspectRatio(this Camera camera, float to, float duration) => - Tweening.To(getter: () => camera.aspect, - setter: aspect => camera.aspect = aspect, - to, duration).SetTarget(camera); + Tweening.To(camera, (source) => source.aspect, (source, value) => source.aspect = value, to, duration) + .SetTarget(camera); public static Tween TweenFieldOfView(this Camera camera, float to, float duration) => - Tweening.To(getter: () => camera.fieldOfView, - setter: fieldOfView => camera.fieldOfView = fieldOfView, - to, duration).SetTarget(camera); + Tweening.To(camera, (source) => source.fieldOfView, (source, value) => source.fieldOfView = value, to, duration) + .SetTarget(camera); public static Tween TweenNearClipPlane(this Camera camera, float to, float duration) => - Tweening.To(getter: () => camera.nearClipPlane, - setter: nearClipPlane => camera.nearClipPlane = nearClipPlane, - to, duration).SetTarget(camera); + Tweening.To(camera, (source) => source.nearClipPlane, (source, value) => source.nearClipPlane = value, to, duration) + .SetTarget(camera); public static Tween TweenFarClipPlane(this Camera camera, float to, float duration) => - Tweening.To(getter: () => camera.farClipPlane, - setter: farClipPlane => camera.farClipPlane = farClipPlane, - to, duration).SetTarget(camera); + Tweening.To(camera, (source) => source.farClipPlane, (source, value) => source.farClipPlane = value, to, duration) + .SetTarget(camera); public static Tween TweenOrthographicSize(this Camera camera, float to, float duration) => - Tweening.To(getter: () => camera.orthographicSize, - setter: orthographicSize => camera.orthographicSize = orthographicSize, - to, duration).SetTarget(camera); + Tweening.To(camera, (source) => source.orthographicSize, (source, value) => source.orthographicSize = value, to, duration) + .SetTarget(camera); public static Tween TweenSensorSize(this Camera camera, Vector2 to, float duration) => - Tweening.To(getter: () => camera.sensorSize, - setter: sensorSize => camera.sensorSize = sensorSize, - to, duration).SetTarget(camera); + Tweening.To(camera, (source) => source.sensorSize, (source, value) => source.sensorSize = value, to, duration) + .SetTarget(camera); public static Tween TweenFocalLength(this Camera camera, float to, float duration) => - Tweening.To(getter: () => camera.focalLength, - setter: focalLength => camera.focalLength = focalLength, - to, duration).SetTarget(camera); + Tweening.To(camera, (source) => source.focalLength, (source, value) => source.focalLength = value, to, duration) + .SetTarget(camera); public static Tween TweenStereoConvergence(this Camera camera, float to, float duration) => - Tweening.To(getter: () => camera.stereoConvergence, - setter: stereoConvergence => camera.stereoConvergence = stereoConvergence, - to, duration).SetTarget(camera); + Tweening.To(camera, (source) => source.stereoConvergence, (source, value) => source.stereoConvergence = value, to, duration) + .SetTarget(camera); public static Tween TweenStereoSeparation(this Camera camera, float to, float duration) => - Tweening.To(getter: () => camera.stereoSeparation, - setter: stereoSeparation => camera.stereoSeparation = stereoSeparation, - to, duration).SetTarget(camera); + Tweening.To(camera, (source) => source.stereoSeparation, (source, value) => source.stereoSeparation = value, to, duration) + .SetTarget(camera); public static Tween TweenLensShift(this Camera camera, Vector2 to, float duration) => - Tweening.To(getter: () => camera.lensShift, - setter: lensShift => camera.lensShift = lensShift, - to, duration).SetTarget(camera); + Tweening.To(camera, (source) => source.lensShift, (source, value) => source.lensShift = value, to, duration) + .SetTarget(camera); public static Tween TweenRect(this Camera camera, Rect to, float duration) => - Tweening.To(getter: () => camera.rect, - setter: rect => camera.rect = rect, - to, duration).SetTarget(camera); + Tweening.To(camera, (source) => source.rect, (source, value) => source.rect = value, to, duration) + .SetTarget(camera); public static Tween TweenPixelRect(this Camera camera, Rect to, float duration) => - Tweening.To(getter: () => camera.pixelRect, - setter: pixelRect => camera.pixelRect = pixelRect, - to, duration).SetTarget(camera); + Tweening.To(camera, (source) => source.pixelRect, (source, value) => source.pixelRect = value, to, duration) + .SetTarget(camera); public static Tween TweenDepth(this Camera camera, float to, float duration) => - Tweening.To(getter: () => camera.depth, - setter: depth => camera.depth = depth, - to, duration).SetTarget(camera); - + Tweening.To(camera, (source) => source.depth, (source, value) => source.depth = value, to, duration) + .SetTarget(camera); } } diff --git a/Runtime/Extensions/Rendering/LensFlareTweens.cs b/Runtime/Extensions/Rendering/LensFlareTweens.cs index 38859b0..7393594 100644 --- a/Runtime/Extensions/Rendering/LensFlareTweens.cs +++ b/Runtime/Extensions/Rendering/LensFlareTweens.cs @@ -5,20 +5,16 @@ namespace Zigurous.Tweening public static class LensFlareTweens { public static Tween TweenColor(this LensFlare lensFlare, Color to, float duration) => - Tweening.To(getter: () => lensFlare.color, - setter: color => lensFlare.color = color, - to, duration).SetTarget(lensFlare); + Tweening.To(lensFlare, (source) => source.color, (source, value) => source.color = value, to, duration) + .SetTarget(lensFlare); public static Tween TweenBrightness(this LensFlare lensFlare, float to, float duration) => - Tweening.To(getter: () => lensFlare.brightness, - setter: brightness => lensFlare.brightness = brightness, - to, duration).SetTarget(lensFlare); + Tweening.To(lensFlare, (source) => source.brightness, (source, value) => source.brightness = value, to, duration) + .SetTarget(lensFlare); public static Tween TweenFadeSpeed(this LensFlare lensFlare, float to, float duration) => - Tweening.To(getter: () => lensFlare.fadeSpeed, - setter: fadeSpeed => lensFlare.fadeSpeed = fadeSpeed, - to, duration).SetTarget(lensFlare); - + Tweening.To(lensFlare, (source) => source.fadeSpeed, (source, value) => source.fadeSpeed = value, to, duration) + .SetTarget(lensFlare); } } diff --git a/Runtime/Extensions/Rendering/LightTweens.cs b/Runtime/Extensions/Rendering/LightTweens.cs index 3679103..38971dd 100644 --- a/Runtime/Extensions/Rendering/LightTweens.cs +++ b/Runtime/Extensions/Rendering/LightTweens.cs @@ -5,70 +5,56 @@ namespace Zigurous.Tweening public static class LightTweens { public static Tween TweenColor(this Light light, Color to, float duration) => - Tweening.To(getter: () => light.color, - setter: color => light.color = color, - to, duration).SetTarget(light); + Tweening.To(light, (source) => source.color, (source, value) => source.color = value, to, duration) + .SetTarget(light); public static Tween TweenColorTemperature(this Light light, float to, float duration) => - Tweening.To(getter: () => light.colorTemperature, - setter: colorTemperature => light.colorTemperature = colorTemperature, - to, duration).SetTarget(light); + Tweening.To(light, (source) => source.colorTemperature, (source, value) => source.colorTemperature = value, to, duration) + .SetTarget(light); public static Tween TweenIntensity(this Light light, float to, float duration) => - Tweening.To(getter: () => light.intensity, - setter: intensity => light.intensity = intensity, - to, duration).SetTarget(light); + Tweening.To(light, (source) => source.intensity, (source, value) => source.intensity = value, to, duration) + .SetTarget(light); public static Tween TweenBounceIntensity(this Light light, float to, float duration) => - Tweening.To(getter: () => light.bounceIntensity, - setter: bounceIntensity => light.bounceIntensity = bounceIntensity, - to, duration).SetTarget(light); + Tweening.To(light, (source) => source.bounceIntensity, (source, value) => source.bounceIntensity = value, to, duration) + .SetTarget(light); public static Tween TweenRange(this Light light, float to, float duration) => - Tweening.To(getter: () => light.range, - setter: range => light.range = range, - to, duration).SetTarget(light); + Tweening.To(light, (source) => source.range, (source, value) => source.range = value, to, duration) + .SetTarget(light); public static Tween TweenShadowStrength(this Light light, float to, float duration) => - Tweening.To(getter: () => light.shadowStrength, - setter: shadowStrength => light.shadowStrength = shadowStrength, - to, duration).SetTarget(light); + Tweening.To(light, (source) => source.shadowStrength, (source, value) => source.shadowStrength = value, to, duration) + .SetTarget(light); public static Tween TweenShadowBias(this Light light, float to, float duration) => - Tweening.To(getter: () => light.shadowBias, - setter: shadowBias => light.shadowBias = shadowBias, - to, duration).SetTarget(light); + Tweening.To(light, (source) => source.shadowBias, (source, value) => source.shadowBias = value, to, duration) + .SetTarget(light); public static Tween TweenShadowNormalBias(this Light light, float to, float duration) => - Tweening.To(getter: () => light.shadowNormalBias, - setter: shadowNormalBias => light.shadowNormalBias = shadowNormalBias, - to, duration).SetTarget(light); + Tweening.To(light, (source) => source.shadowNormalBias, (source, value) => source.shadowNormalBias = value, to, duration) + .SetTarget(light); public static Tween TweenShadowNearPlane(this Light light, float to, float duration) => - Tweening.To(getter: () => light.shadowNearPlane, - setter: shadowNearPlane => light.shadowNearPlane = shadowNearPlane, - to, duration).SetTarget(light); + Tweening.To(light, (source) => source.shadowNearPlane, (source, value) => source.shadowNearPlane = value, to, duration) + .SetTarget(light); public static Tween TweenSpotAngle(this Light light, float to, float duration) => - Tweening.To(getter: () => light.spotAngle, - setter: spotAngle => light.spotAngle = spotAngle, - to, duration).SetTarget(light); + Tweening.To(light, (source) => source.spotAngle, (source, value) => source.spotAngle = value, to, duration) + .SetTarget(light); public static Tween TweenInnerSpotAngle(this Light light, float to, float duration) => - Tweening.To(getter: () => light.innerSpotAngle, - setter: innerSpotAngle => light.innerSpotAngle = innerSpotAngle, - to, duration).SetTarget(light); + Tweening.To(light, (source) => source.innerSpotAngle, (source, value) => source.innerSpotAngle = value, to, duration) + .SetTarget(light); public static Tween TweenCookieSize(this Light light, float to, float duration) => - Tweening.To(getter: () => light.cookieSize, - setter: cookieSize => light.cookieSize = cookieSize, - to, duration).SetTarget(light); + Tweening.To(light, (source) => source.cookieSize, (source, value) => source.cookieSize = value, to, duration) + .SetTarget(light); public static Tween TweenBoundingSphereOverride(this Light light, Vector4 to, float duration) => - Tweening.To(getter: () => light.boundingSphereOverride, - setter: boundingSphereOverride => light.boundingSphereOverride = boundingSphereOverride, - to, duration).SetTarget(light); - + Tweening.To(light, (source) => source.boundingSphereOverride, (source, value) => source.boundingSphereOverride = value, to, duration) + .SetTarget(light); } } diff --git a/Runtime/Extensions/Rendering/LineRendererTweens.cs b/Runtime/Extensions/Rendering/LineRendererTweens.cs index 9f01dc0..87fb4f8 100644 --- a/Runtime/Extensions/Rendering/LineRendererTweens.cs +++ b/Runtime/Extensions/Rendering/LineRendererTweens.cs @@ -5,35 +5,28 @@ namespace Zigurous.Tweening public static class LineRendererTweens { public static Tween TweenStartColor(this LineRenderer renderer, Color to, float duration) => - Tweening.To(getter: () => renderer.startColor, - setter: startColor => renderer.startColor = startColor, - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.startColor, (source, value) => source.startColor = value, to, duration) + .SetTarget(renderer); public static Tween TweenEndColor(this LineRenderer renderer, Color to, float duration) => - Tweening.To(getter: () => renderer.endColor, - setter: endColor => renderer.endColor = endColor, - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.endColor, (source, value) => source.endColor = value, to, duration) + .SetTarget(renderer); public static Tween TweenStartWidth(this LineRenderer renderer, float to, float duration) => - Tweening.To(getter: () => renderer.startWidth, - setter: startWidth => renderer.startWidth = startWidth, - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.startWidth, (source, value) => source.startWidth = value, to, duration) + .SetTarget(renderer); public static Tween TweenEndWidth(this LineRenderer renderer, float to, float duration) => - Tweening.To(getter: () => renderer.endWidth, - setter: endWidth => renderer.endWidth = endWidth, - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.endWidth, (source, value) => source.endWidth = value, to, duration) + .SetTarget(renderer); public static Tween TweenWidthMultiplier(this LineRenderer renderer, float to, float duration) => - Tweening.To(getter: () => renderer.widthMultiplier, - setter: widthMultiplier => renderer.widthMultiplier = widthMultiplier, - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.widthMultiplier, (source, value) => source.widthMultiplier = value, to, duration) + .SetTarget(renderer); public static Tween TweenShadowBias(this LineRenderer renderer, float to, float duration) => - Tweening.To(getter: () => renderer.shadowBias, - setter: shadowBias => renderer.shadowBias = shadowBias, - to, duration).SetTarget(renderer); - + Tweening.To(renderer, (source) => source.shadowBias, (source, value) => source.shadowBias = value, to, duration) + .SetTarget(renderer); } } diff --git a/Runtime/Extensions/Rendering/MaterialTweens.cs b/Runtime/Extensions/Rendering/MaterialTweens.cs index 67bfcf1..5e39832 100644 --- a/Runtime/Extensions/Rendering/MaterialTweens.cs +++ b/Runtime/Extensions/Rendering/MaterialTweens.cs @@ -5,85 +5,68 @@ namespace Zigurous.Tweening public static class MaterialTweens { public static Tween TweenColor(this Material material, Color to, float duration) => - Tweening.To(getter: () => material.color, - setter: color => material.color = color, - to, duration).SetId(material.GetHashCode()); + Tweening.To(material, (source) => source.color, (source, value) => source.color = value, to, duration) + .SetId(material.GetHashCode()); - public static Tween TweenColor(this Material material, int nameId, Color to, float duration) => - Tweening.To(getter: () => material.GetColor(nameId), - setter: color => material.SetColor(nameId, color), - to, duration).SetId(material.GetHashCode()); + public static Tween TweenColor(this Material material, int nameID, Color to, float duration) => + Tweening.To(material, (source) => source.GetColor(nameID), (source, value) => source.SetColor(nameID, value), to, duration) + .SetId(material.GetHashCode()); public static Tween TweenColor(this Material material, string name, Color to, float duration) => - Tweening.To(getter: () => material.GetColor(name), - setter: color => material.SetColor(name, color), - to, duration).SetId(material.GetHashCode()); + Tweening.To(material, (source) => source.GetColor(name), (source, value) => source.SetColor(name, value), to, duration) + .SetId(material.GetHashCode()); public static Tween TweenAlpha(this Material material, float to, float duration) => - Tweening.To(getter: () => material.color.a, - setter: alpha => material.color = new Color(material.color.r, material.color.g, material.color.b, alpha), - to, duration).SetId(material.GetHashCode()); + Tweening.To(material, (source) => source.color.a, (source, value) => source.color = new Color(source.color.r, source.color.g, source.color.b, value), to, duration) + .SetId(material.GetHashCode()); - public static Tween TweenAlpha(this Material material, int nameId, float to, float duration) => - Tweening.To(getter: () => material.GetColor(nameId).a, - setter: alpha => material.SetColor(nameId, new Color(material.color.r, material.color.g, material.color.b, alpha)), - to, duration).SetId(material.GetHashCode()); + public static Tween TweenAlpha(this Material material, int nameID, float to, float duration) => + Tweening.To(material, (source) => source.GetColor(nameID).a, (source, value) => source.SetColor(nameID, new Color(source.color.r, source.color.g, source.color.b, value)), to, duration) + .SetId(material.GetHashCode()); public static Tween TweenAlpha(this Material material, string name, float to, float duration) => - Tweening.To(getter: () => material.GetColor(name).a, - setter: alpha => material.SetColor(name, new Color(material.color.r, material.color.g, material.color.b, alpha)), - to, duration).SetId(material.GetHashCode()); + Tweening.To(material, (source) => source.GetColor(name).a, (source, value) => source.SetColor(name, new Color(source.color.r, source.color.g, source.color.b, value)), to, duration) + .SetId(material.GetHashCode()); - public static Tween TweenFloat(this Material material, int nameId, float to, float duration) => - Tweening.To(getter: () => material.GetFloat(nameId), - setter: value => material.SetFloat(nameId, value), - to, duration).SetId(material.GetHashCode()); + public static Tween TweenFloat(this Material material, int nameID, float to, float duration) => + Tweening.To(material, (source) => source.GetFloat(nameID), (source, value) => source.SetFloat(nameID, value), to, duration) + .SetId(material.GetHashCode()); public static Tween TweenFloat(this Material material, string name, float to, float duration) => - Tweening.To(getter: () => material.GetFloat(name), - setter: value => material.SetFloat(name, value), - to, duration).SetId(material.GetHashCode()); + Tweening.To(material, (source) => source.GetFloat(name), (source, value) => source.SetFloat(name, value), to, duration) + .SetId(material.GetHashCode()); - public static Tween TweenInt(this Material material, int nameId, int to, float duration) => - Tweening.To(getter: () => material.GetInt(nameId), - setter: value => material.SetInt(nameId, value), - to, duration).SetId(material.GetHashCode()); + public static Tween TweenInt(this Material material, int nameID, int to, float duration) => + Tweening.To(material, (source) => source.GetInt(nameID), (source, value) => source.SetInt(nameID, value), to, duration) + .SetId(material.GetHashCode()); public static Tween TweenInt(this Material material, string name, int to, float duration) => - Tweening.To(getter: () => material.GetInt(name), - setter: value => material.SetInt(name, value), - to, duration).SetId(material.GetHashCode()); + Tweening.To(material, (source) => source.GetInt(name), (source, value) => source.SetInt(name, value), to, duration) + .SetId(material.GetHashCode()); public static Tween TweenMainTextureOffset(this Material material, Vector2 to, float duration) => - Tweening.To(getter: () => material.mainTextureOffset, - setter: mainTextureOffset => material.mainTextureOffset = mainTextureOffset, - to, duration).SetId(material.GetHashCode()); + Tweening.To(material, (source) => source.mainTextureOffset, (source, value) => source.mainTextureOffset = value, to, duration) + .SetId(material.GetHashCode()); public static Tween TweenMainTextureScale(this Material material, Vector2 to, float duration) => - Tweening.To(getter: () => material.mainTextureScale, - setter: mainTextureScale => material.mainTextureScale = mainTextureScale, - to, duration).SetId(material.GetHashCode()); + Tweening.To(material, (source) => source.mainTextureScale, (source, value) => source.mainTextureScale = value, to, duration) + .SetId(material.GetHashCode()); - public static Tween TweenTextureOffset(this Material material, int nameId, Vector2 to, float duration) => - Tweening.To(getter: () => material.GetTextureOffset(nameId), - setter: value => material.SetTextureOffset(nameId, value), - to, duration).SetId(material.GetHashCode()); + public static Tween TweenTextureOffset(this Material material, int nameID, Vector2 to, float duration) => + Tweening.To(material, (source) => source.GetTextureOffset(nameID), (source, value) => source.SetTextureOffset(nameID, value), to, duration) + .SetId(material.GetHashCode()); public static Tween TweenTextureOffset(this Material material, string name, Vector2 to, float duration) => - Tweening.To(getter: () => material.GetTextureOffset(name), - setter: value => material.SetTextureOffset(name, value), - to, duration).SetId(material.GetHashCode()); + Tweening.To(material, (source) => source.GetTextureOffset(name), (source, value) => source.SetTextureOffset(name, value), to, duration) + .SetId(material.GetHashCode()); - public static Tween TweenTextureScale(this Material material, int nameId, Vector2 to, float duration) => - Tweening.To(getter: () => material.GetTextureScale(nameId), - setter: value => material.SetTextureScale(nameId, value), - to, duration).SetId(material.GetHashCode()); + public static Tween TweenTextureScale(this Material material, int nameID, Vector2 to, float duration) => + Tweening.To(material, (source) => source.GetTextureScale(nameID), (source, value) => source.SetTextureScale(nameID, value), to, duration) + .SetId(material.GetHashCode()); public static Tween TweenTextureScale(this Material material, string name, Vector2 to, float duration) => - Tweening.To(getter: () => material.GetTextureScale(name), - setter: value => material.SetTextureScale(name, value), - to, duration).SetId(material.GetHashCode()); - + Tweening.To(material, (source) => source.GetTextureScale(name), (source, value) => source.SetTextureScale(name, value), to, duration) + .SetId(material.GetHashCode()); } } diff --git a/Runtime/Extensions/Rendering/OcclusionAreaTweens.cs b/Runtime/Extensions/Rendering/OcclusionAreaTweens.cs index 1a4de74..138d5eb 100644 --- a/Runtime/Extensions/Rendering/OcclusionAreaTweens.cs +++ b/Runtime/Extensions/Rendering/OcclusionAreaTweens.cs @@ -5,15 +5,12 @@ namespace Zigurous.Tweening public static class OcclusionAreaTweens { public static Tween TweenCenter(this OcclusionArea area, Vector3 to, float duration) => - Tweening.To(getter: () => area.center, - setter: center => area.center = center, - to, duration).SetTarget(area); + Tweening.To(area, (source) => source.center, (source, value) => source.center = value, to, duration) + .SetTarget(area); public static Tween TweenSize(this OcclusionArea area, Vector3 to, float duration) => - Tweening.To(getter: () => area.size, - setter: size => area.size = size, - to, duration).SetTarget(area); - + Tweening.To(area, (source) => source.size, (source, value) => source.size = value, to, duration) + .SetTarget(area); } } diff --git a/Runtime/Extensions/Rendering/ParticleSystemForceFieldTweens.cs b/Runtime/Extensions/Rendering/ParticleSystemForceFieldTweens.cs index 00fb377..b3d24dd 100644 --- a/Runtime/Extensions/Rendering/ParticleSystemForceFieldTweens.cs +++ b/Runtime/Extensions/Rendering/ParticleSystemForceFieldTweens.cs @@ -5,30 +5,24 @@ namespace Zigurous.Tweening public static class ParticleSystemForceFieldTweens { public static Tween TweenRotationRandomness(this ParticleSystemForceField forceField, Vector2 to, float duration) => - Tweening.To(getter: () => forceField.rotationRandomness, - setter: rotationRandomness => forceField.rotationRandomness = rotationRandomness, - to, duration).SetTarget(forceField); + Tweening.To(forceField, (source) => source.rotationRandomness, (source, value) => source.rotationRandomness = value, to, duration) + .SetTarget(forceField); public static Tween TweenGravityFocus(this ParticleSystemForceField forceField, float to, float duration) => - Tweening.To(getter: () => forceField.gravityFocus, - setter: gravityFocus => forceField.gravityFocus = gravityFocus, - to, duration).SetTarget(forceField); + Tweening.To(forceField, (source) => source.gravityFocus, (source, value) => source.gravityFocus = value, to, duration) + .SetTarget(forceField); public static Tween TweenLength(this ParticleSystemForceField forceField, float to, float duration) => - Tweening.To(getter: () => forceField.length, - setter: length => forceField.length = length, - to, duration).SetTarget(forceField); + Tweening.To(forceField, (source) => source.length, (source, value) => source.length = value, to, duration) + .SetTarget(forceField); public static Tween TweenStartRange(this ParticleSystemForceField forceField, float to, float duration) => - Tweening.To(getter: () => forceField.startRange, - setter: startRange => forceField.startRange = startRange, - to, duration).SetTarget(forceField); + Tweening.To(forceField, (source) => source.startRange, (source, value) => source.startRange = value, to, duration) + .SetTarget(forceField); public static Tween TweenEndRange(this ParticleSystemForceField forceField, float to, float duration) => - Tweening.To(getter: () => forceField.endRange, - setter: endRange => forceField.endRange = endRange, - to, duration).SetTarget(forceField); - + Tweening.To(forceField, (source) => source.endRange, (source, value) => source.endRange = value, to, duration) + .SetTarget(forceField); } } diff --git a/Runtime/Extensions/Rendering/ParticleSystemTweens.cs b/Runtime/Extensions/Rendering/ParticleSystemTweens.cs index 0d4fc1a..00fda6c 100644 --- a/Runtime/Extensions/Rendering/ParticleSystemTweens.cs +++ b/Runtime/Extensions/Rendering/ParticleSystemTweens.cs @@ -5,10 +5,8 @@ namespace Zigurous.Tweening public static class ParticleSystemTweens { public static Tween TweenTime(this ParticleSystem particleSystem, float to, float duration) => - Tweening.To(getter: () => particleSystem.time, - setter: time => particleSystem.time = time, - to, duration).SetTarget(particleSystem); - + Tweening.To(particleSystem, (source) => source.time, (source, value) => source.time = value, to, duration) + .SetTarget(particleSystem); } } diff --git a/Runtime/Extensions/Rendering/ProjectorTweens.cs b/Runtime/Extensions/Rendering/ProjectorTweens.cs index b06f1a6..62f278a 100644 --- a/Runtime/Extensions/Rendering/ProjectorTweens.cs +++ b/Runtime/Extensions/Rendering/ProjectorTweens.cs @@ -5,30 +5,24 @@ namespace Zigurous.Tweening public static class ProjectorTweens { public static Tween TweenNearClipPlane(this Projector projector, float to, float duration) => - Tweening.To(getter: () => projector.nearClipPlane, - setter: nearClipPlane => projector.nearClipPlane = nearClipPlane, - to, duration).SetTarget(projector); + Tweening.To(projector, (source) => source.nearClipPlane, (source, value) => source.nearClipPlane = value, to, duration) + .SetTarget(projector); public static Tween TweenFarClipPlane(this Projector projector, float to, float duration) => - Tweening.To(getter: () => projector.farClipPlane, - setter: farClipPlane => projector.farClipPlane = farClipPlane, - to, duration).SetTarget(projector); + Tweening.To(projector, (source) => source.farClipPlane, (source, value) => source.farClipPlane = value, to, duration) + .SetTarget(projector); public static Tween TweenFieldOfView(this Projector projector, float to, float duration) => - Tweening.To(getter: () => projector.fieldOfView, - setter: fieldOfView => projector.fieldOfView = fieldOfView, - to, duration).SetTarget(projector); + Tweening.To(projector, (source) => source.fieldOfView, (source, value) => source.fieldOfView = value, to, duration) + .SetTarget(projector); public static Tween TweenAspectRatio(this Projector projector, float to, float duration) => - Tweening.To(getter: () => projector.aspectRatio, - setter: aspectRatio => projector.aspectRatio = aspectRatio, - to, duration).SetTarget(projector); + Tweening.To(projector, (source) => source.aspectRatio, (source, value) => source.aspectRatio = value, to, duration) + .SetTarget(projector); public static Tween TweenOrthographicSize(this Projector projector, float to, float duration) => - Tweening.To(getter: () => projector.orthographicSize, - setter: orthographicSize => projector.orthographicSize = orthographicSize, - to, duration).SetTarget(projector); - + Tweening.To(projector, (source) => source.orthographicSize, (source, value) => source.orthographicSize = value, to, duration) + .SetTarget(projector); } } diff --git a/Runtime/Extensions/Rendering/ReflectionProbeTweens.cs b/Runtime/Extensions/Rendering/ReflectionProbeTweens.cs index 1ec21ae..c66e451 100644 --- a/Runtime/Extensions/Rendering/ReflectionProbeTweens.cs +++ b/Runtime/Extensions/Rendering/ReflectionProbeTweens.cs @@ -5,45 +5,36 @@ namespace Zigurous.Tweening public static class ReflectionProbeTweens { public static Tween TweenCenter(this ReflectionProbe probe, Vector3 to, float duration) => - Tweening.To(getter: () => probe.center, - setter: center => probe.center = center, - to, duration).SetTarget(probe); + Tweening.To(probe, (source) => source.center, (source, value) => source.center = value, to, duration) + .SetTarget(probe); public static Tween TweenSize(this ReflectionProbe probe, Vector3 to, float duration) => - Tweening.To(getter: () => probe.size, - setter: size => probe.size = size, - to, duration).SetTarget(probe); + Tweening.To(probe, (source) => source.size, (source, value) => source.size = value, to, duration) + .SetTarget(probe); public static Tween TweenIntensity(this ReflectionProbe probe, float to, float duration) => - Tweening.To(getter: () => probe.intensity, - setter: intensity => probe.intensity = intensity, - to, duration).SetTarget(probe); + Tweening.To(probe, (source) => source.intensity, (source, value) => source.intensity = value, to, duration) + .SetTarget(probe); public static Tween TweenFarClipPlane(this ReflectionProbe probe, float to, float duration) => - Tweening.To(getter: () => probe.farClipPlane, - setter: farClipPlane => probe.farClipPlane = farClipPlane, - to, duration).SetTarget(probe); + Tweening.To(probe, (source) => source.farClipPlane, (source, value) => source.farClipPlane = value, to, duration) + .SetTarget(probe); public static Tween TweenNearClipPlane(this ReflectionProbe probe, float to, float duration) => - Tweening.To(getter: () => probe.nearClipPlane, - setter: nearClipPlane => probe.nearClipPlane = nearClipPlane, - to, duration).SetTarget(probe); + Tweening.To(probe, (source) => source.nearClipPlane, (source, value) => source.nearClipPlane = value, to, duration) + .SetTarget(probe); public static Tween TweenBlendDistance(this ReflectionProbe probe, float to, float duration) => - Tweening.To(getter: () => probe.blendDistance, - setter: blendDistance => probe.blendDistance = blendDistance, - to, duration).SetTarget(probe); + Tweening.To(probe, (source) => source.blendDistance, (source, value) => source.blendDistance = value, to, duration) + .SetTarget(probe); public static Tween TweenShadowDistance(this ReflectionProbe probe, float to, float duration) => - Tweening.To(getter: () => probe.shadowDistance, - setter: shadowDistance => probe.shadowDistance = shadowDistance, - to, duration).SetTarget(probe); + Tweening.To(probe, (source) => source.shadowDistance, (source, value) => source.shadowDistance = value, to, duration) + .SetTarget(probe); public static Tween TweenBackgroundColor(this ReflectionProbe probe, Color to, float duration) => - Tweening.To(getter: () => probe.backgroundColor, - setter: backgroundColor => probe.backgroundColor = backgroundColor, - to, duration).SetTarget(probe); - + Tweening.To(probe, (source) => source.backgroundColor, (source, value) => source.backgroundColor = value, to, duration) + .SetTarget(probe); } } diff --git a/Runtime/Extensions/Rendering/SpriteMaskTweens.cs b/Runtime/Extensions/Rendering/SpriteMaskTweens.cs index bf82e31..fc75e0c 100644 --- a/Runtime/Extensions/Rendering/SpriteMaskTweens.cs +++ b/Runtime/Extensions/Rendering/SpriteMaskTweens.cs @@ -5,10 +5,8 @@ namespace Zigurous.Tweening public static class SpriteMaskTweens { public static Tween TweenAlphaCutoff(this SpriteMask mask, float to, float duration) => - Tweening.To(getter: () => mask.alphaCutoff, - setter: alphaCutoff => mask.alphaCutoff = alphaCutoff, - to, duration).SetTarget(mask); - + Tweening.To(mask, (source) => source.alphaCutoff, (source, value) => source.alphaCutoff = value, to, duration) + .SetTarget(mask); } } diff --git a/Runtime/Extensions/Rendering/SpriteRendererTweens.cs b/Runtime/Extensions/Rendering/SpriteRendererTweens.cs index 99c13d5..f077d07 100644 --- a/Runtime/Extensions/Rendering/SpriteRendererTweens.cs +++ b/Runtime/Extensions/Rendering/SpriteRendererTweens.cs @@ -5,25 +5,20 @@ namespace Zigurous.Tweening public static class SpriteRendererTweens { public static Tween TweenColor(this SpriteRenderer renderer, Color to, float duration) => - Tweening.To(getter: () => renderer.color, - setter: color => renderer.color = color, - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.color, (source, value) => source.color = value, to, duration) + .SetTarget(renderer); public static Tween TweenAlpha(this SpriteRenderer renderer, float to, float duration) => - Tweening.To(getter: () => renderer.color.a, - setter: alpha => renderer.color = new Color(renderer.color.r, renderer.color.g, renderer.color.b, alpha), - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.color.a, (source, value) => source.color = new Color(source.color.r, source.color.g, source.color.b, value), to, duration) + .SetTarget(renderer); public static Tween TweenSize(this SpriteRenderer renderer, Vector2 to, float duration) => - Tweening.To(getter: () => renderer.size, - setter: size => renderer.size = size, - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.size, (source, value) => source.size = value, to, duration) + .SetTarget(renderer); public static Tween TweenAdaptiveModeThreshold(this SpriteRenderer renderer, float to, float duration) => - Tweening.To(getter: () => renderer.adaptiveModeThreshold, - setter: adaptiveModeThreshold => renderer.adaptiveModeThreshold = adaptiveModeThreshold, - to, duration).SetTarget(renderer); - + Tweening.To(renderer, (source) => source.adaptiveModeThreshold, (source, value) => source.adaptiveModeThreshold = value, to, duration) + .SetTarget(renderer); } } diff --git a/Runtime/Extensions/Rendering/SpriteShapeRendererTweens.cs b/Runtime/Extensions/Rendering/SpriteShapeRendererTweens.cs index 6a89dfa..b577266 100644 --- a/Runtime/Extensions/Rendering/SpriteShapeRendererTweens.cs +++ b/Runtime/Extensions/Rendering/SpriteShapeRendererTweens.cs @@ -6,15 +6,12 @@ namespace Zigurous.Tweening public static class SpriteShapeRendererTweens { public static Tween TweenColor(this SpriteShapeRenderer renderer, Color to, float duration) => - Tweening.To(getter: () => renderer.color, - setter: color => renderer.color = color, - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.color, (source, value) => source.color = value, to, duration) + .SetTarget(renderer); public static Tween TweenAlpha(this SpriteShapeRenderer renderer, float to, float duration) => - Tweening.To(getter: () => renderer.color.a, - setter: alpha => renderer.color = new Color(renderer.color.r, renderer.color.g, renderer.color.b, alpha), - to, duration).SetTarget(renderer); - + Tweening.To(renderer, (source) => source.color.a, (source, value) => source.color = new Color(source.color.r, source.color.g, source.color.b, value), to, duration) + .SetTarget(renderer); } } diff --git a/Runtime/Extensions/Rendering/TilemapTweens.cs b/Runtime/Extensions/Rendering/TilemapTweens.cs index 121b71b..0c5c317 100644 --- a/Runtime/Extensions/Rendering/TilemapTweens.cs +++ b/Runtime/Extensions/Rendering/TilemapTweens.cs @@ -6,30 +6,24 @@ namespace Zigurous.Tweening public static class TilemapTweens { public static Tween TweenColor(this Tilemap tilemap, Color to, float duration) => - Tweening.To(getter: () => tilemap.color, - setter: color => tilemap.color = color, - to, duration).SetTarget(tilemap); + Tweening.To(tilemap, (source) => source.color, (source, value) => source.color = value, to, duration) + .SetTarget(tilemap); public static Tween TweenOrigin(this Tilemap tilemap, Vector3Int to, float duration) => - Tweening.To(getter: () => tilemap.origin, - setter: origin => tilemap.origin = origin, - to, duration).SetTarget(tilemap); + Tweening.To(tilemap, (source) => source.origin, (source, value) => source.origin = value, to, duration) + .SetTarget(tilemap); public static Tween TweenSize(this Tilemap tilemap, Vector3Int to, float duration) => - Tweening.To(getter: () => tilemap.size, - setter: size => tilemap.size = size, - to, duration).SetTarget(tilemap); + Tweening.To(tilemap, (source) => source.size, (source, value) => source.size = value, to, duration) + .SetTarget(tilemap); public static Tween TweenTileAnchor(this Tilemap tilemap, Vector3 to, float duration) => - Tweening.To(getter: () => tilemap.tileAnchor, - setter: tileAnchor => tilemap.tileAnchor = tileAnchor, - to, duration).SetTarget(tilemap); + Tweening.To(tilemap, (source) => source.tileAnchor, (source, value) => source.tileAnchor = value, to, duration) + .SetTarget(tilemap); public static Tween TweenAnimationFrameRate(this Tilemap tilemap, float to, float duration) => - Tweening.To(getter: () => tilemap.animationFrameRate, - setter: animationFrameRate => tilemap.animationFrameRate = animationFrameRate, - to, duration).SetTarget(tilemap); - + Tweening.To(tilemap, (source) => source.animationFrameRate, (source, value) => source.animationFrameRate = value, to, duration) + .SetTarget(tilemap); } } diff --git a/Runtime/Extensions/Rendering/TrailRendererTweens.cs b/Runtime/Extensions/Rendering/TrailRendererTweens.cs index a2a8003..2137961 100644 --- a/Runtime/Extensions/Rendering/TrailRendererTweens.cs +++ b/Runtime/Extensions/Rendering/TrailRendererTweens.cs @@ -5,45 +5,36 @@ namespace Zigurous.Tweening public static class TrailRendererTweens { public static Tween TweenTime(this TrailRenderer renderer, float to, float duration) => - Tweening.To(getter: () => renderer.time, - setter: time => renderer.time = time, - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.time, (source, value) => source.time = value, to, duration) + .SetTarget(renderer); public static Tween TweenStartColor(this TrailRenderer renderer, Color to, float duration) => - Tweening.To(getter: () => renderer.startColor, - setter: startColor => renderer.startColor = startColor, - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.startColor, (source, value) => source.startColor = value, to, duration) + .SetTarget(renderer); public static Tween TweenEndColor(this TrailRenderer renderer, Color to, float duration) => - Tweening.To(getter: () => renderer.endColor, - setter: endColor => renderer.endColor = endColor, - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.endColor, (source, value) => source.endColor = value, to, duration) + .SetTarget(renderer); public static Tween TweenStartWidth(this TrailRenderer renderer, float to, float duration) => - Tweening.To(getter: () => renderer.startWidth, - setter: startWidth => renderer.startWidth = startWidth, - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.startWidth, (source, value) => source.startWidth = value, to, duration) + .SetTarget(renderer); public static Tween TweenEndWidth(this TrailRenderer renderer, float to, float duration) => - Tweening.To(getter: () => renderer.endWidth, - setter: endWidth => renderer.endWidth = endWidth, - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.endWidth, (source, value) => source.endWidth = value, to, duration) + .SetTarget(renderer); public static Tween TweenWidthMultiplier(this TrailRenderer renderer, float to, float duration) => - Tweening.To(getter: () => renderer.widthMultiplier, - setter: widthMultiplier => renderer.widthMultiplier = widthMultiplier, - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.widthMultiplier, (source, value) => source.widthMultiplier = value, to, duration) + .SetTarget(renderer); public static Tween TweenShadowBias(this TrailRenderer renderer, float to, float duration) => - Tweening.To(getter: () => renderer.shadowBias, - setter: shadowBias => renderer.shadowBias = shadowBias, - to, duration).SetTarget(renderer); + Tweening.To(renderer, (source) => source.shadowBias, (source, value) => source.shadowBias = value, to, duration) + .SetTarget(renderer); public static Tween TweenMinVertexDistance(this TrailRenderer renderer, float to, float duration) => - Tweening.To(getter: () => renderer.minVertexDistance, - setter: minVertexDistance => renderer.minVertexDistance = minVertexDistance, - to, duration).SetTarget(renderer); - + Tweening.To(renderer, (source) => source.minVertexDistance, (source, value) => source.minVertexDistance = value, to, duration) + .SetTarget(renderer); } } diff --git a/Runtime/Extensions/Rendering/VideoPlayerTweens.cs b/Runtime/Extensions/Rendering/VideoPlayerTweens.cs index b45e9a0..c9a30ab 100644 --- a/Runtime/Extensions/Rendering/VideoPlayerTweens.cs +++ b/Runtime/Extensions/Rendering/VideoPlayerTweens.cs @@ -5,30 +5,24 @@ namespace Zigurous.Tweening public static class VideoPlayerTweens { public static Tween TweenFrame(this VideoPlayer videoPlayer, long to, float duration) => - Tweening.To(getter: () => videoPlayer.frame, - setter: frame => videoPlayer.frame = frame, - to, duration).SetTarget(videoPlayer); + Tweening.To(videoPlayer, (source) => source.frame, (source, value) => source.frame = value, to, duration) + .SetTarget(videoPlayer); public static Tween TweenTime(this VideoPlayer videoPlayer, double to, float duration) => - Tweening.To(getter: () => videoPlayer.time, - setter: time => videoPlayer.time = time, - to, duration).SetTarget(videoPlayer); + Tweening.To(videoPlayer, (source) => source.time, (source, value) => source.time = value, to, duration) + .SetTarget(videoPlayer); public static Tween TweenPlaybackSpeed(this VideoPlayer videoPlayer, float to, float duration) => - Tweening.To(getter: () => videoPlayer.playbackSpeed, - setter: playbackSpeed => videoPlayer.playbackSpeed = playbackSpeed, - to, duration).SetTarget(videoPlayer); + Tweening.To(videoPlayer, (source) => source.playbackSpeed, (source, value) => source.playbackSpeed = value, to, duration) + .SetTarget(videoPlayer); public static Tween TweenExternalReferenceTime(this VideoPlayer videoPlayer, double to, float duration) => - Tweening.To(getter: () => videoPlayer.externalReferenceTime, - setter: externalReferenceTime => videoPlayer.externalReferenceTime = externalReferenceTime, - to, duration).SetTarget(videoPlayer); + Tweening.To(videoPlayer, (source) => source.externalReferenceTime, (source, value) => source.externalReferenceTime = value, to, duration) + .SetTarget(videoPlayer); public static Tween TweenTargetCameraAlpha(this VideoPlayer videoPlayer, float to, float duration) => - Tweening.To(getter: () => videoPlayer.targetCameraAlpha, - setter: targetCameraAlpha => videoPlayer.targetCameraAlpha = targetCameraAlpha, - to, duration).SetTarget(videoPlayer); - + Tweening.To(videoPlayer, (source) => source.targetCameraAlpha, (source, value) => source.targetCameraAlpha = value, to, duration) + .SetTarget(videoPlayer); } } diff --git a/Runtime/Extensions/Rendering/WindZoneTweens.cs b/Runtime/Extensions/Rendering/WindZoneTweens.cs index 2461a00..4d8c2cc 100644 --- a/Runtime/Extensions/Rendering/WindZoneTweens.cs +++ b/Runtime/Extensions/Rendering/WindZoneTweens.cs @@ -5,30 +5,24 @@ namespace Zigurous.Tweening public static class WindZoneTweens { public static Tween TweenRadius(this WindZone windZone, float to, float duration) => - Tweening.To(getter: () => windZone.radius, - setter: radius => windZone.radius = radius, - to, duration).SetTarget(windZone); + Tweening.To(windZone, (source) => source.radius, (source, value) => source.radius = value, to, duration) + .SetTarget(windZone); public static Tween TweenWindMain(this WindZone windZone, float to, float duration) => - Tweening.To(getter: () => windZone.windMain, - setter: windMain => windZone.windMain = windMain, - to, duration).SetTarget(windZone); + Tweening.To(windZone, (source) => source.windMain, (source, value) => source.windMain = value, to, duration) + .SetTarget(windZone); public static Tween TweenWindTurbulence(this WindZone windZone, float to, float duration) => - Tweening.To(getter: () => windZone.windTurbulence, - setter: windTurbulence => windZone.windTurbulence = windTurbulence, - to, duration).SetTarget(windZone); + Tweening.To(windZone, (source) => source.windTurbulence, (source, value) => source.windTurbulence = value, to, duration) + .SetTarget(windZone); public static Tween TweenWindPulseMagnitude(this WindZone windZone, float to, float duration) => - Tweening.To(getter: () => windZone.windPulseMagnitude, - setter: windPulseMagnitude => windZone.windPulseMagnitude = windPulseMagnitude, - to, duration).SetTarget(windZone); + Tweening.To(windZone, (source) => source.windPulseMagnitude, (source, value) => source.windPulseMagnitude = value, to, duration) + .SetTarget(windZone); public static Tween TweenWindPulseFrequency(this WindZone windZone, float to, float duration) => - Tweening.To(getter: () => windZone.windPulseFrequency, - setter: windPulseFrequency => windZone.windPulseFrequency = windPulseFrequency, - to, duration).SetTarget(windZone); - + Tweening.To(windZone, (source) => source.windPulseFrequency, (source, value) => source.windPulseFrequency = value, to, duration) + .SetTarget(windZone); } } diff --git a/Runtime/Extensions/UI/AspectRatioFitterTweens.cs b/Runtime/Extensions/UI/AspectRatioFitterTweens.cs index 714e540..4cb6e20 100644 --- a/Runtime/Extensions/UI/AspectRatioFitterTweens.cs +++ b/Runtime/Extensions/UI/AspectRatioFitterTweens.cs @@ -5,10 +5,8 @@ namespace Zigurous.Tweening public static class AspectRatioFitterTweens { public static Tween TweenAspectRatio(this AspectRatioFitter fitter, float to, float duration) => - Tweening.To(getter: () => fitter.aspectRatio, - setter: aspectRatio => fitter.aspectRatio = aspectRatio, - to, duration).SetTarget(fitter); - + Tweening.To(fitter, (source) => source.aspectRatio, (source, value) => source.aspectRatio = value, to, duration) + .SetTarget(fitter); } } diff --git a/Runtime/Extensions/UI/CanvasGroupTweens.cs b/Runtime/Extensions/UI/CanvasGroupTweens.cs index 86c50d4..3854e3a 100644 --- a/Runtime/Extensions/UI/CanvasGroupTweens.cs +++ b/Runtime/Extensions/UI/CanvasGroupTweens.cs @@ -5,10 +5,8 @@ namespace Zigurous.Tweening public static class CanvasGroupTweens { public static Tween TweenAlpha(this CanvasGroup canvasGroup, float to, float duration) => - Tweening.To(getter: () => canvasGroup.alpha, - setter: alpha => canvasGroup.alpha = alpha, - to, duration).SetTarget(canvasGroup); - + Tweening.To(canvasGroup, (source) => source.alpha, (source, value) => source.alpha = value, to, duration) + .SetTarget(canvasGroup); } } diff --git a/Runtime/Extensions/UI/CanvasScalerTweens.cs b/Runtime/Extensions/UI/CanvasScalerTweens.cs index 3c41d58..b850021 100644 --- a/Runtime/Extensions/UI/CanvasScalerTweens.cs +++ b/Runtime/Extensions/UI/CanvasScalerTweens.cs @@ -6,40 +6,32 @@ namespace Zigurous.Tweening public static class CanvasScalerTweens { public static Tween TweenScaleFactor(this CanvasScaler scaler, float to, float duration) => - Tweening.To(getter: () => scaler.scaleFactor, - setter: scaleFactor => scaler.scaleFactor = scaleFactor, - to, duration).SetTarget(scaler); + Tweening.To(scaler, (source) => source.scaleFactor, (source, value) => source.scaleFactor = value, to, duration) + .SetTarget(scaler); public static Tween TweenReferenceResolution(this CanvasScaler scaler, Vector2 to, float duration) => - Tweening.To(getter: () => scaler.referenceResolution, - setter: referenceResolution => scaler.referenceResolution = referenceResolution, - to, duration).SetTarget(scaler); + Tweening.To(scaler, (source) => source.referenceResolution, (source, value) => source.referenceResolution = value, to, duration) + .SetTarget(scaler); public static Tween TweenMatchWidthOrHeight(this CanvasScaler scaler, float to, float duration) => - Tweening.To(getter: () => scaler.matchWidthOrHeight, - setter: matchWidthOrHeight => scaler.matchWidthOrHeight = matchWidthOrHeight, - to, duration).SetTarget(scaler); + Tweening.To(scaler, (source) => source.matchWidthOrHeight, (source, value) => source.matchWidthOrHeight = value, to, duration) + .SetTarget(scaler); public static Tween TweenDefaultSpriteDPI(this CanvasScaler scaler, float to, float duration) => - Tweening.To(getter: () => scaler.defaultSpriteDPI, - setter: defaultSpriteDPI => scaler.defaultSpriteDPI = defaultSpriteDPI, - to, duration).SetTarget(scaler); + Tweening.To(scaler, (source) => source.defaultSpriteDPI, (source, value) => source.defaultSpriteDPI = value, to, duration) + .SetTarget(scaler); public static Tween TweenFallbackScreenDPI(this CanvasScaler scaler, float to, float duration) => - Tweening.To(getter: () => scaler.fallbackScreenDPI, - setter: fallbackScreenDPI => scaler.fallbackScreenDPI = fallbackScreenDPI, - to, duration).SetTarget(scaler); + Tweening.To(scaler, (source) => source.fallbackScreenDPI, (source, value) => source.fallbackScreenDPI = value, to, duration) + .SetTarget(scaler); public static Tween TweenDynamicPixelsPerUnit(this CanvasScaler scaler, float to, float duration) => - Tweening.To(getter: () => scaler.dynamicPixelsPerUnit, - setter: dynamicPixelsPerUnit => scaler.dynamicPixelsPerUnit = dynamicPixelsPerUnit, - to, duration).SetTarget(scaler); + Tweening.To(scaler, (source) => source.dynamicPixelsPerUnit, (source, value) => source.dynamicPixelsPerUnit = value, to, duration) + .SetTarget(scaler); public static Tween TweenReferencePixelsPerUnit(this CanvasScaler scaler, float to, float duration) => - Tweening.To(getter: () => scaler.referencePixelsPerUnit, - setter: referencePixelsPerUnit => scaler.referencePixelsPerUnit = referencePixelsPerUnit, - to, duration).SetTarget(scaler); - + Tweening.To(scaler, (source) => source.referencePixelsPerUnit, (source, value) => source.referencePixelsPerUnit = value, to, duration) + .SetTarget(scaler); } } diff --git a/Runtime/Extensions/UI/CanvasTweens.cs b/Runtime/Extensions/UI/CanvasTweens.cs index a2612f8..56bc6e5 100644 --- a/Runtime/Extensions/UI/CanvasTweens.cs +++ b/Runtime/Extensions/UI/CanvasTweens.cs @@ -5,25 +5,20 @@ namespace Zigurous.Tweening public static class CanvasTweens { public static Tween TweenScaleFactor(this Canvas canvas, float to, float duration) => - Tweening.To(getter: () => canvas.scaleFactor, - setter: scaleFactor => canvas.scaleFactor = scaleFactor, - to, duration).SetTarget(canvas); + Tweening.To(canvas, (source) => source.scaleFactor, (source, value) => source.scaleFactor = value, to, duration) + .SetTarget(canvas); public static Tween TweenPlaneDistance(this Canvas canvas, float to, float duration) => - Tweening.To(getter: () => canvas.planeDistance, - setter: planeDistance => canvas.planeDistance = planeDistance, - to, duration).SetTarget(canvas); + Tweening.To(canvas, (source) => source.planeDistance, (source, value) => source.planeDistance = value, to, duration) + .SetTarget(canvas); public static Tween TweenReferencePixelsPerUnit(this Canvas canvas, float to, float duration) => - Tweening.To(getter: () => canvas.referencePixelsPerUnit, - setter: referencePixelsPerUnit => canvas.referencePixelsPerUnit = referencePixelsPerUnit, - to, duration).SetTarget(canvas); + Tweening.To(canvas, (source) => source.referencePixelsPerUnit, (source, value) => source.referencePixelsPerUnit = value, to, duration) + .SetTarget(canvas); public static Tween TweenNormalizedSortingGridSize(this Canvas canvas, float to, float duration) => - Tweening.To(getter: () => canvas.normalizedSortingGridSize, - setter: normalizedSortingGridSize => canvas.normalizedSortingGridSize = normalizedSortingGridSize, - to, duration).SetTarget(canvas); - + Tweening.To(canvas, (source) => source.normalizedSortingGridSize, (source, value) => source.normalizedSortingGridSize = value, to, duration) + .SetTarget(canvas); } } diff --git a/Runtime/Extensions/UI/GraphicTweens.cs b/Runtime/Extensions/UI/GraphicTweens.cs index 81f62a0..15128d1 100644 --- a/Runtime/Extensions/UI/GraphicTweens.cs +++ b/Runtime/Extensions/UI/GraphicTweens.cs @@ -6,15 +6,12 @@ namespace Zigurous.Tweening public static class GraphicTweens { public static Tween TweenColor(this Graphic graphic, Color to, float duration) => - Tweening.To(getter: () => graphic.color, - setter: color => graphic.color = color, - to, duration).SetTarget(graphic); + Tweening.To(graphic, (source) => source.color, (source, value) => source.color = value, to, duration) + .SetTarget(graphic); public static Tween TweenAlpha(this Graphic graphic, float to, float duration) => - Tweening.To(getter: () => graphic.color.a, - setter: alpha => graphic.color = new Color(graphic.color.r, graphic.color.g, graphic.color.b, alpha), - to, duration).SetTarget(graphic); - + Tweening.To(graphic, (source) => source.color.a, (source, value) => source.color = new Color(source.color.r, source.color.g, source.color.b, value), to, duration) + .SetTarget(graphic); } } diff --git a/Runtime/Extensions/UI/GridLayoutGroupTweens.cs b/Runtime/Extensions/UI/GridLayoutGroupTweens.cs index 2f95207..0ec8976 100644 --- a/Runtime/Extensions/UI/GridLayoutGroupTweens.cs +++ b/Runtime/Extensions/UI/GridLayoutGroupTweens.cs @@ -6,15 +6,12 @@ namespace Zigurous.Tweening public static class GridLayoutGroupTweens { public static Tween TweenSpacing(this GridLayoutGroup layoutGroup, Vector2 to, float duration) => - Tweening.To(getter: () => layoutGroup.spacing, - setter: spacing => layoutGroup.spacing = spacing, - to, duration).SetTarget(layoutGroup); + Tweening.To(layoutGroup, (source) => source.spacing, (source, value) => source.spacing = value, to, duration) + .SetTarget(layoutGroup); public static Tween TweenCellSize(this GridLayoutGroup layoutGroup, Vector2 to, float duration) => - Tweening.To(getter: () => layoutGroup.cellSize, - setter: cellSize => layoutGroup.cellSize = cellSize, - to, duration).SetTarget(layoutGroup); - + Tweening.To(layoutGroup, (source) => source.cellSize, (source, value) => source.cellSize = value, to, duration) + .SetTarget(layoutGroup); } } diff --git a/Runtime/Extensions/UI/HorizontalOrVerticalLayoutGroupTweens.cs b/Runtime/Extensions/UI/HorizontalOrVerticalLayoutGroupTweens.cs index 8873aa3..00abb5d 100644 --- a/Runtime/Extensions/UI/HorizontalOrVerticalLayoutGroupTweens.cs +++ b/Runtime/Extensions/UI/HorizontalOrVerticalLayoutGroupTweens.cs @@ -5,10 +5,8 @@ namespace Zigurous.Tweening public static class HorizontalOrVerticalLayoutGroupTweens { public static Tween TweenSpacing(this HorizontalOrVerticalLayoutGroup layoutGroup, float to, float duration) => - Tweening.To(getter: () => layoutGroup.spacing, - setter: spacing => layoutGroup.spacing = spacing, - to, duration).SetTarget(layoutGroup); - + Tweening.To(layoutGroup, (source) => source.spacing, (source, value) => source.spacing = value, to, duration) + .SetTarget(layoutGroup); } } diff --git a/Runtime/Extensions/UI/RectMask2DTweens.cs b/Runtime/Extensions/UI/RectMask2DTweens.cs index f66370f..2f24b22 100644 --- a/Runtime/Extensions/UI/RectMask2DTweens.cs +++ b/Runtime/Extensions/UI/RectMask2DTweens.cs @@ -6,15 +6,12 @@ namespace Zigurous.Tweening public static class RectMask2DTweens { public static Tween TweenPadding(this RectMask2D mask, Vector4 to, float duration) => - Tweening.To(getter: () => mask.padding, - setter: padding => mask.padding = padding, - to, duration).SetTarget(mask); + Tweening.To(mask, (source) => source.padding, (source, value) => source.padding = value, to, duration) + .SetTarget(mask); public static Tween TweenSoftness(this RectMask2D mask, Vector2Int to, float duration) => - Tweening.To(getter: () => mask.softness, - setter: softness => mask.softness = softness, - to, duration).SetTarget(mask); - + Tweening.To(mask, (source) => source.softness, (source, value) => source.softness = value, to, duration) + .SetTarget(mask); } } diff --git a/Runtime/Extensions/UI/RectTransformTweens.cs b/Runtime/Extensions/UI/RectTransformTweens.cs index 3cb1605..3d4b53d 100644 --- a/Runtime/Extensions/UI/RectTransformTweens.cs +++ b/Runtime/Extensions/UI/RectTransformTweens.cs @@ -5,45 +5,36 @@ namespace Zigurous.Tweening public static class RectTransformTweens { public static Tween TweenAnchoredPosition(this RectTransform transform, Vector2 to, float duration) => - Tweening.To(getter: () => transform.anchoredPosition, - setter: anchoredPosition => transform.anchoredPosition = anchoredPosition, - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.anchoredPosition, (source, value) => source.anchoredPosition = value, to, duration) + .SetTarget(transform); public static Tween TweenAnchoredPosition3D(this RectTransform transform, Vector3 to, float duration) => - Tweening.To(getter: () => transform.anchoredPosition3D, - setter: anchoredPosition3D => transform.anchoredPosition3D = anchoredPosition3D, - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.anchoredPosition3D, (source, value) => source.anchoredPosition3D = value, to, duration) + .SetTarget(transform); public static Tween TweenAnchorMin(this RectTransform transform, Vector2 to, float duration) => - Tweening.To(getter: () => transform.anchorMin, - setter: anchorMin => transform.anchorMin = anchorMin, - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.anchorMin, (source, value) => source.anchorMin = value, to, duration) + .SetTarget(transform); public static Tween TweenAnchorMax(this RectTransform transform, Vector2 to, float duration) => - Tweening.To(getter: () => transform.anchorMax, - setter: anchorMax => transform.anchorMax = anchorMax, - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.anchorMax, (source, value) => source.anchorMax = value, to, duration) + .SetTarget(transform); public static Tween TweenOffsetMin(this RectTransform transform, Vector2 to, float duration) => - Tweening.To(getter: () => transform.offsetMin, - setter: offsetMin => transform.offsetMin = offsetMin, - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.offsetMin, (source, value) => source.offsetMin = value, to, duration) + .SetTarget(transform); public static Tween TweenOffsetMax(this RectTransform transform, Vector2 to, float duration) => - Tweening.To(getter: () => transform.offsetMax, - setter: offsetMax => transform.offsetMax = offsetMax, - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.offsetMax, (source, value) => source.offsetMax = value, to, duration) + .SetTarget(transform); public static Tween TweenPivot(this RectTransform transform, Vector2 to, float duration) => - Tweening.To(getter: () => transform.pivot, - setter: pivot => transform.pivot = pivot, - to, duration).SetTarget(transform); + Tweening.To(transform, (source) => source.pivot, (source, value) => source.pivot = value, to, duration) + .SetTarget(transform); public static Tween TweenSizeDelta(this RectTransform transform, Vector2 to, float duration) => - Tweening.To(getter: () => transform.sizeDelta, - setter: sizeDelta => transform.sizeDelta = sizeDelta, - to, duration).SetTarget(transform); - + Tweening.To(transform, (source) => source.sizeDelta, (source, value) => source.sizeDelta = value, to, duration) + .SetTarget(transform); } } diff --git a/Runtime/Extensions/UI/ScrollRectTweens.cs b/Runtime/Extensions/UI/ScrollRectTweens.cs index 27cb7e8..00b8ca0 100644 --- a/Runtime/Extensions/UI/ScrollRectTweens.cs +++ b/Runtime/Extensions/UI/ScrollRectTweens.cs @@ -6,50 +6,40 @@ namespace Zigurous.Tweening public static class ScrollRectTweens { public static Tween TweenElasticity(this ScrollRect scrollRect, float to, float duration) => - Tweening.To(getter: () => scrollRect.elasticity, - setter: elasticity => scrollRect.elasticity = elasticity, - to, duration).SetTarget(scrollRect); + Tweening.To(scrollRect, (source) => source.elasticity, (source, value) => source.elasticity = value, to, duration) + .SetTarget(scrollRect); public static Tween TweenDecelerationRate(this ScrollRect scrollRect, float to, float duration) => - Tweening.To(getter: () => scrollRect.decelerationRate, - setter: decelerationRate => scrollRect.decelerationRate = decelerationRate, - to, duration).SetTarget(scrollRect); + Tweening.To(scrollRect, (source) => source.decelerationRate, (source, value) => source.decelerationRate = value, to, duration) + .SetTarget(scrollRect); public static Tween TweenScrollSensitivity(this ScrollRect scrollRect, float to, float duration) => - Tweening.To(getter: () => scrollRect.scrollSensitivity, - setter: scrollSensitivity => scrollRect.scrollSensitivity = scrollSensitivity, - to, duration).SetTarget(scrollRect); + Tweening.To(scrollRect, (source) => source.scrollSensitivity, (source, value) => source.scrollSensitivity = value, to, duration) + .SetTarget(scrollRect); public static Tween TweenVelocity(this ScrollRect scrollRect, Vector2 to, float duration) => - Tweening.To(getter: () => scrollRect.velocity, - setter: velocity => scrollRect.velocity = velocity, - to, duration).SetTarget(scrollRect); + Tweening.To(scrollRect, (source) => source.velocity, (source, value) => source.velocity = value, to, duration) + .SetTarget(scrollRect); public static Tween TweenNormalizedPosition(this ScrollRect scrollRect, Vector2 to, float duration) => - Tweening.To(getter: () => scrollRect.normalizedPosition, - setter: normalizedPosition => scrollRect.normalizedPosition = normalizedPosition, - to, duration).SetTarget(scrollRect); + Tweening.To(scrollRect, (source) => source.normalizedPosition, (source, value) => source.normalizedPosition = value, to, duration) + .SetTarget(scrollRect); public static Tween TweenHorizontalNormalizedPosition(this ScrollRect scrollRect, float to, float duration) => - Tweening.To(getter: () => scrollRect.horizontalNormalizedPosition, - setter: position => scrollRect.horizontalNormalizedPosition = position, - to, duration).SetTarget(scrollRect); + Tweening.To(scrollRect, (source) => source.horizontalNormalizedPosition, (source, value) => source.horizontalNormalizedPosition = value, to, duration) + .SetTarget(scrollRect); public static Tween TweenVerticalNormalizedPosition(this ScrollRect scrollRect, float to, float duration) => - Tweening.To(getter: () => scrollRect.verticalNormalizedPosition, - setter: position => scrollRect.verticalNormalizedPosition = position, - to, duration).SetTarget(scrollRect); + Tweening.To(scrollRect, (source) => source.verticalNormalizedPosition, (source, value) => source.verticalNormalizedPosition = value, to, duration) + .SetTarget(scrollRect); public static Tween TweenHorizontalScrollbarSpacing(this ScrollRect scrollRect, float to, float duration) => - Tweening.To(getter: () => scrollRect.horizontalScrollbarSpacing, - setter: spacing => scrollRect.horizontalScrollbarSpacing = spacing, - to, duration).SetTarget(scrollRect); + Tweening.To(scrollRect, (source) => source.horizontalScrollbarSpacing, (source, value) => source.horizontalScrollbarSpacing = value, to, duration) + .SetTarget(scrollRect); public static Tween TweenVerticalScrollbarSpacing(this ScrollRect scrollRect, float to, float duration) => - Tweening.To(getter: () => scrollRect.verticalScrollbarSpacing, - setter: spacing => scrollRect.verticalScrollbarSpacing = spacing, - to, duration).SetTarget(scrollRect); - + Tweening.To(scrollRect, (source) => source.verticalScrollbarSpacing, (source, value) => source.verticalScrollbarSpacing = value, to, duration) + .SetTarget(scrollRect); } } diff --git a/Runtime/Extensions/UI/ScrollbarTweens.cs b/Runtime/Extensions/UI/ScrollbarTweens.cs index 028a902..09cf474 100644 --- a/Runtime/Extensions/UI/ScrollbarTweens.cs +++ b/Runtime/Extensions/UI/ScrollbarTweens.cs @@ -5,15 +5,12 @@ namespace Zigurous.Tweening public static class ScrollbarTweens { public static Tween TweenValue(this Scrollbar scrollbar, float to, float duration) => - Tweening.To(getter: () => scrollbar.value, - setter: value => scrollbar.value = value, - to, duration).SetTarget(scrollbar); + Tweening.To(scrollbar, (source) => source.value, (source, value) => source.value = value, to, duration) + .SetTarget(scrollbar); public static Tween TweenSize(this Scrollbar scrollbar, float to, float duration) => - Tweening.To(getter: () => scrollbar.size, - setter: size => scrollbar.size = size, - to, duration).SetTarget(scrollbar); - + Tweening.To(scrollbar, (source) => source.size, (source, value) => source.size = value, to, duration) + .SetTarget(scrollbar); } } diff --git a/Runtime/Extensions/UI/ShadowTweens.cs b/Runtime/Extensions/UI/ShadowTweens.cs index 5b2ca7d..c220877 100644 --- a/Runtime/Extensions/UI/ShadowTweens.cs +++ b/Runtime/Extensions/UI/ShadowTweens.cs @@ -6,20 +6,16 @@ namespace Zigurous.Tweening public static class ShadowTweens { public static Tween TweenColor(this Shadow shadow, Color to, float duration) => - Tweening.To(getter: () => shadow.effectColor, - setter: effectColor => shadow.effectColor = effectColor, - to, duration).SetTarget(shadow); + Tweening.To(shadow, (source) => source.effectColor, (source, value) => source.effectColor = value, to, duration) + .SetTarget(shadow); public static Tween TweenAlpha(this Shadow shadow, float to, float duration) => - Tweening.To(getter: () => shadow.effectColor.a, - setter: alpha => shadow.effectColor = new Color(shadow.effectColor.r, shadow.effectColor.g, shadow.effectColor.b, alpha), - to, duration).SetTarget(shadow); + Tweening.To(shadow, (source) => source.effectColor.a, (source, value) => source.effectColor = new Color(source.effectColor.r, source.effectColor.g, source.effectColor.b, value), to, duration) + .SetTarget(shadow); public static Tween TweenDistance(this Shadow shadow, Vector2 to, float duration) => - Tweening.To(getter: () => shadow.effectDistance, - setter: effectDistance => shadow.effectDistance = effectDistance, - to, duration).SetTarget(shadow); - + Tweening.To(shadow, (source) => source.effectDistance, (source, value) => source.effectDistance = value, to, duration) + .SetTarget(shadow); } } diff --git a/Runtime/Extensions/UI/SliderTweens.cs b/Runtime/Extensions/UI/SliderTweens.cs index 5c99549..e690d88 100644 --- a/Runtime/Extensions/UI/SliderTweens.cs +++ b/Runtime/Extensions/UI/SliderTweens.cs @@ -5,25 +5,20 @@ namespace Zigurous.Tweening public static class SliderTweens { public static Tween TweenValue(this Slider slider, float to, float duration) => - Tweening.To(getter: () => slider.value, - setter: value => slider.value = value, - to, duration).SetTarget(slider); + Tweening.To(slider, (source) => source.value, (source, value) => source.value = value, to, duration) + .SetTarget(slider); public static Tween TweenNormalizedValue(this Slider slider, float to, float duration) => - Tweening.To(getter: () => slider.normalizedValue, - setter: normalizedValue => slider.normalizedValue = normalizedValue, - to, duration).SetTarget(slider); + Tweening.To(slider, (source) => source.normalizedValue, (source, value) => source.normalizedValue = value, to, duration) + .SetTarget(slider); public static Tween TweenMinValue(this Slider slider, float to, float duration) => - Tweening.To(getter: () => slider.minValue, - setter: minValue => slider.minValue = minValue, - to, duration).SetTarget(slider); + Tweening.To(slider, (source) => source.minValue, (source, value) => source.minValue = value, to, duration) + .SetTarget(slider); public static Tween TweenMaxValue(this Slider slider, float to, float duration) => - Tweening.To(getter: () => slider.maxValue, - setter: maxValue => slider.maxValue = maxValue, - to, duration).SetTarget(slider); - + Tweening.To(slider, (source) => source.maxValue, (source, value) => source.maxValue = value, to, duration) + .SetTarget(slider); } } diff --git a/Runtime/Extensions/UI/TextMeshTweens.cs b/Runtime/Extensions/UI/TextMeshTweens.cs index 03c5acc..f22b778 100644 --- a/Runtime/Extensions/UI/TextMeshTweens.cs +++ b/Runtime/Extensions/UI/TextMeshTweens.cs @@ -5,40 +5,32 @@ namespace Zigurous.Tweening public static class TextMeshTweens { public static Tween TweenColor(this TextMesh textMesh, Color to, float duration) => - Tweening.To(getter: () => textMesh.color, - setter: color => textMesh.color = color, - to, duration).SetTarget(textMesh); + Tweening.To(textMesh, (source) => source.color, (source, value) => source.color = value, to, duration) + .SetTarget(textMesh); public static Tween TweenAlpha(this TextMesh textMesh, float to, float duration) => - Tweening.To(getter: () => textMesh.color.a, - setter: alpha => textMesh.color = new Color(textMesh.color.r, textMesh.color.g, textMesh.color.b, alpha), - to, duration).SetTarget(textMesh); + Tweening.To(textMesh, (source) => source.color.a, (source, value) => source.color = new Color(source.color.r, source.color.g, source.color.b, value), to, duration) + .SetTarget(textMesh); public static Tween TweenFontSize(this TextMesh textMesh, int to, float duration) => - Tweening.To(getter: () => textMesh.fontSize, - setter: fontSize => textMesh.fontSize = fontSize, - to, duration).SetTarget(textMesh); + Tweening.To(textMesh, (source) => source.fontSize, (source, value) => source.fontSize = value, to, duration) + .SetTarget(textMesh); public static Tween TweenOffsetZ(this TextMesh textMesh, float to, float duration) => - Tweening.To(getter: () => textMesh.offsetZ, - setter: offsetZ => textMesh.offsetZ = offsetZ, - to, duration).SetTarget(textMesh); + Tweening.To(textMesh, (source) => source.offsetZ, (source, value) => source.offsetZ = value, to, duration) + .SetTarget(textMesh); public static Tween TweenCharacterSize(this TextMesh textMesh, float to, float duration) => - Tweening.To(getter: () => textMesh.characterSize, - setter: characterSize => textMesh.characterSize = characterSize, - to, duration).SetTarget(textMesh); + Tweening.To(textMesh, (source) => source.characterSize, (source, value) => source.characterSize = value, to, duration) + .SetTarget(textMesh); public static Tween TweenLineSpacing(this TextMesh textMesh, float to, float duration) => - Tweening.To(getter: () => textMesh.lineSpacing, - setter: lineSpacing => textMesh.lineSpacing = lineSpacing, - to, duration).SetTarget(textMesh); + Tweening.To(textMesh, (source) => source.lineSpacing, (source, value) => source.lineSpacing = value, to, duration) + .SetTarget(textMesh); public static Tween TweenTabSize(this TextMesh textMesh, float to, float duration) => - Tweening.To(getter: () => textMesh.tabSize, - setter: tabSize => textMesh.tabSize = tabSize, - to, duration).SetTarget(textMesh); - + Tweening.To(textMesh, (source) => source.tabSize, (source, value) => source.tabSize = value, to, duration) + .SetTarget(textMesh); } } diff --git a/Runtime/Extensions/UI/TextTweens.cs b/Runtime/Extensions/UI/TextTweens.cs index bb4a1a9..9474577 100644 --- a/Runtime/Extensions/UI/TextTweens.cs +++ b/Runtime/Extensions/UI/TextTweens.cs @@ -5,10 +5,8 @@ namespace Zigurous.Tweening public static class TextTweens { public static Tween TweenFontSize(this Text text, int to, float duration) => - Tweening.To(getter: () => text.fontSize, - setter: fontSize => text.fontSize = fontSize, - to, duration).SetTarget(text); - + Tweening.To(text, (source) => source.fontSize, (source, value) => source.fontSize = value, to, duration) + .SetTarget(text); } } diff --git a/Runtime/Interpolation.cs b/Runtime/Interpolation.cs index 93c17fd..5cbb047 100644 --- a/Runtime/Interpolation.cs +++ b/Runtime/Interpolation.cs @@ -1,4 +1,4 @@ -using UnityEngine; +using UnityEngine; namespace Zigurous.Tweening { @@ -7,6 +7,20 @@ namespace Zigurous.Tweening /// public static class Interpolation { + internal static readonly Interpolater _float = Lerp; + internal static readonly Interpolater _double = Lerp; + internal static readonly Interpolater _int = Lerp; + internal static readonly Interpolater _long = Lerp; + internal static readonly Interpolater _short = Lerp; + internal static readonly Interpolater _Vector2 = Lerp; + internal static readonly Interpolater _Vector2Int = Lerp; + internal static readonly Interpolater _Vector3 = Lerp; + internal static readonly Interpolater _Vector3Int = Lerp; + internal static readonly Interpolater _Vector4 = Lerp; + internal static readonly Interpolater _Quaternion = Lerp; + internal static readonly Interpolater _Rect = Lerp; + internal static readonly Interpolater _Color = Lerp; + /// /// Linearly interpolates between and /// by . @@ -197,7 +211,7 @@ public static Color Lerp(Color a, Color b, float t, bool snapping = false) /// The value snapped to the nearest whole number. internal static Vector2 Snap(Vector2 value) { - return new Vector2(Mathf.RoundToInt(value.x), Mathf.RoundToInt(value.y)); + return new Vector2(Mathf.Round(value.x), Mathf.Round(value.y)); } /// @@ -207,7 +221,7 @@ internal static Vector2 Snap(Vector2 value) /// The value snapped to the nearest whole number. internal static Vector3 Snap(Vector3 value) { - return new Vector3(Mathf.RoundToInt(value.x), Mathf.RoundToInt(value.y), Mathf.RoundToInt(value.z)); + return new Vector3(Mathf.Round(value.x), Mathf.Round(value.y), Mathf.Round(value.z)); } /// @@ -217,7 +231,7 @@ internal static Vector3 Snap(Vector3 value) /// The value snapped to the nearest whole number. internal static Vector4 Snap(Vector4 value) { - return new Vector4(Mathf.RoundToInt(value.x), Mathf.RoundToInt(value.y), Mathf.RoundToInt(value.z), Mathf.RoundToInt(value.w)); + return new Vector4(Mathf.Round(value.x), Mathf.Round(value.y), Mathf.Round(value.z), Mathf.Round(value.w)); } /// diff --git a/Runtime/TweenManager.cs b/Runtime/TweenManager.cs index ca02230..435d2cc 100644 --- a/Runtime/TweenManager.cs +++ b/Runtime/TweenManager.cs @@ -114,23 +114,23 @@ private void Update() /// /// Recycles or creates a new tween object. /// - internal Tweener BuildTweener() + internal Tweener BuildTweener() { - Tweener tweener = null; + Tweener tweener = null; foreach (Tween tween in tweens) { if (tween.internalState == InternalTweenState.Recycled && tween.type == TweenType.Tweener && - tween.template == typeof(T)) + tween.template == typeof(Tweener)) { - tweener = (Tweener)tween; + tweener = (Tweener)tween; break; } } if (tweener == null) { - tweener = new Tweener(); + tweener = new Tweener(); } else { tweener.Reset(); } diff --git a/Runtime/Tweener.cs b/Runtime/Tweener.cs index 2565eb8..fbc0b55 100644 --- a/Runtime/Tweener.cs +++ b/Runtime/Tweener.cs @@ -1,12 +1,18 @@ namespace Zigurous.Tweening { /// - /// A tween that animates a parameter over time from a start value to an end - /// value. + /// A tween that animates a parameter over time on a source object from a + /// start value to an end value. /// - /// The type of the parameter to tween. - public class Tweener : Tween + /// The type of object to tween. + /// The type of parameter to tween. + public class Tweener : Tween { + /// + /// The source object being tweened. + /// + public S source; + /// /// The function that interpolates values between the tween's start and /// end value. @@ -17,12 +23,12 @@ public class Tweener : Tween /// The function that gets the current value of the parameter being /// tweened. /// - public TweenGetter getter; + public TweenGetter getter; /// /// The function that sets a new value of the parameter being tweened. /// - public TweenSetter setter; + public TweenSetter setter; /// /// The initial value of the parameter at the start of the tween. @@ -40,7 +46,7 @@ public class Tweener : Tween public Tweener() : base() { type = TweenType.Tweener; - template = typeof(T); + template = typeof(Tweener); } /// @@ -57,20 +63,21 @@ public override void Animate() } float time = EaseFunction.lookup[ease](percent); - setter(interpolater(startValue, endValue, time, snapping)); + setter(source, interpolater(startValue, endValue, time, snapping)); } /// protected override void OnStart() { if (iterations == 0 && getter != null) { - startValue = getter(); + startValue = getter(source); } } /// protected override void OnKill() { + source = default(S); interpolater = null; getter = null; setter = null; @@ -79,6 +86,7 @@ protected override void OnKill() /// protected override void OnReset() { + source = default(S); interpolater = null; getter = null; setter = null; diff --git a/Runtime/Tweening.cs b/Runtime/Tweening.cs index d73917b..0dc87db 100644 --- a/Runtime/Tweening.cs +++ b/Runtime/Tweening.cs @@ -53,164 +53,191 @@ public static int activeCount /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(TweenGetter getter, TweenSetter setter, float endValue, float duration) => - To(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween To(S source, TweenGetter getter, TweenSetter setter, float endValue, float duration) => + To(Interpolation._float, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(TweenGetter getter, TweenSetter setter, double endValue, float duration) => - To(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween To(S source, TweenGetter getter, TweenSetter setter, double endValue, float duration) => + To(Interpolation._double, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(TweenGetter getter, TweenSetter setter, long endValue, float duration) => - To(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween To(S source, TweenGetter getter, TweenSetter setter, int endValue, float duration) => + To(Interpolation._int, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(TweenGetter getter, TweenSetter setter, int endValue, float duration) => - To(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween To(S source, TweenGetter getter, TweenSetter setter, long endValue, float duration) => + To(Interpolation._long, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(TweenGetter getter, TweenSetter setter, Vector2 endValue, float duration) => - To(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween To(S source, TweenGetter getter, TweenSetter setter, Vector2 endValue, float duration) => + To(Interpolation._Vector2, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(TweenGetter getter, TweenSetter setter, Vector2Int endValue, float duration) => - To(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween To(S source, TweenGetter getter, TweenSetter setter, Vector2Int endValue, float duration) => + To(Interpolation._Vector2Int, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(TweenGetter getter, TweenSetter setter, Vector3 endValue, float duration) => - To(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween To(S source, TweenGetter getter, TweenSetter setter, Vector3 endValue, float duration) => + To(Interpolation._Vector3, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(TweenGetter getter, TweenSetter setter, Vector3Int endValue, float duration) => - To(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween To(S source, TweenGetter getter, TweenSetter setter, Vector3Int endValue, float duration) => + To(Interpolation._Vector3Int, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(TweenGetter getter, TweenSetter setter, Vector4 endValue, float duration) => - To(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween To(S source, TweenGetter getter, TweenSetter setter, Vector4 endValue, float duration) => + To(Interpolation._Vector4, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(TweenGetter getter, TweenSetter setter, Quaternion endValue, float duration) => - To(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween To(S source, TweenGetter getter, TweenSetter setter, Quaternion endValue, float duration) => + To(Interpolation._Quaternion, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(TweenGetter getter, TweenSetter setter, Rect endValue, float duration) => - To(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween To(S source, TweenGetter getter, TweenSetter setter, Rect endValue, float duration) => + To(Interpolation._Rect, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(TweenGetter getter, TweenSetter setter, Color endValue, float duration) => - To(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween To(S source, TweenGetter getter, TweenSetter setter, Color endValue, float duration) => + To(Interpolation._Color, source, getter, setter, endValue, duration); /// - /// Creates a tween that animates a parameter to a given end value over - /// a set duration. + /// Creates a tween that animates a parameter on a source object to a + /// given end value over a set duration. /// - /// The type of the parameter. + /// The type of object to tween. + /// The type of parameter to tween. /// The function that interpolates values between the start and end value. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(Interpolater interpolater, TweenGetter getter, TweenSetter setter, T endValue, float duration) + public static Tween To(Interpolater interpolater, S source, TweenGetter getter, TweenSetter setter, T endValue, float duration) { if (TweenManager.Unloading) { return null; } - Tweener tween = TweenManager.Instance.BuildTweener(); + Tweener tween = TweenManager.Instance.BuildTweener(); + tween.source = source; tween.interpolater = interpolater; tween.getter = getter; tween.setter = setter; @@ -225,164 +252,191 @@ public static Tween To(Interpolater interpolater, TweenGetter getter, T /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(TweenGetter getter, TweenSetter setter, float endValue, float duration) => - From(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween From(S source, TweenGetter getter, TweenSetter setter, float endValue, float duration) => + From(Interpolation.Lerp, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(TweenGetter getter, TweenSetter setter, double endValue, float duration) => - From(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween From(S source, TweenGetter getter, TweenSetter setter, double endValue, float duration) => + From(Interpolation.Lerp, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(TweenGetter getter, TweenSetter setter, long endValue, float duration) => - From(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween From(S source, TweenGetter getter, TweenSetter setter, int endValue, float duration) => + From(Interpolation.Lerp, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(TweenGetter getter, TweenSetter setter, int endValue, float duration) => - From(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween From(S source, TweenGetter getter, TweenSetter setter, long endValue, float duration) => + From(Interpolation.Lerp, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(TweenGetter getter, TweenSetter setter, Vector2 endValue, float duration) => - From(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween From(S source, TweenGetter getter, TweenSetter setter, Vector2 endValue, float duration) => + From(Interpolation.Lerp, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(TweenGetter getter, TweenSetter setter, Vector2Int endValue, float duration) => - From(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween From(S source, TweenGetter getter, TweenSetter setter, Vector2Int endValue, float duration) => + From(Interpolation.Lerp, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(TweenGetter getter, TweenSetter setter, Vector3 endValue, float duration) => - From(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween From(S source, TweenGetter getter, TweenSetter setter, Vector3 endValue, float duration) => + From(Interpolation.Lerp, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(TweenGetter getter, TweenSetter setter, Vector3Int endValue, float duration) => - From(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween From(S source, TweenGetter getter, TweenSetter setter, Vector3Int endValue, float duration) => + From(Interpolation.Lerp, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(TweenGetter getter, TweenSetter setter, Vector4 endValue, float duration) => - From(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween From(S source, TweenGetter getter, TweenSetter setter, Vector4 endValue, float duration) => + From(Interpolation.Lerp, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(TweenGetter getter, TweenSetter setter, Quaternion endValue, float duration) => - From(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween From(S source, TweenGetter getter, TweenSetter setter, Quaternion endValue, float duration) => + From(Interpolation.Lerp, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(TweenGetter getter, TweenSetter setter, Rect endValue, float duration) => - From(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween From(S source, TweenGetter getter, TweenSetter setter, Rect endValue, float duration) => + From(Interpolation.Lerp, source, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// + /// The type of object to tween. + /// The source object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(TweenGetter getter, TweenSetter setter, Color endValue, float duration) => - From(Interpolation.Lerp, getter, setter, endValue, duration); + public static Tween From(S source, TweenGetter getter, TweenSetter setter, Color endValue, float duration) => + From(Interpolation.Lerp, source, getter, setter, endValue, duration); /// - /// Creates a tween that animates a parameter from a given end value to - /// the current value over a set duration. + /// Creates a tween that animates a parameter on a source object from a + /// given end value to the current value over a set duration. /// - /// The type of the parameter. + /// The type of object to tween. + /// The type of parameter to tween. + /// The source object to tween. /// The function that interpolates values between the start and end value. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(Interpolater interpolater, TweenGetter getter, TweenSetter setter, T endValue, float duration) + public static Tween From(Interpolater interpolater, S source, TweenGetter getter, TweenSetter setter, T endValue, float duration) { if (TweenManager.Unloading) { return null; } - Tweener tween = TweenManager.Instance.BuildTweener(); + Tweener tween = TweenManager.Instance.BuildTweener(); + tween.source = source; tween.interpolater = interpolater; tween.getter = getter; tween.setter = setter; From 822ec3d545d724fe6ea35e3b754c210223ff422d Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Mon, 26 Jun 2023 17:37:30 -0500 Subject: [PATCH 05/19] Add support for short values --- Documentation~/articles/supported-types.md | 3 ++- Runtime/Interpolation.cs | 15 ++++++++++-- Runtime/Tweening.cs | 28 ++++++++++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/Documentation~/articles/supported-types.md b/Documentation~/articles/supported-types.md index 6b271a0..28152bf 100644 --- a/Documentation~/articles/supported-types.md +++ b/Documentation~/articles/supported-types.md @@ -10,8 +10,9 @@ When creating tweens using the generic functions, the following types of values - `float` - `double` -- `long` - `int` +- `long` +- `short` - `Vector2` - `Vector2Int` - `Vector3` diff --git a/Runtime/Interpolation.cs b/Runtime/Interpolation.cs index 5cbb047..93fd470 100644 --- a/Runtime/Interpolation.cs +++ b/Runtime/Interpolation.cs @@ -76,8 +76,19 @@ public static int Lerp(int a, int b, float t, bool snapping = false) /// The interpolated value between the start and end value. public static long Lerp(long a, long b, float t, bool snapping = false) { - long value = (long)Mathf.Lerp(a, b, t); - return snapping ? (int)value : value; + + /// + /// Linearly interpolates between and + /// by . + /// + /// The start value. + /// The end value. + /// The interpolation value between the start and end value. + /// Snaps the interpolated value to the nearest whole number. + /// The interpolated value between the start and end value. + public static short Lerp(short a, short b, float t, bool snapping = false) + { + return (short)Mathf.Lerp(a, b, t); } /// diff --git a/Runtime/Tweening.cs b/Runtime/Tweening.cs index 0dc87db..7326506 100644 --- a/Runtime/Tweening.cs +++ b/Runtime/Tweening.cs @@ -105,6 +105,20 @@ public static Tween To(S source, TweenGetter getter, TweenSetter(S source, TweenGetter getter, TweenSetter setter, long endValue, float duration) => To(Interpolation._long, source, getter, setter, endValue, duration); + /// + /// Creates a tween that animates a parameter to a given end value over + /// a set duration. + /// + /// The type of object to tween. + /// The source object to tween. + /// The function that gets the current value of the parameter. + /// The function that sets a new value of the parameter. + /// The end value of the parameter. + /// The duration of the tween. + /// A new tween that animates the parameter. + public static Tween To(S source, TweenGetter getter, TweenSetter setter, short endValue, float duration) => + To(Interpolation._short, source, getter, setter, endValue, duration); + /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. @@ -304,6 +318,20 @@ public static Tween From(S source, TweenGetter getter, TweenSetter(S source, TweenGetter getter, TweenSetter setter, long endValue, float duration) => From(Interpolation.Lerp, source, getter, setter, endValue, duration); + /// + /// Creates a tween that animates a parameter from a given end value to + /// the current value over a set duration. + /// + /// The type of object to tween. + /// The source object to tween. + /// The function that gets the current value of the parameter. + /// The function that sets a new value of the parameter. + /// The end value of the parameter. + /// The duration of the tween. + /// A new tween that animates the parameter. + public static Tween From(S source, TweenGetter getter, TweenSetter setter, short endValue, float duration) => + From(Interpolation.Lerp, source, getter, setter, endValue, duration); + /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. From 700d8b3faf668d01a13c2dcd3c0819ab133c6989 Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Mon, 26 Jun 2023 17:42:27 -0500 Subject: [PATCH 06/19] Fix interpolation snapping always rounding down --- Runtime/Interpolation.cs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Runtime/Interpolation.cs b/Runtime/Interpolation.cs index 93fd470..7afd4b4 100644 --- a/Runtime/Interpolation.cs +++ b/Runtime/Interpolation.cs @@ -1,4 +1,4 @@ -using UnityEngine; +using UnityEngine; namespace Zigurous.Tweening { @@ -32,8 +32,8 @@ public static class Interpolation /// The interpolated value between the start and end value. public static float Lerp(float a, float b, float t, bool snapping = false) { - float value = Mathf.Lerp(a, b, t); - return snapping ? (int)value : value; + float value = a + (b - a) * t; + return snapping ? Mathf.Round(value) : value; } /// @@ -47,8 +47,8 @@ public static float Lerp(float a, float b, float t, bool snapping = false) /// The interpolated value between the start and end value. public static double Lerp(double a, double b, float t, bool snapping = false) { - double value = Mathf.Lerp((float)a, (float)b, t); - return snapping ? (int)value : value; + double value = a + (b - a) * t; + return snapping ? System.Math.Round(value) : value; } /// @@ -62,7 +62,7 @@ public static double Lerp(double a, double b, float t, bool snapping = false) /// The interpolated value between the start and end value. public static int Lerp(int a, int b, float t, bool snapping = false) { - return (int)Mathf.Lerp(a, b, t); + return (int)Lerp((float)a, (float)b, t, snapping); } /// @@ -76,6 +76,8 @@ public static int Lerp(int a, int b, float t, bool snapping = false) /// The interpolated value between the start and end value. public static long Lerp(long a, long b, float t, bool snapping = false) { + return (long)Lerp((double)a, (double)b, t, snapping); + } /// /// Linearly interpolates between and @@ -88,7 +90,7 @@ public static long Lerp(long a, long b, float t, bool snapping = false) /// The interpolated value between the start and end value. public static short Lerp(short a, short b, float t, bool snapping = false) { - return (short)Mathf.Lerp(a, b, t); + return (short)Lerp((float)a, (float)b, t, snapping); } /// @@ -118,8 +120,8 @@ public static Vector2 Lerp(Vector2 a, Vector2 b, float t, bool snapping = false) public static Vector2Int Lerp(Vector2Int a, Vector2Int b, float t, bool snapping = false) { return new Vector2Int( - (int)Mathf.Lerp(a.x, b.x, t), - (int)Mathf.Lerp(a.y, b.y, t)); + Lerp(a.x, b.x, t, snapping), + Lerp(a.y, b.y, t, snapping)); } /// @@ -149,9 +151,9 @@ public static Vector3 Lerp(Vector3 a, Vector3 b, float t, bool snapping = false) public static Vector3Int Lerp(Vector3Int a, Vector3Int b, float t, bool snapping = false) { return new Vector3Int( - (int)Mathf.Lerp(a.x, b.x, t), - (int)Mathf.Lerp(a.y, b.y, t), - (int)Mathf.Lerp(a.z, b.z, t)); + Lerp(a.x, b.x, t, snapping), + Lerp(a.y, b.y, t, snapping), + Lerp(a.z, b.z, t, snapping)); } /// From fbbab11beee7af0fe4e518f83fabaec9f0e3efe0 Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Mon, 26 Jun 2023 17:42:36 -0500 Subject: [PATCH 07/19] Reset scene index to -1 --- Runtime/Tween.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Runtime/Tween.cs b/Runtime/Tween.cs index 58eda5e..3fad86e 100644 --- a/Runtime/Tween.cs +++ b/Runtime/Tween.cs @@ -1,6 +1,4 @@ -using UnityEngine.SceneManagement; - -namespace Zigurous.Tweening +namespace Zigurous.Tweening { /// /// The base class of every tween. @@ -450,7 +448,7 @@ public void Restart() internal void Reset() { id = -1; - sceneIndex = SceneManager.GetActiveScene().buildIndex; + sceneIndex = -1; state = TweenState.Ready; internalState = InternalTweenState.Queued; From afa744aa098ddddc05d538ef52ea78d311e12be3 Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Sat, 21 Oct 2023 18:56:29 -0500 Subject: [PATCH 08/19] Add color extension utility functions --- Runtime/ColorExtensions.cs | 56 +++++++++++++++++++++++++++++++++ Runtime/ColorExtensions.cs.meta | 11 +++++++ 2 files changed, 67 insertions(+) create mode 100644 Runtime/ColorExtensions.cs create mode 100644 Runtime/ColorExtensions.cs.meta diff --git a/Runtime/ColorExtensions.cs b/Runtime/ColorExtensions.cs new file mode 100644 index 0000000..d822b57 --- /dev/null +++ b/Runtime/ColorExtensions.cs @@ -0,0 +1,56 @@ +using UnityEngine; + +namespace Zigurous.Tweening +{ + /// + /// Utility extension methods for colors. + /// + internal static class ColorExtensions + { + /// + /// Returns a copy of the color with the red component changed. + /// + /// The color to change. + /// The new red component. + /// A copy of the color with the red component changed. + public static Color WithRed(this Color color, float red) + { + return new Color(red, color.g, color.b, color.a); + } + + /// + /// Returns a copy of the color with the green component changed. + /// + /// The color to change. + /// The new green component. + /// A copy of the color with the green component changed. + public static Color WithGreen(this Color color, float green) + { + return new Color(color.r, green, color.b, color.a); + } + + /// + /// Returns a copy of the color with the blue component changed. + /// + /// The color to change. + /// The new blue component. + /// A copy of the color with the blue component changed. + public static Color WithBlue(this Color color, float blue) + { + return new Color(color.r, color.g, blue, color.a); + } + + /// + /// Returns a copy of the color with the alpha component changed. + /// + /// The color to change. + /// The new alpha component. + /// A copy of the color with the alpha component changed. + public static Color WithAlpha(this Color color, float alpha) + { + return new Color(color.r, color.g, color.b, alpha); + } + + } + +} diff --git a/Runtime/ColorExtensions.cs.meta b/Runtime/ColorExtensions.cs.meta new file mode 100644 index 0000000..b23c7bc --- /dev/null +++ b/Runtime/ColorExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 856265b6de5c23643846b48aee7d1539 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From c5bd8ed69ce860f43365c3e1bae5bd7e63934718 Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Sat, 21 Oct 2023 19:21:38 -0500 Subject: [PATCH 09/19] Refactor extensions to not use closures to reduce GC allocations --- Runtime/Delegates.cs | 25 +- .../Audio/AudioChorusFilterTweens.cs | 28 +- .../Audio/AudioDistortionFilterTweens.cs | 4 +- .../Extensions/Audio/AudioEchoFilterTweens.cs | 16 +- .../Audio/AudioHighPassFilterTweens.cs | 8 +- .../Extensions/Audio/AudioListenerTweens.cs | 2 +- .../Audio/AudioLowPassFilterTweens.cs | 8 +- .../Audio/AudioReverbFilterTweens.cs | 56 ++-- .../Extensions/Audio/AudioReverbZoneTweens.cs | 40 +-- Runtime/Extensions/Audio/AudioSourceTweens.cs | 40 +-- .../Extensions/Misc/AimConstraintTweens.cs | 24 +- Runtime/Extensions/Misc/GridTweens.cs | 8 +- .../Extensions/Misc/LookAtConstraintTweens.cs | 16 +- .../Extensions/Misc/ParentConstraintTweens.cs | 12 +- .../Misc/PositionConstraintTweens.cs | 12 +- Runtime/Extensions/Misc/RectOffsetTweens.cs | 8 +- .../Misc/RotationConstraintTweens.cs | 12 +- .../Extensions/Misc/ScaleConstraintTweens.cs | 12 +- Runtime/Extensions/Misc/TransformTweens.cs | 56 ++-- .../Navigation/NavMeshAgentTweens.cs | 40 +-- .../Navigation/NavMeshObstacleTweens.cs | 20 +- .../Extensions/Physics/BoxColliderTweens.cs | 8 +- .../Physics/CapsuleColliderTweens.cs | 12 +- .../Physics/CharacterControllerTweens.cs | 28 +- .../Physics/CharacterJointTweens.cs | 12 +- Runtime/Extensions/Physics/ClothTweens.cs | 52 ++-- Runtime/Extensions/Physics/ColliderTweens.cs | 4 +- .../Physics/ConfigurableJointTweens.cs | 28 +- .../Extensions/Physics/ConstantForceTweens.cs | 16 +- Runtime/Extensions/Physics/JointTweens.cs | 28 +- .../Physics/PhysicMaterialTweens.cs | 12 +- Runtime/Extensions/Physics/RigidbodyTweens.cs | 52 ++-- .../Physics/SphereColliderTweens.cs | 8 +- .../Extensions/Physics/SpringJointTweens.cs | 20 +- .../Extensions/Physics/WheelColliderTweens.cs | 40 +-- .../Physics2D/AnchoredJoint2DTweens.cs | 8 +- .../Physics2D/AreaEffector2DTweens.cs | 20 +- .../Physics2D/BoxCollider2DTweens.cs | 8 +- .../Physics2D/BuoyancyEffector2DTweens.cs | 28 +- .../Physics2D/CapsuleCollider2DTweens.cs | 4 +- .../Physics2D/CircleCollider2DTweens.cs | 4 +- .../Extensions/Physics2D/Collider2DTweens.cs | 8 +- .../Physics2D/CompositeCollider2DTweens.cs | 12 +- .../Physics2D/ConstantForce2DTweens.cs | 12 +- .../Physics2D/DistanceJoint2DTweens.cs | 4 +- .../Physics2D/EdgeCollider2DTweens.cs | 4 +- .../Physics2D/FixedJoint2DTweens.cs | 8 +- .../Physics2D/FrictionJoint2DTweens.cs | 8 +- Runtime/Extensions/Physics2D/Joint2DTweens.cs | 8 +- .../Physics2D/PhysicsMaterial2DTweens.cs | 8 +- .../Physics2D/PlatformEffector2DTweens.cs | 12 +- .../Physics2D/PointEffector2DTweens.cs | 20 +- .../Physics2D/RelativeJoint2DTweens.cs | 20 +- .../Extensions/Physics2D/Rigidbody2DTweens.cs | 40 +-- .../Physics2D/SliderJoint2DTweens.cs | 4 +- .../Physics2D/SpringJoint2DTweens.cs | 12 +- .../Physics2D/SurfaceEffector2DTweens.cs | 12 +- .../Physics2D/TargetJoint2DTweens.cs | 20 +- .../Extensions/Rendering/AnimatorTweens.cs | 28 +- Runtime/Extensions/Rendering/CameraTweens.cs | 56 ++-- .../Extensions/Rendering/LensFlareTweens.cs | 12 +- Runtime/Extensions/Rendering/LightTweens.cs | 52 ++-- .../Rendering/LineRendererTweens.cs | 24 +- .../Rendering/MaterialPropertyBlockTweens.cs | 72 +++++ .../MaterialPropertyBlockTweens.cs.meta | 11 + .../Extensions/Rendering/MaterialTweens.cs | 100 ++++--- .../Rendering/OcclusionAreaTweens.cs | 8 +- .../ParticleSystemForceFieldTweens.cs | 20 +- .../Rendering/ParticleSystemTweens.cs | 4 +- .../Extensions/Rendering/ProjectorTweens.cs | 20 +- .../Rendering/ReflectionProbeTweens.cs | 32 +-- .../Extensions/Rendering/SpriteMaskTweens.cs | 4 +- .../Rendering/SpriteRendererTweens.cs | 16 +- .../Rendering/SpriteShapeRendererTweens.cs | 8 +- Runtime/Extensions/Rendering/TilemapTweens.cs | 20 +- .../Rendering/TrailRendererTweens.cs | 32 +-- .../Extensions/Rendering/VideoPlayerTweens.cs | 20 +- .../Extensions/Rendering/WindZoneTweens.cs | 20 +- .../Extensions/UI/AspectRatioFitterTweens.cs | 4 +- Runtime/Extensions/UI/CanvasGroupTweens.cs | 4 +- Runtime/Extensions/UI/CanvasScalerTweens.cs | 28 +- Runtime/Extensions/UI/CanvasTweens.cs | 16 +- Runtime/Extensions/UI/GraphicTweens.cs | 8 +- .../Extensions/UI/GridLayoutGroupTweens.cs | 8 +- .../HorizontalOrVerticalLayoutGroupTweens.cs | 4 +- Runtime/Extensions/UI/RectMask2DTweens.cs | 8 +- Runtime/Extensions/UI/RectTransformTweens.cs | 32 +-- Runtime/Extensions/UI/ScrollRectTweens.cs | 36 +-- Runtime/Extensions/UI/ScrollbarTweens.cs | 8 +- Runtime/Extensions/UI/ShadowTweens.cs | 12 +- Runtime/Extensions/UI/SliderTweens.cs | 16 +- Runtime/Extensions/UI/TextMeshTweens.cs | 28 +- Runtime/Extensions/UI/TextTweens.cs | 4 +- Runtime/PropertyChaining.cs | 169 +++++++++--- Runtime/Sequence.cs | 2 +- Runtime/TweenManager.cs | 18 +- Runtime/Tweener.cs | 53 ++-- Runtime/Tweening.cs | 248 +++++++++--------- 98 files changed, 1268 insertions(+), 1048 deletions(-) create mode 100644 Runtime/Extensions/Rendering/MaterialPropertyBlockTweens.cs create mode 100644 Runtime/Extensions/Rendering/MaterialPropertyBlockTweens.cs.meta diff --git a/Runtime/Delegates.cs b/Runtime/Delegates.cs index bf31838..3397bde 100644 --- a/Runtime/Delegates.cs +++ b/Runtime/Delegates.cs @@ -1,28 +1,27 @@ namespace Zigurous.Tweening { /// - /// A function delegate that gets the current value of a parameter from a - /// source object. + /// A function delegate that gets the current value of a parameter from an + /// object. /// - /// The type of the source object. - /// The type of the parameter. - /// The source object to get the value from. + /// The type of object to get the parameter from. + /// The type of the parameter. + /// The object to get the value from. /// The current value of the parameter. - public delegate T TweenGetter(S source); + public delegate U TweenGetter(T target); /// - /// A function delegate that sets a new value of a parameter on a source - /// object. + /// A function delegate that sets a new value of a parameter on an object. /// - /// The type of the source object. - /// The type of the parameter. - /// The source object to set the value on. + /// The type of object to set the parameter on. + /// The type of the parameter. + /// The object to set the value on. /// The new value of the parameter. - public delegate void TweenSetter(S source, T value); + public delegate void TweenSetter(T target, U value); /// /// A function delegate that can be invoked during various tween events - /// and/or state changes. + /// and/or state changes, such as on complete. /// public delegate void TweenCallback(); diff --git a/Runtime/Extensions/Audio/AudioChorusFilterTweens.cs b/Runtime/Extensions/Audio/AudioChorusFilterTweens.cs index 67a9004..33c3cd9 100644 --- a/Runtime/Extensions/Audio/AudioChorusFilterTweens.cs +++ b/Runtime/Extensions/Audio/AudioChorusFilterTweens.cs @@ -5,32 +5,32 @@ namespace Zigurous.Tweening public static class AudioChorusFilterTweens { public static Tween TweenDelay(this AudioChorusFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.delay, (source, value) => source.delay = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.delay, (target, value) => target.delay = value, to, duration) + .SetReference(filter); public static Tween TweenRate(this AudioChorusFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.rate, (source, value) => source.rate = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.rate, (target, value) => target.rate = value, to, duration) + .SetReference(filter); public static Tween TweenDepth(this AudioChorusFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.depth, (source, value) => source.depth = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.depth, (target, value) => target.depth = value, to, duration) + .SetReference(filter); public static Tween TweenDryMix(this AudioChorusFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.dryMix, (source, value) => source.dryMix = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.dryMix, (target, value) => target.dryMix = value, to, duration) + .SetReference(filter); public static Tween TweenWetMix1(this AudioChorusFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.wetMix1, (source, value) => source.wetMix1 = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.wetMix1, (target, value) => target.wetMix1 = value, to, duration) + .SetReference(filter); public static Tween TweenWetMix2(this AudioChorusFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.wetMix2, (source, value) => source.wetMix2 = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.wetMix2, (target, value) => target.wetMix2 = value, to, duration) + .SetReference(filter); public static Tween TweenWetMix3(this AudioChorusFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.wetMix3, (source, value) => source.wetMix3 = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.wetMix3, (target, value) => target.wetMix3 = value, to, duration) + .SetReference(filter); } } diff --git a/Runtime/Extensions/Audio/AudioDistortionFilterTweens.cs b/Runtime/Extensions/Audio/AudioDistortionFilterTweens.cs index 514bb4c..2aaf0d6 100644 --- a/Runtime/Extensions/Audio/AudioDistortionFilterTweens.cs +++ b/Runtime/Extensions/Audio/AudioDistortionFilterTweens.cs @@ -5,8 +5,8 @@ namespace Zigurous.Tweening public static class AudioDistortionFilterTweens { public static Tween TweenDistortionLevel(this AudioDistortionFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.distortionLevel, (source, value) => source.distortionLevel = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.distortionLevel, (target, value) => target.distortionLevel = value, to, duration) + .SetReference(filter); } } diff --git a/Runtime/Extensions/Audio/AudioEchoFilterTweens.cs b/Runtime/Extensions/Audio/AudioEchoFilterTweens.cs index e489686..d83c3d7 100644 --- a/Runtime/Extensions/Audio/AudioEchoFilterTweens.cs +++ b/Runtime/Extensions/Audio/AudioEchoFilterTweens.cs @@ -5,20 +5,20 @@ namespace Zigurous.Tweening public static class AudioEchoFilterTweens { public static Tween TweenDelay(this AudioEchoFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.delay, (source, value) => source.delay = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.delay, (target, value) => target.delay = value, to, duration) + .SetReference(filter); public static Tween TweenDecayRatio(this AudioEchoFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.decayRatio, (source, value) => source.decayRatio = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.decayRatio, (target, value) => target.decayRatio = value, to, duration) + .SetReference(filter); public static Tween TweenDryMix(this AudioEchoFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.dryMix, (source, value) => source.dryMix = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.dryMix, (target, value) => target.dryMix = value, to, duration) + .SetReference(filter); public static Tween TweenWetMix(this AudioEchoFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.wetMix, (source, value) => source.wetMix = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.wetMix, (target, value) => target.wetMix = value, to, duration) + .SetReference(filter); } } diff --git a/Runtime/Extensions/Audio/AudioHighPassFilterTweens.cs b/Runtime/Extensions/Audio/AudioHighPassFilterTweens.cs index af6844c..c4f6154 100644 --- a/Runtime/Extensions/Audio/AudioHighPassFilterTweens.cs +++ b/Runtime/Extensions/Audio/AudioHighPassFilterTweens.cs @@ -5,12 +5,12 @@ namespace Zigurous.Tweening public static class AudioHighPassFilterTweens { public static Tween TweenCutoffFrequency(this AudioHighPassFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.cutoffFrequency, (source, value) => source.cutoffFrequency = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.cutoffFrequency, (target, value) => target.cutoffFrequency = value, to, duration) + .SetReference(filter); public static Tween TweenHighpassResonanceQ(this AudioHighPassFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.highpassResonanceQ, (source, value) => source.highpassResonanceQ = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.highpassResonanceQ, (target, value) => target.highpassResonanceQ = value, to, duration) + .SetReference(filter); } } diff --git a/Runtime/Extensions/Audio/AudioListenerTweens.cs b/Runtime/Extensions/Audio/AudioListenerTweens.cs index 5fd6a44..2adafcf 100644 --- a/Runtime/Extensions/Audio/AudioListenerTweens.cs +++ b/Runtime/Extensions/Audio/AudioListenerTweens.cs @@ -6,7 +6,7 @@ public static class AudioListenerTweens { public static Tween TweenVolume(this AudioListener listener, float to, float duration) => Tweening.To(listener, (source) => AudioListener.volume, (source, value) => AudioListener.volume = value, to, duration) - .SetTarget(listener); + .SetReference(listener); } } diff --git a/Runtime/Extensions/Audio/AudioLowPassFilterTweens.cs b/Runtime/Extensions/Audio/AudioLowPassFilterTweens.cs index a790d99..d959dac 100644 --- a/Runtime/Extensions/Audio/AudioLowPassFilterTweens.cs +++ b/Runtime/Extensions/Audio/AudioLowPassFilterTweens.cs @@ -5,12 +5,12 @@ namespace Zigurous.Tweening public static class AudioLowPassFilterTweens { public static Tween TweenCutoffFrequency(this AudioLowPassFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.cutoffFrequency, (source, value) => source.cutoffFrequency = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.cutoffFrequency, (target, value) => target.cutoffFrequency = value, to, duration) + .SetReference(filter); public static Tween TweenLowpassResonanceQ(this AudioLowPassFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.lowpassResonanceQ, (source, value) => source.lowpassResonanceQ = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.lowpassResonanceQ, (target, value) => target.lowpassResonanceQ = value, to, duration) + .SetReference(filter); } } diff --git a/Runtime/Extensions/Audio/AudioReverbFilterTweens.cs b/Runtime/Extensions/Audio/AudioReverbFilterTweens.cs index 817e076..1e9531e 100644 --- a/Runtime/Extensions/Audio/AudioReverbFilterTweens.cs +++ b/Runtime/Extensions/Audio/AudioReverbFilterTweens.cs @@ -5,60 +5,60 @@ namespace Zigurous.Tweening public static class AudioReverbFilterTweens { public static Tween TweenDensity(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.density, (source, value) => source.density = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.density, (target, value) => target.density = value, to, duration) + .SetReference(filter); public static Tween TweenDiffusion(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.diffusion, (source, value) => source.diffusion = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.diffusion, (target, value) => target.diffusion = value, to, duration) + .SetReference(filter); public static Tween TweenReverbDelay(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.reverbDelay, (source, value) => source.reverbDelay = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.reverbDelay, (target, value) => target.reverbDelay = value, to, duration) + .SetReference(filter); public static Tween TweenReverbLevel(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.reverbLevel, (source, value) => source.reverbLevel = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.reverbLevel, (target, value) => target.reverbLevel = value, to, duration) + .SetReference(filter); public static Tween TweenReflectionsDelay(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.reflectionsDelay, (source, value) => source.reflectionsDelay = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.reflectionsDelay, (target, value) => target.reflectionsDelay = value, to, duration) + .SetReference(filter); public static Tween TweenReflectionsLevel(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.reflectionsLevel, (source, value) => source.reflectionsLevel = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.reflectionsLevel, (target, value) => target.reflectionsLevel = value, to, duration) + .SetReference(filter); public static Tween TweenDecayHFRatio(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.decayHFRatio, (source, value) => source.decayHFRatio = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.decayHFRatio, (target, value) => target.decayHFRatio = value, to, duration) + .SetReference(filter); public static Tween TweenDecayTime(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.decayTime, (source, value) => source.decayTime = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.decayTime, (target, value) => target.decayTime = value, to, duration) + .SetReference(filter); public static Tween TweenRoom(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.room, (source, value) => source.room = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.room, (target, value) => target.room = value, to, duration) + .SetReference(filter); public static Tween TweenRoomHF(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.roomHF, (source, value) => source.roomHF = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.roomHF, (target, value) => target.roomHF = value, to, duration) + .SetReference(filter); public static Tween TweenRoomLF(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.roomLF, (source, value) => source.roomLF = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.roomLF, (target, value) => target.roomLF = value, to, duration) + .SetReference(filter); public static Tween TweenDryLevel(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.dryLevel, (source, value) => source.dryLevel = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.dryLevel, (target, value) => target.dryLevel = value, to, duration) + .SetReference(filter); public static Tween TweenHFReference(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.hfReference, (source, value) => source.hfReference = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.hfReference, (target, value) => target.hfReference = value, to, duration) + .SetReference(filter); public static Tween TweenLFReference(this AudioReverbFilter filter, float to, float duration) => - Tweening.To(filter, (source) => source.lfReference, (source, value) => source.lfReference = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.lfReference, (target, value) => target.lfReference = value, to, duration) + .SetReference(filter); } } diff --git a/Runtime/Extensions/Audio/AudioReverbZoneTweens.cs b/Runtime/Extensions/Audio/AudioReverbZoneTweens.cs index 251b8d0..d3ede30 100644 --- a/Runtime/Extensions/Audio/AudioReverbZoneTweens.cs +++ b/Runtime/Extensions/Audio/AudioReverbZoneTweens.cs @@ -5,44 +5,44 @@ namespace Zigurous.Tweening public static class AudioReverbZoneTweens { public static Tween TweenMaxDistance(this AudioReverbZone filter, float to, float duration) => - Tweening.To(filter, (source) => source.maxDistance, (source, value) => source.maxDistance = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.maxDistance, (target, value) => target.maxDistance = value, to, duration) + .SetReference(filter); public static Tween TweenMinDistance(this AudioReverbZone filter, float to, float duration) => - Tweening.To(filter, (source) => source.minDistance, (source, value) => source.minDistance = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.minDistance, (target, value) => target.minDistance = value, to, duration) + .SetReference(filter); public static Tween TweenDiffusion(this AudioReverbZone filter, float to, float duration) => - Tweening.To(filter, (source) => source.diffusion, (source, value) => source.diffusion = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.diffusion, (target, value) => target.diffusion = value, to, duration) + .SetReference(filter); public static Tween TweenDensity(this AudioReverbZone filter, float to, float duration) => - Tweening.To(filter, (source) => source.density, (source, value) => source.density = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.density, (target, value) => target.density = value, to, duration) + .SetReference(filter); public static Tween TweenReverbDelay(this AudioReverbZone filter, float to, float duration) => - Tweening.To(filter, (source) => source.reverbDelay, (source, value) => source.reverbDelay = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.reverbDelay, (target, value) => target.reverbDelay = value, to, duration) + .SetReference(filter); public static Tween TweenReflectionsDelay(this AudioReverbZone filter, float to, float duration) => - Tweening.To(filter, (source) => source.reflectionsDelay, (source, value) => source.reflectionsDelay = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.reflectionsDelay, (target, value) => target.reflectionsDelay = value, to, duration) + .SetReference(filter); public static Tween TweenDecayHFRatio(this AudioReverbZone filter, float to, float duration) => - Tweening.To(filter, (source) => source.decayHFRatio, (source, value) => source.decayHFRatio = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.decayHFRatio, (target, value) => target.decayHFRatio = value, to, duration) + .SetReference(filter); public static Tween TweenDecayTime(this AudioReverbZone filter, float to, float duration) => - Tweening.To(filter, (source) => source.decayTime, (source, value) => source.decayTime = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.decayTime, (target, value) => target.decayTime = value, to, duration) + .SetReference(filter); public static Tween TweenHFReference(this AudioReverbZone filter, float to, float duration) => - Tweening.To(filter, (source) => source.HFReference, (source, value) => source.HFReference = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.HFReference, (target, value) => target.HFReference = value, to, duration) + .SetReference(filter); public static Tween TweenLFReference(this AudioReverbZone filter, float to, float duration) => - Tweening.To(filter, (source) => source.LFReference, (source, value) => source.LFReference = value, to, duration) - .SetTarget(filter); + Tweening.To(filter, (target) => target.LFReference, (target, value) => target.LFReference = value, to, duration) + .SetReference(filter); } } diff --git a/Runtime/Extensions/Audio/AudioSourceTweens.cs b/Runtime/Extensions/Audio/AudioSourceTweens.cs index 0116e97..58c1344 100644 --- a/Runtime/Extensions/Audio/AudioSourceTweens.cs +++ b/Runtime/Extensions/Audio/AudioSourceTweens.cs @@ -5,44 +5,44 @@ namespace Zigurous.Tweening public static class AudioSourceTweens { public static Tween TweenTime(this AudioSource audioSource, float to, float duration) => - Tweening.To(audioSource, (source) => source.time, (source, value) => source.time = value, to, duration) - .SetTarget(audioSource); + Tweening.To(audioSource, (target) => target.time, (target, value) => target.time = value, to, duration) + .SetReference(audioSource); public static Tween TweenPitch(this AudioSource audioSource, float to, float duration) => - Tweening.To(audioSource, (source) => source.pitch, (source, value) => source.pitch = value, to, duration) - .SetTarget(audioSource); + Tweening.To(audioSource, (target) => target.pitch, (target, value) => target.pitch = value, to, duration) + .SetReference(audioSource); public static Tween TweenVolume(this AudioSource audioSource, float to, float duration) => - Tweening.To(audioSource, (source) => source.volume, (source, value) => source.volume = value, to, duration) - .SetTarget(audioSource); + Tweening.To(audioSource, (target) => target.volume, (target, value) => target.volume = value, to, duration) + .SetReference(audioSource); public static Tween TweenPanStereo(this AudioSource audioSource, float to, float duration) => - Tweening.To(audioSource, (source) => source.panStereo, (source, value) => source.panStereo = value, to, duration) - .SetTarget(audioSource); + Tweening.To(audioSource, (target) => target.panStereo, (target, value) => target.panStereo = value, to, duration) + .SetReference(audioSource); public static Tween TweenSpatialBlend(this AudioSource audioSource, float to, float duration) => - Tweening.To(audioSource, (source) => source.spatialBlend, (source, value) => source.spatialBlend = value, to, duration) - .SetTarget(audioSource); + Tweening.To(audioSource, (target) => target.spatialBlend, (target, value) => target.spatialBlend = value, to, duration) + .SetReference(audioSource); public static Tween TweenReverbZoneMix(this AudioSource audioSource, float to, float duration) => - Tweening.To(audioSource, (source) => source.reverbZoneMix, (source, value) => source.reverbZoneMix = value, to, duration) - .SetTarget(audioSource); + Tweening.To(audioSource, (target) => target.reverbZoneMix, (target, value) => target.reverbZoneMix = value, to, duration) + .SetReference(audioSource); public static Tween TweenDopplerLevel(this AudioSource audioSource, float to, float duration) => - Tweening.To(audioSource, (source) => source.dopplerLevel, (source, value) => source.dopplerLevel = value, to, duration) - .SetTarget(audioSource); + Tweening.To(audioSource, (target) => target.dopplerLevel, (target, value) => target.dopplerLevel = value, to, duration) + .SetReference(audioSource); public static Tween TweenSpread(this AudioSource audioSource, float to, float duration) => - Tweening.To(audioSource, (source) => source.spread, (source, value) => source.spread = value, to, duration) - .SetTarget(audioSource); + Tweening.To(audioSource, (target) => target.spread, (target, value) => target.spread = value, to, duration) + .SetReference(audioSource); public static Tween TweenMinDistance(this AudioSource audioSource, float to, float duration) => - Tweening.To(audioSource, (source) => source.minDistance, (source, value) => source.minDistance = value, to, duration) - .SetTarget(audioSource); + Tweening.To(audioSource, (target) => target.minDistance, (target, value) => target.minDistance = value, to, duration) + .SetReference(audioSource); public static Tween TweenMaxDistance(this AudioSource audioSource, float to, float duration) => - Tweening.To(audioSource, (source) => source.maxDistance, (source, value) => source.maxDistance = value, to, duration) - .SetTarget(audioSource); + Tweening.To(audioSource, (target) => target.maxDistance, (target, value) => target.maxDistance = value, to, duration) + .SetReference(audioSource); } } diff --git a/Runtime/Extensions/Misc/AimConstraintTweens.cs b/Runtime/Extensions/Misc/AimConstraintTweens.cs index 664cacf..9433885 100644 --- a/Runtime/Extensions/Misc/AimConstraintTweens.cs +++ b/Runtime/Extensions/Misc/AimConstraintTweens.cs @@ -6,28 +6,28 @@ namespace Zigurous.Tweening public static class AimConstraintTweens { public static Tween TweenWeight(this AimConstraint constraint, float to, float duration) => - Tweening.To(constraint, (source) => source.weight, (source, value) => source.weight = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.weight, (target, value) => target.weight = value, to, duration) + .SetReference(constraint); public static Tween TweenUpVector(this AimConstraint constraint, Vector3 to, float duration) => - Tweening.To(constraint, (source) => source.upVector, (source, value) => source.upVector = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.upVector, (target, value) => target.upVector = value, to, duration) + .SetReference(constraint); public static Tween TweenWorldUpVector(this AimConstraint constraint, Vector3 to, float duration) => - Tweening.To(constraint, (source) => source.worldUpVector, (source, value) => source.worldUpVector = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.worldUpVector, (target, value) => target.worldUpVector = value, to, duration) + .SetReference(constraint); public static Tween TweenAimVector(this AimConstraint constraint, Vector3 to, float duration) => - Tweening.To(constraint, (source) => source.aimVector, (source, value) => source.aimVector = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.aimVector, (target, value) => target.aimVector = value, to, duration) + .SetReference(constraint); public static Tween TweenRotationOffset(this AimConstraint constraint, Vector3 to, float duration) => - Tweening.To(constraint, (source) => source.rotationOffset, (source, value) => source.rotationOffset = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.rotationOffset, (target, value) => target.rotationOffset = value, to, duration) + .SetReference(constraint); public static Tween TweenRotationAtRest(this AimConstraint constraint, Vector3 to, float duration) => - Tweening.To(constraint, (source) => source.rotationAtRest, (source, value) => source.rotationAtRest = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.rotationAtRest, (target, value) => target.rotationAtRest = value, to, duration) + .SetReference(constraint); } } diff --git a/Runtime/Extensions/Misc/GridTweens.cs b/Runtime/Extensions/Misc/GridTweens.cs index 8b33065..1e14b0c 100644 --- a/Runtime/Extensions/Misc/GridTweens.cs +++ b/Runtime/Extensions/Misc/GridTweens.cs @@ -5,12 +5,12 @@ namespace Zigurous.Tweening public static class GridTweens { public static Tween TweenCellSize(this Grid grid, Vector3 to, float duration) => - Tweening.To(grid, (source) => source.cellSize, (source, value) => source.cellSize = value, to, duration) - .SetTarget(grid); + Tweening.To(grid, (target) => target.cellSize, (target, value) => target.cellSize = value, to, duration) + .SetReference(grid); public static Tween TweenCellGap(this Grid grid, Vector3 to, float duration) => - Tweening.To(grid, (source) => source.cellGap, (source, value) => source.cellGap = value, to, duration) - .SetTarget(grid); + Tweening.To(grid, (target) => target.cellGap, (target, value) => target.cellGap = value, to, duration) + .SetReference(grid); } } diff --git a/Runtime/Extensions/Misc/LookAtConstraintTweens.cs b/Runtime/Extensions/Misc/LookAtConstraintTweens.cs index 0e8efcd..b765b3b 100644 --- a/Runtime/Extensions/Misc/LookAtConstraintTweens.cs +++ b/Runtime/Extensions/Misc/LookAtConstraintTweens.cs @@ -6,20 +6,20 @@ namespace Zigurous.Tweening public static class LookAtConstraintTweens { public static Tween TweenWeight(this LookAtConstraint constraint, float to, float duration) => - Tweening.To(constraint, (source) => source.weight, (source, value) => source.weight = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.weight, (target, value) => target.weight = value, to, duration) + .SetReference(constraint); public static Tween TweenRoll(this LookAtConstraint constraint, float to, float duration) => - Tweening.To(constraint, (source) => source.roll, (source, value) => source.roll = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.roll, (target, value) => target.roll = value, to, duration) + .SetReference(constraint); public static Tween TweenRotationOffset(this LookAtConstraint constraint, Vector3 to, float duration) => - Tweening.To(constraint, (source) => source.rotationOffset, (source, value) => source.rotationOffset = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.rotationOffset, (target, value) => target.rotationOffset = value, to, duration) + .SetReference(constraint); public static Tween TweenRotationAtRest(this LookAtConstraint constraint, Vector3 to, float duration) => - Tweening.To(constraint, (source) => source.rotationAtRest, (source, value) => source.rotationAtRest = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.rotationAtRest, (target, value) => target.rotationAtRest = value, to, duration) + .SetReference(constraint); } } diff --git a/Runtime/Extensions/Misc/ParentConstraintTweens.cs b/Runtime/Extensions/Misc/ParentConstraintTweens.cs index c192c7b..b8cbad1 100644 --- a/Runtime/Extensions/Misc/ParentConstraintTweens.cs +++ b/Runtime/Extensions/Misc/ParentConstraintTweens.cs @@ -6,16 +6,16 @@ namespace Zigurous.Tweening public static class ParentConstraintTweens { public static Tween TweenWeight(this ParentConstraint constraint, float to, float duration) => - Tweening.To(constraint, (source) => source.weight, (source, value) => source.weight = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.weight, (target, value) => target.weight = value, to, duration) + .SetReference(constraint); public static Tween TweenRotationAtRest(this ParentConstraint constraint, Vector3 to, float duration) => - Tweening.To(constraint, (source) => source.rotationAtRest, (source, value) => source.rotationAtRest = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.rotationAtRest, (target, value) => target.rotationAtRest = value, to, duration) + .SetReference(constraint); public static Tween TweenTranslationAtRest(this ParentConstraint constraint, Vector3 to, float duration) => - Tweening.To(constraint, (source) => source.translationAtRest, (source, value) => source.translationAtRest = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.translationAtRest, (target, value) => target.translationAtRest = value, to, duration) + .SetReference(constraint); } } diff --git a/Runtime/Extensions/Misc/PositionConstraintTweens.cs b/Runtime/Extensions/Misc/PositionConstraintTweens.cs index 871f637..e3d4769 100644 --- a/Runtime/Extensions/Misc/PositionConstraintTweens.cs +++ b/Runtime/Extensions/Misc/PositionConstraintTweens.cs @@ -6,16 +6,16 @@ namespace Zigurous.Tweening public static class PositionConstraintTweens { public static Tween TweenWeight(this PositionConstraint constraint, float to, float duration) => - Tweening.To(constraint, (source) => source.weight, (source, value) => source.weight = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.weight, (target, value) => target.weight = value, to, duration) + .SetReference(constraint); public static Tween TweenTranslationAtRest(this PositionConstraint constraint, Vector3 to, float duration) => - Tweening.To(constraint, (source) => source.translationAtRest, (source, value) => source.translationAtRest = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.translationAtRest, (target, value) => target.translationAtRest = value, to, duration) + .SetReference(constraint); public static Tween TweenTranslationOffset(this PositionConstraint constraint, Vector3 to, float duration) => - Tweening.To(constraint, (source) => source.translationOffset, (source, value) => source.translationOffset = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.translationOffset, (target, value) => target.translationOffset = value, to, duration) + .SetReference(constraint); } } diff --git a/Runtime/Extensions/Misc/RectOffsetTweens.cs b/Runtime/Extensions/Misc/RectOffsetTweens.cs index 6773789..cd1cf40 100644 --- a/Runtime/Extensions/Misc/RectOffsetTweens.cs +++ b/Runtime/Extensions/Misc/RectOffsetTweens.cs @@ -5,19 +5,19 @@ namespace Zigurous.Tweening public static class RectOffsetTweens { public static Tween TweenLeft(this RectOffset offset, int to, float duration) => - Tweening.To(offset, (source) => source.left, (source, value) => source.left = value, to, duration) + Tweening.To(offset, (target) => target.left, (target, value) => target.left = value, to, duration) .SetId(offset.GetHashCode()); public static Tween TweenRight(this RectOffset offset, int to, float duration) => - Tweening.To(offset, (source) => source.right, (source, value) => source.right = value, to, duration) + Tweening.To(offset, (target) => target.right, (target, value) => target.right = value, to, duration) .SetId(offset.GetHashCode()); public static Tween TweenTop(this RectOffset offset, int to, float duration) => - Tweening.To(offset, (source) => source.top, (source, value) => source.top = value, to, duration) + Tweening.To(offset, (target) => target.top, (target, value) => target.top = value, to, duration) .SetId(offset.GetHashCode()); public static Tween TweenBottom(this RectOffset offset, int to, float duration) => - Tweening.To(offset, (source) => source.bottom, (source, value) => source.bottom = value, to, duration) + Tweening.To(offset, (target) => target.bottom, (target, value) => target.bottom = value, to, duration) .SetId(offset.GetHashCode()); } diff --git a/Runtime/Extensions/Misc/RotationConstraintTweens.cs b/Runtime/Extensions/Misc/RotationConstraintTweens.cs index 8b6e64f..adef49f 100644 --- a/Runtime/Extensions/Misc/RotationConstraintTweens.cs +++ b/Runtime/Extensions/Misc/RotationConstraintTweens.cs @@ -6,16 +6,16 @@ namespace Zigurous.Tweening public static class RotationConstraintTweens { public static Tween TweenWeight(this RotationConstraint constraint, float to, float duration) => - Tweening.To(constraint, (source) => source.weight, (source, value) => source.weight = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.weight, (target, value) => target.weight = value, to, duration) + .SetReference(constraint); public static Tween TweenRotationAtRest(this RotationConstraint constraint, Vector3 to, float duration) => - Tweening.To(constraint, (source) => source.rotationAtRest, (source, value) => source.rotationAtRest = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.rotationAtRest, (target, value) => target.rotationAtRest = value, to, duration) + .SetReference(constraint); public static Tween TweenRotationOffset(this RotationConstraint constraint, Vector3 to, float duration) => - Tweening.To(constraint, (source) => source.rotationOffset, (source, value) => source.rotationOffset = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.rotationOffset, (target, value) => target.rotationOffset = value, to, duration) + .SetReference(constraint); } } diff --git a/Runtime/Extensions/Misc/ScaleConstraintTweens.cs b/Runtime/Extensions/Misc/ScaleConstraintTweens.cs index 692c31f..9088295 100644 --- a/Runtime/Extensions/Misc/ScaleConstraintTweens.cs +++ b/Runtime/Extensions/Misc/ScaleConstraintTweens.cs @@ -6,16 +6,16 @@ namespace Zigurous.Tweening public static class ScaleConstraintTweens { public static Tween TweenWeight(this ScaleConstraint constraint, float to, float duration) => - Tweening.To(constraint, (source) => source.weight, (source, value) => source.weight = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.weight, (target, value) => target.weight = value, to, duration) + .SetReference(constraint); public static Tween TweenScaleAtRest(this ScaleConstraint constraint, Vector3 to, float duration) => - Tweening.To(constraint, (source) => source.scaleAtRest, (source, value) => source.scaleAtRest = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.scaleAtRest, (target, value) => target.scaleAtRest = value, to, duration) + .SetReference(constraint); public static Tween TweenScaleOffset(this ScaleConstraint constraint, Vector3 to, float duration) => - Tweening.To(constraint, (source) => source.scaleOffset, (source, value) => source.scaleOffset = value, to, duration) - .SetTarget(constraint); + Tweening.To(constraint, (target) => target.scaleOffset, (target, value) => target.scaleOffset = value, to, duration) + .SetReference(constraint); } } diff --git a/Runtime/Extensions/Misc/TransformTweens.cs b/Runtime/Extensions/Misc/TransformTweens.cs index 6631c20..d972e09 100644 --- a/Runtime/Extensions/Misc/TransformTweens.cs +++ b/Runtime/Extensions/Misc/TransformTweens.cs @@ -5,60 +5,60 @@ namespace Zigurous.Tweening public static class TransformTweens { public static Tween TweenPosition(this Transform transform, Vector3 to, float duration) => - Tweening.To(transform, (source) => source.position, (source, value) => source.position = value, to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.position, (target, value) => target.position = value, to, duration) + .SetReference(transform); public static Tween TweenPositionX(this Transform transform, float to, float duration) => - Tweening.To(transform, (source) => source.position.x, (source, value) => source.position = new Vector3(value, source.position.y, source.position.z), to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.position.x, (target, value) => target.position = new Vector3(value, target.position.y, target.position.z), to, duration) + .SetReference(transform); public static Tween TweenPositionY(this Transform transform, float to, float duration) => - Tweening.To(transform, (source) => source.position.y, (source, value) => source.position = new Vector3(source.position.x, value, source.position.z), to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.position.y, (target, value) => target.position = new Vector3(target.position.x, value, target.position.z), to, duration) + .SetReference(transform); public static Tween TweenPositionZ(this Transform transform, float to, float duration) => - Tweening.To(transform, (source) => source.position.z, (source, value) => source.position = new Vector3(source.position.x, source.position.y, value), to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.position.z, (target, value) => target.position = new Vector3(target.position.x, target.position.y, value), to, duration) + .SetReference(transform); public static Tween TweenLocalPosition(this Transform transform, Vector3 to, float duration) => - Tweening.To(transform, (source) => source.localPosition, (source, value) => source.localPosition = value, to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.localPosition, (target, value) => target.localPosition = value, to, duration) + .SetReference(transform); public static Tween TweenLocalPositionX(this Transform transform, float to, float duration) => - Tweening.To(transform, (source) => source.localPosition.x, (source, value) => source.localPosition = new Vector3(value, source.localPosition.y, source.localPosition.z), to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.localPosition.x, (target, value) => target.localPosition = new Vector3(value, target.localPosition.y, target.localPosition.z), to, duration) + .SetReference(transform); public static Tween TweenLocalPositionY(this Transform transform, float to, float duration) => - Tweening.To(transform, (source) => source.localPosition.y, (source, value) => source.localPosition = new Vector3(source.localPosition.x, value, source.localPosition.z), to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.localPosition.y, (target, value) => target.localPosition = new Vector3(target.localPosition.x, value, target.localPosition.z), to, duration) + .SetReference(transform); public static Tween TweenLocalPositionZ(this Transform transform, float to, float duration) => - Tweening.To(transform, (source) => source.localPosition.z, (source, value) => source.localPosition = new Vector3(source.localPosition.x, source.localPosition.y, value), to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.localPosition.z, (target, value) => target.localPosition = new Vector3(target.localPosition.x, target.localPosition.y, value), to, duration) + .SetReference(transform); public static Tween TweenScale(this Transform transform, Vector3 to, float duration) => - Tweening.To(transform, (source) => source.localScale, (source, value) => source.localScale = value, to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.localScale, (target, value) => target.localScale = value, to, duration) + .SetReference(transform); public static Tween TweenScaleX(this Transform transform, float to, float duration) => - Tweening.To(transform, (source) => source.localScale.x, (source, value) => source.localScale = new Vector3(value, source.localScale.y, source.localScale.z), to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.localScale.x, (target, value) => target.localScale = new Vector3(value, target.localScale.y, target.localScale.z), to, duration) + .SetReference(transform); public static Tween TweenScaleY(this Transform transform, float to, float duration) => - Tweening.To(transform, (source) => source.localScale.y, (source, value) => source.localScale = new Vector3(source.localScale.x, value, source.localScale.z), to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.localScale.y, (target, value) => target.localScale = new Vector3(target.localScale.x, value, target.localScale.z), to, duration) + .SetReference(transform); public static Tween TweenScaleZ(this Transform transform, float to, float duration) => - Tweening.To(transform, (source) => source.localScale.z, (source, value) => source.localScale = new Vector3(source.localScale.x, source.localScale.y, value), to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.localScale.z, (target, value) => target.localScale = new Vector3(target.localScale.x, target.localScale.y, value), to, duration) + .SetReference(transform); public static Tween TweenRotation(this Transform transform, Quaternion to, float duration) => - Tweening.To(transform, (source) => source.rotation, (source, value) => source.rotation = value, to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.rotation, (target, value) => target.rotation = value, to, duration) + .SetReference(transform); public static Tween TweenLocalRotation(this Transform transform, Quaternion to, float duration) => - Tweening.To(transform, (source) => source.localRotation, (source, value) => source.localRotation = value, to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.localRotation, (target, value) => target.localRotation = value, to, duration) + .SetReference(transform); public static Tween TweenEulerAngles(this Transform transform, Vector3 to, float duration) => TweenRotation(transform, Quaternion.Euler(to), duration); diff --git a/Runtime/Extensions/Navigation/NavMeshAgentTweens.cs b/Runtime/Extensions/Navigation/NavMeshAgentTweens.cs index e507091..0a5b210 100644 --- a/Runtime/Extensions/Navigation/NavMeshAgentTweens.cs +++ b/Runtime/Extensions/Navigation/NavMeshAgentTweens.cs @@ -6,44 +6,44 @@ namespace Zigurous.Tweening public static class NavMeshAgentTweens { public static Tween TweenSpeed(this NavMeshAgent agent, float to, float duration) => - Tweening.To(agent, (source) => source.speed, (source, value) => source.speed = value, to, duration) - .SetTarget(agent); + Tweening.To(agent, (target) => target.speed, (target, value) => target.speed = value, to, duration) + .SetReference(agent); public static Tween TweenAngularSpeed(this NavMeshAgent agent, float to, float duration) => - Tweening.To(agent, (source) => source.angularSpeed, (source, value) => source.angularSpeed = value, to, duration) - .SetTarget(agent); + Tweening.To(agent, (target) => target.angularSpeed, (target, value) => target.angularSpeed = value, to, duration) + .SetReference(agent); public static Tween TweenAcceleration(this NavMeshAgent agent, float to, float duration) => - Tweening.To(agent, (source) => source.acceleration, (source, value) => source.acceleration = value, to, duration) - .SetTarget(agent); + Tweening.To(agent, (target) => target.acceleration, (target, value) => target.acceleration = value, to, duration) + .SetReference(agent); public static Tween TweenRadius(this NavMeshAgent agent, float to, float duration) => - Tweening.To(agent, (source) => source.radius, (source, value) => source.radius = value, to, duration) - .SetTarget(agent); + Tweening.To(agent, (target) => target.radius, (target, value) => target.radius = value, to, duration) + .SetReference(agent); public static Tween TweenHeight(this NavMeshAgent agent, float to, float duration) => - Tweening.To(agent, (source) => source.height, (source, value) => source.height = value, to, duration) - .SetTarget(agent); + Tweening.To(agent, (target) => target.height, (target, value) => target.height = value, to, duration) + .SetReference(agent); public static Tween TweenBaseOffset(this NavMeshAgent agent, float to, float duration) => - Tweening.To(agent, (source) => source.baseOffset, (source, value) => source.baseOffset = value, to, duration) - .SetTarget(agent); + Tweening.To(agent, (target) => target.baseOffset, (target, value) => target.baseOffset = value, to, duration) + .SetReference(agent); public static Tween TweenNextPosition(this NavMeshAgent agent, Vector3 to, float duration) => - Tweening.To(agent, (source) => source.nextPosition, (source, value) => source.nextPosition = value, to, duration) - .SetTarget(agent); + Tweening.To(agent, (target) => target.nextPosition, (target, value) => target.nextPosition = value, to, duration) + .SetReference(agent); public static Tween TweenDestination(this NavMeshAgent agent, Vector3 to, float duration) => - Tweening.To(agent, (source) => source.destination, (source, value) => source.destination = value, to, duration) - .SetTarget(agent); + Tweening.To(agent, (target) => target.destination, (target, value) => target.destination = value, to, duration) + .SetReference(agent); public static Tween TweenVelocity(this NavMeshAgent agent, Vector3 to, float duration) => - Tweening.To(agent, (source) => source.velocity, (source, value) => source.velocity = value, to, duration) - .SetTarget(agent); + Tweening.To(agent, (target) => target.velocity, (target, value) => target.velocity = value, to, duration) + .SetReference(agent); public static Tween TweenStoppingDistance(this NavMeshAgent agent, float to, float duration) => - Tweening.To(agent, (source) => source.stoppingDistance, (source, value) => source.stoppingDistance = value, to, duration) - .SetTarget(agent); + Tweening.To(agent, (target) => target.stoppingDistance, (target, value) => target.stoppingDistance = value, to, duration) + .SetReference(agent); } } diff --git a/Runtime/Extensions/Navigation/NavMeshObstacleTweens.cs b/Runtime/Extensions/Navigation/NavMeshObstacleTweens.cs index 333ff9f..eda74c2 100644 --- a/Runtime/Extensions/Navigation/NavMeshObstacleTweens.cs +++ b/Runtime/Extensions/Navigation/NavMeshObstacleTweens.cs @@ -6,24 +6,24 @@ namespace Zigurous.Tweening public static class NavMeshObstacleTweens { public static Tween TweenHeight(this NavMeshObstacle obstacle, float to, float duration) => - Tweening.To(obstacle, (source) => source.height, (source, value) => source.height = value, to, duration) - .SetTarget(obstacle); + Tweening.To(obstacle, (target) => target.height, (target, value) => target.height = value, to, duration) + .SetReference(obstacle); public static Tween TweenRadius(this NavMeshObstacle obstacle, float to, float duration) => - Tweening.To(obstacle, (source) => source.radius, (source, value) => source.radius = value, to, duration) - .SetTarget(obstacle); + Tweening.To(obstacle, (target) => target.radius, (target, value) => target.radius = value, to, duration) + .SetReference(obstacle); public static Tween TweenSize(this NavMeshObstacle obstacle, Vector3 to, float duration) => - Tweening.To(obstacle, (source) => source.size, (source, value) => source.size = value, to, duration) - .SetTarget(obstacle); + Tweening.To(obstacle, (target) => target.size, (target, value) => target.size = value, to, duration) + .SetReference(obstacle); public static Tween TweenCenter(this NavMeshObstacle obstacle, Vector3 to, float duration) => - Tweening.To(obstacle, (source) => source.center, (source, value) => source.center = value, to, duration) - .SetTarget(obstacle); + Tweening.To(obstacle, (target) => target.center, (target, value) => target.center = value, to, duration) + .SetReference(obstacle); public static Tween TweenVelocity(this NavMeshObstacle obstacle, Vector3 to, float duration) => - Tweening.To(obstacle, (source) => source.velocity, (source, value) => source.velocity = value, to, duration) - .SetTarget(obstacle); + Tweening.To(obstacle, (target) => target.velocity, (target, value) => target.velocity = value, to, duration) + .SetReference(obstacle); } } diff --git a/Runtime/Extensions/Physics/BoxColliderTweens.cs b/Runtime/Extensions/Physics/BoxColliderTweens.cs index 1f8af2a..80ed9e9 100644 --- a/Runtime/Extensions/Physics/BoxColliderTweens.cs +++ b/Runtime/Extensions/Physics/BoxColliderTweens.cs @@ -5,12 +5,12 @@ namespace Zigurous.Tweening public static class BoxColliderTweens { public static Tween TweenCenter(this BoxCollider collider, Vector3 to, float duration) => - Tweening.To(collider, (source) => source.center, (source, value) => source.center = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.center, (target, value) => target.center = value, to, duration) + .SetReference(collider); public static Tween TweenSize(this BoxCollider collider, Vector3 to, float duration) => - Tweening.To(collider, (source) => source.size, (source, value) => source.size = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.size, (target, value) => target.size = value, to, duration) + .SetReference(collider); } } diff --git a/Runtime/Extensions/Physics/CapsuleColliderTweens.cs b/Runtime/Extensions/Physics/CapsuleColliderTweens.cs index 3d5b218..dfc2c5e 100644 --- a/Runtime/Extensions/Physics/CapsuleColliderTweens.cs +++ b/Runtime/Extensions/Physics/CapsuleColliderTweens.cs @@ -5,16 +5,16 @@ namespace Zigurous.Tweening public static class CapsuleColliderTweens { public static Tween TweenCenter(this CapsuleCollider collider, Vector3 to, float duration) => - Tweening.To(collider, (source) => source.center, (source, value) => source.center = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.center, (target, value) => target.center = value, to, duration) + .SetReference(collider); public static Tween TweenRadius(this CapsuleCollider collider, float to, float duration) => - Tweening.To(collider, (source) => source.radius, (source, value) => source.radius = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.radius, (target, value) => target.radius = value, to, duration) + .SetReference(collider); public static Tween TweenHeight(this CapsuleCollider collider, float to, float duration) => - Tweening.To(collider, (source) => source.height, (source, value) => source.height = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.height, (target, value) => target.height = value, to, duration) + .SetReference(collider); } } diff --git a/Runtime/Extensions/Physics/CharacterControllerTweens.cs b/Runtime/Extensions/Physics/CharacterControllerTweens.cs index 9070810..f7c0f17 100644 --- a/Runtime/Extensions/Physics/CharacterControllerTweens.cs +++ b/Runtime/Extensions/Physics/CharacterControllerTweens.cs @@ -5,32 +5,32 @@ namespace Zigurous.Tweening public static class CharacterControllerTweens { public static Tween TweenCenter(this CharacterController character, Vector3 to, float duration) => - Tweening.To(character, (source) => source.center, (source, value) => source.center = value, to, duration) - .SetTarget(character); + Tweening.To(character, (target) => target.center, (target, value) => target.center = value, to, duration) + .SetReference(character); public static Tween TweenRadius(this CharacterController character, float to, float duration) => - Tweening.To(character, (source) => source.radius, (source, value) => source.radius = value, to, duration) - .SetTarget(character); + Tweening.To(character, (target) => target.radius, (target, value) => target.radius = value, to, duration) + .SetReference(character); public static Tween TweenHeight(this CharacterController character, float to, float duration) => - Tweening.To(character, (source) => source.height, (source, value) => source.height = value, to, duration) - .SetTarget(character); + Tweening.To(character, (target) => target.height, (target, value) => target.height = value, to, duration) + .SetReference(character); public static Tween TweenSlopeLimit(this CharacterController character, float to, float duration) => - Tweening.To(character, (source) => source.slopeLimit, (source, value) => source.slopeLimit = value, to, duration) - .SetTarget(character); + Tweening.To(character, (target) => target.slopeLimit, (target, value) => target.slopeLimit = value, to, duration) + .SetReference(character); public static Tween TweenStepOffset(this CharacterController character, float to, float duration) => - Tweening.To(character, (source) => source.stepOffset, (source, value) => source.stepOffset = value, to, duration) - .SetTarget(character); + Tweening.To(character, (target) => target.stepOffset, (target, value) => target.stepOffset = value, to, duration) + .SetReference(character); public static Tween TweenSkinWidth(this CharacterController character, float to, float duration) => - Tweening.To(character, (source) => source.skinWidth, (source, value) => source.skinWidth = value, to, duration) - .SetTarget(character); + Tweening.To(character, (target) => target.skinWidth, (target, value) => target.skinWidth = value, to, duration) + .SetReference(character); public static Tween TweenMinMoveDistance(this CharacterController character, float to, float duration) => - Tweening.To(character, (source) => source.minMoveDistance, (source, value) => source.minMoveDistance = value, to, duration) - .SetTarget(character); + Tweening.To(character, (target) => target.minMoveDistance, (target, value) => target.minMoveDistance = value, to, duration) + .SetReference(character); } } diff --git a/Runtime/Extensions/Physics/CharacterJointTweens.cs b/Runtime/Extensions/Physics/CharacterJointTweens.cs index 4cc2e61..9af319e 100644 --- a/Runtime/Extensions/Physics/CharacterJointTweens.cs +++ b/Runtime/Extensions/Physics/CharacterJointTweens.cs @@ -5,16 +5,16 @@ namespace Zigurous.Tweening public static class CharacterJointTweens { public static Tween TweenSwingAxis(this CharacterJoint joint, Vector3 to, float duration) => - Tweening.To(joint, (source) => source.swingAxis, (source, value) => source.swingAxis = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.swingAxis, (target, value) => target.swingAxis = value, to, duration) + .SetReference(joint); public static Tween TweenProjectionDistance(this CharacterJoint joint, float to, float duration) => - Tweening.To(joint, (source) => source.projectionDistance, (source, value) => source.projectionDistance = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.projectionDistance, (target, value) => target.projectionDistance = value, to, duration) + .SetReference(joint); public static Tween TweenProjectionAngle(this CharacterJoint joint, float to, float duration) => - Tweening.To(joint, (source) => source.projectionAngle, (source, value) => source.projectionAngle = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.projectionAngle, (target, value) => target.projectionAngle = value, to, duration) + .SetReference(joint); } } diff --git a/Runtime/Extensions/Physics/ClothTweens.cs b/Runtime/Extensions/Physics/ClothTweens.cs index a0540b8..28150dd 100644 --- a/Runtime/Extensions/Physics/ClothTweens.cs +++ b/Runtime/Extensions/Physics/ClothTweens.cs @@ -5,56 +5,56 @@ namespace Zigurous.Tweening public static class ClothTweens { public static Tween TweenDamping(this Cloth cloth, float to, float duration) => - Tweening.To(cloth, (source) => source.damping, (source, value) => source.damping = value, to, duration) - .SetTarget(cloth); + Tweening.To(cloth, (target) => target.damping, (target, value) => target.damping = value, to, duration) + .SetReference(cloth); public static Tween TweenFriction(this Cloth cloth, float to, float duration) => - Tweening.To(cloth, (source) => source.friction, (source, value) => source.friction = value, to, duration) - .SetTarget(cloth); + Tweening.To(cloth, (target) => target.friction, (target, value) => target.friction = value, to, duration) + .SetReference(cloth); public static Tween TweenCollisionMassScale(this Cloth cloth, float to, float duration) => - Tweening.To(cloth, (source) => source.collisionMassScale, (source, value) => source.collisionMassScale = value, to, duration) - .SetTarget(cloth); + Tweening.To(cloth, (target) => target.collisionMassScale, (target, value) => target.collisionMassScale = value, to, duration) + .SetReference(cloth); public static Tween TweenWorldVelocityScale(this Cloth cloth, float to, float duration) => - Tweening.To(cloth, (source) => source.worldVelocityScale, (source, value) => source.worldVelocityScale = value, to, duration) - .SetTarget(cloth); + Tweening.To(cloth, (target) => target.worldVelocityScale, (target, value) => target.worldVelocityScale = value, to, duration) + .SetReference(cloth); public static Tween TweenWorldAccelerationScale(this Cloth cloth, float to, float duration) => - Tweening.To(cloth, (source) => source.worldAccelerationScale, (source, value) => source.worldAccelerationScale = value, to, duration) - .SetTarget(cloth); + Tweening.To(cloth, (target) => target.worldAccelerationScale, (target, value) => target.worldAccelerationScale = value, to, duration) + .SetReference(cloth); public static Tween TweenExternalAcceleration(this Cloth cloth, Vector3 to, float duration) => - Tweening.To(cloth, (source) => source.externalAcceleration, (source, value) => source.externalAcceleration = value, to, duration) - .SetTarget(cloth); + Tweening.To(cloth, (target) => target.externalAcceleration, (target, value) => target.externalAcceleration = value, to, duration) + .SetReference(cloth); public static Tween TweenRandomAcceleration(this Cloth cloth, Vector3 to, float duration) => - Tweening.To(cloth, (source) => source.randomAcceleration, (source, value) => source.randomAcceleration = value, to, duration) - .SetTarget(cloth); + Tweening.To(cloth, (target) => target.randomAcceleration, (target, value) => target.randomAcceleration = value, to, duration) + .SetReference(cloth); public static Tween TweenStiffnessFrequency(this Cloth cloth, float to, float duration) => - Tweening.To(cloth, (source) => source.stiffnessFrequency, (source, value) => source.stiffnessFrequency = value, to, duration) - .SetTarget(cloth); + Tweening.To(cloth, (target) => target.stiffnessFrequency, (target, value) => target.stiffnessFrequency = value, to, duration) + .SetReference(cloth); public static Tween TweenSelfCollisionDistance(this Cloth cloth, float to, float duration) => - Tweening.To(cloth, (source) => source.selfCollisionDistance, (source, value) => source.selfCollisionDistance = value, to, duration) - .SetTarget(cloth); + Tweening.To(cloth, (target) => target.selfCollisionDistance, (target, value) => target.selfCollisionDistance = value, to, duration) + .SetReference(cloth); public static Tween TweenSelfCollisionStiffness(this Cloth cloth, float to, float duration) => - Tweening.To(cloth, (source) => source.selfCollisionStiffness, (source, value) => source.selfCollisionStiffness = value, to, duration) - .SetTarget(cloth); + Tweening.To(cloth, (target) => target.selfCollisionStiffness, (target, value) => target.selfCollisionStiffness = value, to, duration) + .SetReference(cloth); public static Tween TweenStretchingStiffness(this Cloth cloth, float to, float duration) => - Tweening.To(cloth, (source) => source.stretchingStiffness, (source, value) => source.stretchingStiffness = value, to, duration) - .SetTarget(cloth); + Tweening.To(cloth, (target) => target.stretchingStiffness, (target, value) => target.stretchingStiffness = value, to, duration) + .SetReference(cloth); public static Tween TweenBendingStiffness(this Cloth cloth, float to, float duration) => - Tweening.To(cloth, (source) => source.bendingStiffness, (source, value) => source.bendingStiffness = value, to, duration) - .SetTarget(cloth); + Tweening.To(cloth, (target) => target.bendingStiffness, (target, value) => target.bendingStiffness = value, to, duration) + .SetReference(cloth); public static Tween TweenSleepThreshold(this Cloth cloth, float to, float duration) => - Tweening.To(cloth, (source) => source.sleepThreshold, (source, value) => source.sleepThreshold = value, to, duration) - .SetTarget(cloth); + Tweening.To(cloth, (target) => target.sleepThreshold, (target, value) => target.sleepThreshold = value, to, duration) + .SetReference(cloth); } } diff --git a/Runtime/Extensions/Physics/ColliderTweens.cs b/Runtime/Extensions/Physics/ColliderTweens.cs index 4016634..342710a 100644 --- a/Runtime/Extensions/Physics/ColliderTweens.cs +++ b/Runtime/Extensions/Physics/ColliderTweens.cs @@ -5,8 +5,8 @@ namespace Zigurous.Tweening public static class ColliderTweens { public static Tween TweenContactOffset(this Collider collider, float to, float duration) => - Tweening.To(collider, (source) => source.contactOffset, (source, value) => source.contactOffset = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.contactOffset, (target, value) => target.contactOffset = value, to, duration) + .SetReference(collider); } } diff --git a/Runtime/Extensions/Physics/ConfigurableJointTweens.cs b/Runtime/Extensions/Physics/ConfigurableJointTweens.cs index 49dc075..d2048a6 100644 --- a/Runtime/Extensions/Physics/ConfigurableJointTweens.cs +++ b/Runtime/Extensions/Physics/ConfigurableJointTweens.cs @@ -5,32 +5,32 @@ namespace Zigurous.Tweening public static class ConfigurableJointTweens { public static Tween TweenProjectionAngle(this ConfigurableJoint joint, float to, float duration) => - Tweening.To(joint, (source) => source.projectionAngle, (source, value) => source.projectionAngle = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.projectionAngle, (target, value) => target.projectionAngle = value, to, duration) + .SetReference(joint); public static Tween TweenProjectionDistance(this ConfigurableJoint joint, float to, float duration) => - Tweening.To(joint, (source) => source.projectionDistance, (source, value) => source.projectionDistance = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.projectionDistance, (target, value) => target.projectionDistance = value, to, duration) + .SetReference(joint); public static Tween TweenTargetVelocity(this ConfigurableJoint joint, Vector3 to, float duration) => - Tweening.To(joint, (source) => source.targetVelocity, (source, value) => source.targetVelocity = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.targetVelocity, (target, value) => target.targetVelocity = value, to, duration) + .SetReference(joint); public static Tween TweenTargetAngularVelocity(this ConfigurableJoint joint, Vector3 to, float duration) => - Tweening.To(joint, (source) => source.targetAngularVelocity, (source, value) => source.targetAngularVelocity = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.targetAngularVelocity, (target, value) => target.targetAngularVelocity = value, to, duration) + .SetReference(joint); public static Tween TweenTargetPosition(this ConfigurableJoint joint, Vector3 to, float duration) => - Tweening.To(joint, (source) => source.targetPosition, (source, value) => source.targetPosition = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.targetPosition, (target, value) => target.targetPosition = value, to, duration) + .SetReference(joint); public static Tween TweenTargetRotation(this ConfigurableJoint joint, Quaternion to, float duration) => - Tweening.To(joint, (source) => source.targetRotation, (source, value) => source.targetRotation = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.targetRotation, (target, value) => target.targetRotation = value, to, duration) + .SetReference(joint); public static Tween TweenSecondaryAxis(this ConfigurableJoint joint, Vector3 to, float duration) => - Tweening.To(joint, (source) => source.secondaryAxis, (source, value) => source.secondaryAxis = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.secondaryAxis, (target, value) => target.secondaryAxis = value, to, duration) + .SetReference(joint); } } diff --git a/Runtime/Extensions/Physics/ConstantForceTweens.cs b/Runtime/Extensions/Physics/ConstantForceTweens.cs index 3217e9a..0649579 100644 --- a/Runtime/Extensions/Physics/ConstantForceTweens.cs +++ b/Runtime/Extensions/Physics/ConstantForceTweens.cs @@ -5,20 +5,20 @@ namespace Zigurous.Tweening public static class ConstantForceTweens { public static Tween TweenForce(this ConstantForce constantForce, Vector3 to, float duration) => - Tweening.To(constantForce, (source) => source.force, (source, value) => source.force = value, to, duration) - .SetTarget(constantForce); + Tweening.To(constantForce, (target) => target.force, (target, value) => target.force = value, to, duration) + .SetReference(constantForce); public static Tween TweenRelativeForce(this ConstantForce constantForce, Vector3 to, float duration) => - Tweening.To(constantForce, (source) => source.relativeForce, (source, value) => source.relativeForce = value, to, duration) - .SetTarget(constantForce); + Tweening.To(constantForce, (target) => target.relativeForce, (target, value) => target.relativeForce = value, to, duration) + .SetReference(constantForce); public static Tween TweenTorque(this ConstantForce constantForce, Vector3 to, float duration) => - Tweening.To(constantForce, (source) => source.torque, (source, value) => source.torque = value, to, duration) - .SetTarget(constantForce); + Tweening.To(constantForce, (target) => target.torque, (target, value) => target.torque = value, to, duration) + .SetReference(constantForce); public static Tween TweenRelativeTorque(this ConstantForce constantForce, Vector3 to, float duration) => - Tweening.To(constantForce, (source) => source.relativeTorque, (source, value) => source.relativeTorque = value, to, duration) - .SetTarget(constantForce); + Tweening.To(constantForce, (target) => target.relativeTorque, (target, value) => target.relativeTorque = value, to, duration) + .SetReference(constantForce); } } diff --git a/Runtime/Extensions/Physics/JointTweens.cs b/Runtime/Extensions/Physics/JointTweens.cs index e0a830f..52e49d4 100644 --- a/Runtime/Extensions/Physics/JointTweens.cs +++ b/Runtime/Extensions/Physics/JointTweens.cs @@ -5,32 +5,32 @@ namespace Zigurous.Tweening public static class JointTweens { public static Tween TweenAxis(this Joint joint, Vector3 to, float duration) => - Tweening.To(joint, (source) => source.axis, (source, value) => source.axis = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.axis, (target, value) => target.axis = value, to, duration) + .SetReference(joint); public static Tween TweenAnchor(this Joint joint, Vector3 to, float duration) => - Tweening.To(joint, (source) => source.anchor, (source, value) => source.anchor = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.anchor, (target, value) => target.anchor = value, to, duration) + .SetReference(joint); public static Tween TweenConnectedAnchor(this Joint joint, Vector3 to, float duration) => - Tweening.To(joint, (source) => source.connectedAnchor, (source, value) => source.connectedAnchor = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.connectedAnchor, (target, value) => target.connectedAnchor = value, to, duration) + .SetReference(joint); public static Tween TweenBreakForce(this Joint joint, float to, float duration) => - Tweening.To(joint, (source) => source.breakForce, (source, value) => source.breakForce = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.breakForce, (target, value) => target.breakForce = value, to, duration) + .SetReference(joint); public static Tween TweenBreakTorque(this Joint joint, float to, float duration) => - Tweening.To(joint, (source) => source.breakTorque, (source, value) => source.breakTorque = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.breakTorque, (target, value) => target.breakTorque = value, to, duration) + .SetReference(joint); public static Tween TweenMassScale(this Joint joint, float to, float duration) => - Tweening.To(joint, (source) => source.massScale, (source, value) => source.massScale = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.massScale, (target, value) => target.massScale = value, to, duration) + .SetReference(joint); public static Tween TweenConnectedMassScale(this Joint joint, float to, float duration) => - Tweening.To(joint, (source) => source.connectedMassScale, (source, value) => source.connectedMassScale = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.connectedMassScale, (target, value) => target.connectedMassScale = value, to, duration) + .SetReference(joint); } } diff --git a/Runtime/Extensions/Physics/PhysicMaterialTweens.cs b/Runtime/Extensions/Physics/PhysicMaterialTweens.cs index 0914b9d..029f98b 100644 --- a/Runtime/Extensions/Physics/PhysicMaterialTweens.cs +++ b/Runtime/Extensions/Physics/PhysicMaterialTweens.cs @@ -5,16 +5,16 @@ namespace Zigurous.Tweening public static class PhysicMaterialTweens { public static Tween TweenBounciness(this PhysicMaterial material, float to, float duration) => - Tweening.To(material, (source) => source.bounciness, (source, value) => source.bounciness = value, to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.bounciness, (target, value) => target.bounciness = value, to, duration) + .SetReference(material); public static Tween TweenDynamicFriction(this PhysicMaterial material, float to, float duration) => - Tweening.To(material, (source) => source.dynamicFriction, (source, value) => source.dynamicFriction = value, to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.dynamicFriction, (target, value) => target.dynamicFriction = value, to, duration) + .SetReference(material); public static Tween TweenStaticFriction(this PhysicMaterial material, float to, float duration) => - Tweening.To(material, (source) => source.staticFriction, (source, value) => source.staticFriction = value, to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.staticFriction, (target, value) => target.staticFriction = value, to, duration) + .SetReference(material); } } diff --git a/Runtime/Extensions/Physics/RigidbodyTweens.cs b/Runtime/Extensions/Physics/RigidbodyTweens.cs index 9ad4af5..33ab18f 100644 --- a/Runtime/Extensions/Physics/RigidbodyTweens.cs +++ b/Runtime/Extensions/Physics/RigidbodyTweens.cs @@ -5,56 +5,56 @@ namespace Zigurous.Tweening public static class RigidbodyTweens { public static Tween TweenPosition(this Rigidbody rigidbody, Vector3 to, float duration) => - Tweening.To(rigidbody, (source) => source.position, (source, value) => source.position = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.position, (target, value) => target.position = value, to, duration) + .SetReference(rigidbody); public static Tween TweenRotation(this Rigidbody rigidbody, Quaternion to, float duration) => - Tweening.To(rigidbody, (source) => source.rotation, (source, value) => source.rotation = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.rotation, (target, value) => target.rotation = value, to, duration) + .SetReference(rigidbody); public static Tween TweenVelocity(this Rigidbody rigidbody, Vector3 to, float duration) => - Tweening.To(rigidbody, (source) => source.velocity, (source, value) => source.velocity = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.velocity, (target, value) => target.velocity = value, to, duration) + .SetReference(rigidbody); public static Tween TweenAngularVelocity(this Rigidbody rigidbody, Vector3 to, float duration) => - Tweening.To(rigidbody, (source) => source.angularVelocity, (source, value) => source.angularVelocity = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.angularVelocity, (target, value) => target.angularVelocity = value, to, duration) + .SetReference(rigidbody); public static Tween TweenMaxAngularVelocity(this Rigidbody rigidbody, float to, float duration) => - Tweening.To(rigidbody, (source) => source.maxAngularVelocity, (source, value) => source.maxAngularVelocity = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.maxAngularVelocity, (target, value) => target.maxAngularVelocity = value, to, duration) + .SetReference(rigidbody); public static Tween TweenMaxDepenetrationVelocity(this Rigidbody rigidbody, float to, float duration) => - Tweening.To(rigidbody, (source) => source.maxDepenetrationVelocity, (source, value) => source.maxDepenetrationVelocity = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.maxDepenetrationVelocity, (target, value) => target.maxDepenetrationVelocity = value, to, duration) + .SetReference(rigidbody); public static Tween TweenMass(this Rigidbody rigidbody, float to, float duration) => - Tweening.To(rigidbody, (source) => source.mass, (source, value) => source.mass = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.mass, (target, value) => target.mass = value, to, duration) + .SetReference(rigidbody); public static Tween TweenCenterOfMass(this Rigidbody rigidbody, Vector3 to, float duration) => - Tweening.To(rigidbody, (source) => source.centerOfMass, (source, value) => source.centerOfMass = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.centerOfMass, (target, value) => target.centerOfMass = value, to, duration) + .SetReference(rigidbody); public static Tween TweenDrag(this Rigidbody rigidbody, float to, float duration) => - Tweening.To(rigidbody, (source) => source.drag, (source, value) => source.drag = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.drag, (target, value) => target.drag = value, to, duration) + .SetReference(rigidbody); public static Tween TweenAngularDrag(this Rigidbody rigidbody, float to, float duration) => - Tweening.To(rigidbody, (source) => source.angularDrag, (source, value) => source.angularDrag = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.angularDrag, (target, value) => target.angularDrag = value, to, duration) + .SetReference(rigidbody); public static Tween TweenInertiaTensor(this Rigidbody rigidbody, Vector3 to, float duration) => - Tweening.To(rigidbody, (source) => source.inertiaTensor, (source, value) => source.inertiaTensor = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.inertiaTensor, (target, value) => target.inertiaTensor = value, to, duration) + .SetReference(rigidbody); public static Tween TweenInertiaTensorRotation(this Rigidbody rigidbody, Quaternion to, float duration) => - Tweening.To(rigidbody, (source) => source.inertiaTensorRotation, (source, value) => source.inertiaTensorRotation = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.inertiaTensorRotation, (target, value) => target.inertiaTensorRotation = value, to, duration) + .SetReference(rigidbody); public static Tween TweenSleepThreshold(this Rigidbody rigidbody, float to, float duration) => - Tweening.To(rigidbody, (source) => source.sleepThreshold, (source, value) => source.sleepThreshold = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.sleepThreshold, (target, value) => target.sleepThreshold = value, to, duration) + .SetReference(rigidbody); } } diff --git a/Runtime/Extensions/Physics/SphereColliderTweens.cs b/Runtime/Extensions/Physics/SphereColliderTweens.cs index 3f33598..50f67cb 100644 --- a/Runtime/Extensions/Physics/SphereColliderTweens.cs +++ b/Runtime/Extensions/Physics/SphereColliderTweens.cs @@ -5,12 +5,12 @@ namespace Zigurous.Tweening public static class SphereColliderTweens { public static Tween TweenCenter(this SphereCollider collider, Vector3 to, float duration) => - Tweening.To(collider, (source) => source.center, (source, value) => source.center = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.center, (target, value) => target.center = value, to, duration) + .SetReference(collider); public static Tween TweenRadius(this SphereCollider collider, float to, float duration) => - Tweening.To(collider, (source) => source.radius, (source, value) => source.radius = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.radius, (target, value) => target.radius = value, to, duration) + .SetReference(collider); } } diff --git a/Runtime/Extensions/Physics/SpringJointTweens.cs b/Runtime/Extensions/Physics/SpringJointTweens.cs index 05e33c0..daffdb6 100644 --- a/Runtime/Extensions/Physics/SpringJointTweens.cs +++ b/Runtime/Extensions/Physics/SpringJointTweens.cs @@ -5,24 +5,24 @@ namespace Zigurous.Tweening public static class SpringJointTweens { public static Tween TweenSpring(this SpringJoint joint, float to, float duration) => - Tweening.To(joint, (source) => source.spring, (source, value) => source.spring = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.spring, (target, value) => target.spring = value, to, duration) + .SetReference(joint); public static Tween TweenDamper(this SpringJoint joint, float to, float duration) => - Tweening.To(joint, (source) => source.damper, (source, value) => source.damper = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.damper, (target, value) => target.damper = value, to, duration) + .SetReference(joint); public static Tween TweenMinDistance(this SpringJoint joint, float to, float duration) => - Tweening.To(joint, (source) => source.minDistance, (source, value) => source.minDistance = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.minDistance, (target, value) => target.minDistance = value, to, duration) + .SetReference(joint); public static Tween TweenMaxDistance(this SpringJoint joint, float to, float duration) => - Tweening.To(joint, (source) => source.maxDistance, (source, value) => source.maxDistance = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.maxDistance, (target, value) => target.maxDistance = value, to, duration) + .SetReference(joint); public static Tween TweenTolerance(this SpringJoint joint, float to, float duration) => - Tweening.To(joint, (source) => source.tolerance, (source, value) => source.tolerance = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.tolerance, (target, value) => target.tolerance = value, to, duration) + .SetReference(joint); } } diff --git a/Runtime/Extensions/Physics/WheelColliderTweens.cs b/Runtime/Extensions/Physics/WheelColliderTweens.cs index 8ab9902..b58d8ee 100644 --- a/Runtime/Extensions/Physics/WheelColliderTweens.cs +++ b/Runtime/Extensions/Physics/WheelColliderTweens.cs @@ -5,44 +5,44 @@ namespace Zigurous.Tweening public static class WheelColliderTweens { public static Tween TweenForceAppPointDistance(this WheelCollider collider, float to, float duration) => - Tweening.To(collider, (source) => source.forceAppPointDistance, (source, value) => source.forceAppPointDistance = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.forceAppPointDistance, (target, value) => target.forceAppPointDistance = value, to, duration) + .SetReference(collider); public static Tween TweenSteerAngle(this WheelCollider collider, float to, float duration) => - Tweening.To(collider, (source) => source.steerAngle, (source, value) => source.steerAngle = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.steerAngle, (target, value) => target.steerAngle = value, to, duration) + .SetReference(collider); public static Tween TweenBreakTorque(this WheelCollider collider, float to, float duration) => - Tweening.To(collider, (source) => source.brakeTorque, (source, value) => source.brakeTorque = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.brakeTorque, (target, value) => target.brakeTorque = value, to, duration) + .SetReference(collider); public static Tween TweenMotorTorque(this WheelCollider collider, float to, float duration) => - Tweening.To(collider, (source) => source.motorTorque, (source, value) => source.motorTorque = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.motorTorque, (target, value) => target.motorTorque = value, to, duration) + .SetReference(collider); public static Tween TweenWheelDampingRate(this WheelCollider collider, float to, float duration) => - Tweening.To(collider, (source) => source.wheelDampingRate, (source, value) => source.wheelDampingRate = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.wheelDampingRate, (target, value) => target.wheelDampingRate = value, to, duration) + .SetReference(collider); public static Tween TweenMass(this WheelCollider collider, float to, float duration) => - Tweening.To(collider, (source) => source.mass, (source, value) => source.mass = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.mass, (target, value) => target.mass = value, to, duration) + .SetReference(collider); public static Tween TweenSprungMass(this WheelCollider collider, float to, float duration) => - Tweening.To(collider, (source) => source.sprungMass, (source, value) => source.sprungMass = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.sprungMass, (target, value) => target.sprungMass = value, to, duration) + .SetReference(collider); public static Tween TweenSuspensionDistance(this WheelCollider collider, float to, float duration) => - Tweening.To(collider, (source) => source.suspensionDistance, (source, value) => source.suspensionDistance = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.suspensionDistance, (target, value) => target.suspensionDistance = value, to, duration) + .SetReference(collider); public static Tween TweenRadius(this WheelCollider collider, float to, float duration) => - Tweening.To(collider, (source) => source.radius, (source, value) => source.radius = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.radius, (target, value) => target.radius = value, to, duration) + .SetReference(collider); public static Tween TweenCenter(this WheelCollider collider, Vector3 to, float duration) => - Tweening.To(collider, (source) => source.center, (source, value) => source.center = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.center, (target, value) => target.center = value, to, duration) + .SetReference(collider); } } diff --git a/Runtime/Extensions/Physics2D/AnchoredJoint2DTweens.cs b/Runtime/Extensions/Physics2D/AnchoredJoint2DTweens.cs index 895fba5..78abb01 100644 --- a/Runtime/Extensions/Physics2D/AnchoredJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/AnchoredJoint2DTweens.cs @@ -5,12 +5,12 @@ namespace Zigurous.Tweening public static class AnchoredJoint2DTweens { public static Tween TweenAnchor(this AnchoredJoint2D joint, Vector2 to, float duration) => - Tweening.To(joint, (source) => source.anchor, (source, value) => source.anchor = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.anchor, (target, value) => target.anchor = value, to, duration) + .SetReference(joint); public static Tween TweenConnectedAnchor(this AnchoredJoint2D joint, Vector2 to, float duration) => - Tweening.To(joint, (source) => source.connectedAnchor, (source, value) => source.connectedAnchor = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.connectedAnchor, (target, value) => target.connectedAnchor = value, to, duration) + .SetReference(joint); } } diff --git a/Runtime/Extensions/Physics2D/AreaEffector2DTweens.cs b/Runtime/Extensions/Physics2D/AreaEffector2DTweens.cs index 68d3f2c..1895109 100644 --- a/Runtime/Extensions/Physics2D/AreaEffector2DTweens.cs +++ b/Runtime/Extensions/Physics2D/AreaEffector2DTweens.cs @@ -5,24 +5,24 @@ namespace Zigurous.Tweening public static class AreaEffector2DTweens { public static Tween TweenForceAngle(this AreaEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.forceAngle, (source, value) => source.forceAngle = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.forceAngle, (target, value) => target.forceAngle = value, to, duration) + .SetReference(effector); public static Tween TweenForceMagnitude(this AreaEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.forceMagnitude, (source, value) => source.forceMagnitude = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.forceMagnitude, (target, value) => target.forceMagnitude = value, to, duration) + .SetReference(effector); public static Tween TweenForceVariation(this AreaEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.forceVariation, (source, value) => source.forceVariation = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.forceVariation, (target, value) => target.forceVariation = value, to, duration) + .SetReference(effector); public static Tween TweenDrag(this AreaEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.drag, (source, value) => source.drag = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.drag, (target, value) => target.drag = value, to, duration) + .SetReference(effector); public static Tween TweenAngularDrag(this AreaEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.angularDrag, (source, value) => source.angularDrag = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.angularDrag, (target, value) => target.angularDrag = value, to, duration) + .SetReference(effector); } } diff --git a/Runtime/Extensions/Physics2D/BoxCollider2DTweens.cs b/Runtime/Extensions/Physics2D/BoxCollider2DTweens.cs index 8cdadad..93173ad 100644 --- a/Runtime/Extensions/Physics2D/BoxCollider2DTweens.cs +++ b/Runtime/Extensions/Physics2D/BoxCollider2DTweens.cs @@ -5,12 +5,12 @@ namespace Zigurous.Tweening public static class BoxCollider2DTweens { public static Tween TweenSize(this BoxCollider2D collider, Vector2 to, float duration) => - Tweening.To(collider, (source) => source.size, (source, value) => source.size = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.size, (target, value) => target.size = value, to, duration) + .SetReference(collider); public static Tween TweenEdgeRadius(this BoxCollider2D collider, float to, float duration) => - Tweening.To(collider, (source) => source.edgeRadius, (source, value) => source.edgeRadius = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.edgeRadius, (target, value) => target.edgeRadius = value, to, duration) + .SetReference(collider); } } diff --git a/Runtime/Extensions/Physics2D/BuoyancyEffector2DTweens.cs b/Runtime/Extensions/Physics2D/BuoyancyEffector2DTweens.cs index a66a7d5..52a2a52 100644 --- a/Runtime/Extensions/Physics2D/BuoyancyEffector2DTweens.cs +++ b/Runtime/Extensions/Physics2D/BuoyancyEffector2DTweens.cs @@ -5,32 +5,32 @@ namespace Zigurous.Tweening public static class BuoyancyEffector2DTweens { public static Tween TweenSurfaceLevel(this BuoyancyEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.surfaceLevel, (source, value) => source.surfaceLevel = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.surfaceLevel, (target, value) => target.surfaceLevel = value, to, duration) + .SetReference(effector); public static Tween TweenDensity(this BuoyancyEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.density, (source, value) => source.density = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.density, (target, value) => target.density = value, to, duration) + .SetReference(effector); public static Tween TweenLinearDrag(this BuoyancyEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.linearDrag, (source, value) => source.linearDrag = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.linearDrag, (target, value) => target.linearDrag = value, to, duration) + .SetReference(effector); public static Tween TweenAngularDrag(this BuoyancyEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.angularDrag, (source, value) => source.angularDrag = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.angularDrag, (target, value) => target.angularDrag = value, to, duration) + .SetReference(effector); public static Tween TweenFlowAngle(this BuoyancyEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.flowAngle, (source, value) => source.flowAngle = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.flowAngle, (target, value) => target.flowAngle = value, to, duration) + .SetReference(effector); public static Tween TweenFlowMagnitude(this BuoyancyEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.flowMagnitude, (source, value) => source.flowMagnitude = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.flowMagnitude, (target, value) => target.flowMagnitude = value, to, duration) + .SetReference(effector); public static Tween TweenFlowVariation(this BuoyancyEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.flowVariation, (source, value) => source.flowVariation = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.flowVariation, (target, value) => target.flowVariation = value, to, duration) + .SetReference(effector); } } diff --git a/Runtime/Extensions/Physics2D/CapsuleCollider2DTweens.cs b/Runtime/Extensions/Physics2D/CapsuleCollider2DTweens.cs index ca5838c..caea7b4 100644 --- a/Runtime/Extensions/Physics2D/CapsuleCollider2DTweens.cs +++ b/Runtime/Extensions/Physics2D/CapsuleCollider2DTweens.cs @@ -5,8 +5,8 @@ namespace Zigurous.Tweening public static class CapsuleCollider2DTweens { public static Tween TweenSize(this CapsuleCollider2D collider, Vector2 to, float duration) => - Tweening.To(collider, (source) => source.size, (source, value) => source.size = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.size, (target, value) => target.size = value, to, duration) + .SetReference(collider); } } diff --git a/Runtime/Extensions/Physics2D/CircleCollider2DTweens.cs b/Runtime/Extensions/Physics2D/CircleCollider2DTweens.cs index f8fac5e..97f5cec 100644 --- a/Runtime/Extensions/Physics2D/CircleCollider2DTweens.cs +++ b/Runtime/Extensions/Physics2D/CircleCollider2DTweens.cs @@ -5,8 +5,8 @@ namespace Zigurous.Tweening public static class CircleCollider2DTweens { public static Tween TweenRadius(this CircleCollider2D collider, float to, float duration) => - Tweening.To(collider, (source) => source.radius, (source, value) => source.radius = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.radius, (target, value) => target.radius = value, to, duration) + .SetReference(collider); } } diff --git a/Runtime/Extensions/Physics2D/Collider2DTweens.cs b/Runtime/Extensions/Physics2D/Collider2DTweens.cs index c1104b7..3a33849 100644 --- a/Runtime/Extensions/Physics2D/Collider2DTweens.cs +++ b/Runtime/Extensions/Physics2D/Collider2DTweens.cs @@ -5,12 +5,12 @@ namespace Zigurous.Tweening public static class Collider2DTweens { public static Tween TweenDensity(this Collider2D collider, float to, float duration) => - Tweening.To(collider, (source) => source.density, (source, value) => source.density = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.density, (target, value) => target.density = value, to, duration) + .SetReference(collider); public static Tween TweenOffset(this Collider2D collider, Vector2 to, float duration) => - Tweening.To(collider, (source) => source.offset, (source, value) => source.offset = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.offset, (target, value) => target.offset = value, to, duration) + .SetReference(collider); } } diff --git a/Runtime/Extensions/Physics2D/CompositeCollider2DTweens.cs b/Runtime/Extensions/Physics2D/CompositeCollider2DTweens.cs index 4c2f8cc..3a3e22d 100644 --- a/Runtime/Extensions/Physics2D/CompositeCollider2DTweens.cs +++ b/Runtime/Extensions/Physics2D/CompositeCollider2DTweens.cs @@ -5,16 +5,16 @@ namespace Zigurous.Tweening public static class CompositeCollider2DTweens { public static Tween TweenVertexDistance(this CompositeCollider2D collider, float to, float duration) => - Tweening.To(collider, (source) => source.vertexDistance, (source, value) => source.vertexDistance = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.vertexDistance, (target, value) => target.vertexDistance = value, to, duration) + .SetReference(collider); public static Tween TweenEdgeRadius(this CompositeCollider2D collider, float to, float duration) => - Tweening.To(collider, (source) => source.edgeRadius, (source, value) => source.edgeRadius = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.edgeRadius, (target, value) => target.edgeRadius = value, to, duration) + .SetReference(collider); public static Tween TweenOffsetDistance(this CompositeCollider2D collider, float to, float duration) => - Tweening.To(collider, (source) => source.offsetDistance, (source, value) => source.offsetDistance = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.offsetDistance, (target, value) => target.offsetDistance = value, to, duration) + .SetReference(collider); } } diff --git a/Runtime/Extensions/Physics2D/ConstantForce2DTweens.cs b/Runtime/Extensions/Physics2D/ConstantForce2DTweens.cs index f1914d5..153307b 100644 --- a/Runtime/Extensions/Physics2D/ConstantForce2DTweens.cs +++ b/Runtime/Extensions/Physics2D/ConstantForce2DTweens.cs @@ -5,16 +5,16 @@ namespace Zigurous.Tweening public static class ConstantForce2DTweens { public static Tween TweenForce(this ConstantForce2D constantForce, Vector2 to, float duration) => - Tweening.To(constantForce, (source) => source.force, (source, value) => source.force = value, to, duration) - .SetTarget(constantForce); + Tweening.To(constantForce, (target) => target.force, (target, value) => target.force = value, to, duration) + .SetReference(constantForce); public static Tween TweenRelativeForce(this ConstantForce2D constantForce, Vector2 to, float duration) => - Tweening.To(constantForce, (source) => source.relativeForce, (source, value) => source.relativeForce = value, to, duration) - .SetTarget(constantForce); + Tweening.To(constantForce, (target) => target.relativeForce, (target, value) => target.relativeForce = value, to, duration) + .SetReference(constantForce); public static Tween TweenTorque(this ConstantForce2D constantForce, float to, float duration) => - Tweening.To(constantForce, (source) => source.torque, (source, value) => source.torque = value, to, duration) - .SetTarget(constantForce); + Tweening.To(constantForce, (target) => target.torque, (target, value) => target.torque = value, to, duration) + .SetReference(constantForce); } } diff --git a/Runtime/Extensions/Physics2D/DistanceJoint2DTweens.cs b/Runtime/Extensions/Physics2D/DistanceJoint2DTweens.cs index 4027e69..02f3f5a 100644 --- a/Runtime/Extensions/Physics2D/DistanceJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/DistanceJoint2DTweens.cs @@ -5,8 +5,8 @@ namespace Zigurous.Tweening public static class DistanceJoint2DTweens { public static Tween TweenDistance(this DistanceJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.distance, (source, value) => source.distance = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.distance, (target, value) => target.distance = value, to, duration) + .SetReference(joint); } } diff --git a/Runtime/Extensions/Physics2D/EdgeCollider2DTweens.cs b/Runtime/Extensions/Physics2D/EdgeCollider2DTweens.cs index 2feada7..5807d0e 100644 --- a/Runtime/Extensions/Physics2D/EdgeCollider2DTweens.cs +++ b/Runtime/Extensions/Physics2D/EdgeCollider2DTweens.cs @@ -5,8 +5,8 @@ namespace Zigurous.Tweening public static class EdgeCollider2DTweens { public static Tween TweenEdgeRadius(this EdgeCollider2D collider, float to, float duration) => - Tweening.To(collider, (source) => source.edgeRadius, (source, value) => source.edgeRadius = value, to, duration) - .SetTarget(collider); + Tweening.To(collider, (target) => target.edgeRadius, (target, value) => target.edgeRadius = value, to, duration) + .SetReference(collider); } } diff --git a/Runtime/Extensions/Physics2D/FixedJoint2DTweens.cs b/Runtime/Extensions/Physics2D/FixedJoint2DTweens.cs index fe531da..a9f574c 100644 --- a/Runtime/Extensions/Physics2D/FixedJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/FixedJoint2DTweens.cs @@ -5,12 +5,12 @@ namespace Zigurous.Tweening public static class FixedJoint2DTweens { public static Tween TweenDampingRatio(this FixedJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.dampingRatio, (source, value) => source.dampingRatio = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.dampingRatio, (target, value) => target.dampingRatio = value, to, duration) + .SetReference(joint); public static Tween TweenFrequency(this FixedJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.frequency, (source, value) => source.frequency = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.frequency, (target, value) => target.frequency = value, to, duration) + .SetReference(joint); } } diff --git a/Runtime/Extensions/Physics2D/FrictionJoint2DTweens.cs b/Runtime/Extensions/Physics2D/FrictionJoint2DTweens.cs index e99f234..e93c3dc 100644 --- a/Runtime/Extensions/Physics2D/FrictionJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/FrictionJoint2DTweens.cs @@ -5,12 +5,12 @@ namespace Zigurous.Tweening public static class FrictionJoint2DTweens { public static Tween TweenMaxForce(this FrictionJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.maxForce, (source, value) => source.maxForce = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.maxForce, (target, value) => target.maxForce = value, to, duration) + .SetReference(joint); public static Tween TweenMaxTorque(this FrictionJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.maxTorque, (source, value) => source.maxTorque = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.maxTorque, (target, value) => target.maxTorque = value, to, duration) + .SetReference(joint); } } diff --git a/Runtime/Extensions/Physics2D/Joint2DTweens.cs b/Runtime/Extensions/Physics2D/Joint2DTweens.cs index dde26c9..3e1163c 100644 --- a/Runtime/Extensions/Physics2D/Joint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/Joint2DTweens.cs @@ -5,12 +5,12 @@ namespace Zigurous.Tweening public static class Joint2DTweens { public static Tween TweenBreakForce(this Joint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.breakForce, (source, value) => source.breakForce = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.breakForce, (target, value) => target.breakForce = value, to, duration) + .SetReference(joint); public static Tween TweenBreakTorque(this Joint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.breakTorque, (source, value) => source.breakTorque = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.breakTorque, (target, value) => target.breakTorque = value, to, duration) + .SetReference(joint); } } diff --git a/Runtime/Extensions/Physics2D/PhysicsMaterial2DTweens.cs b/Runtime/Extensions/Physics2D/PhysicsMaterial2DTweens.cs index 4750ebb..1ada992 100644 --- a/Runtime/Extensions/Physics2D/PhysicsMaterial2DTweens.cs +++ b/Runtime/Extensions/Physics2D/PhysicsMaterial2DTweens.cs @@ -5,12 +5,12 @@ namespace Zigurous.Tweening public static class PhysicsMaterial2DTweens { public static Tween TweenBounciness(this PhysicsMaterial2D material, float to, float duration) => - Tweening.To(material, (source) => source.bounciness, (source, value) => source.bounciness = value, to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.bounciness, (target, value) => target.bounciness = value, to, duration) + .SetReference(material); public static Tween TweenFriction(this PhysicsMaterial2D material, float to, float duration) => - Tweening.To(material, (source) => source.friction, (source, value) => source.friction = value, to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.friction, (target, value) => target.friction = value, to, duration) + .SetReference(material); } } diff --git a/Runtime/Extensions/Physics2D/PlatformEffector2DTweens.cs b/Runtime/Extensions/Physics2D/PlatformEffector2DTweens.cs index ce33d80..46fe396 100644 --- a/Runtime/Extensions/Physics2D/PlatformEffector2DTweens.cs +++ b/Runtime/Extensions/Physics2D/PlatformEffector2DTweens.cs @@ -5,16 +5,16 @@ namespace Zigurous.Tweening public static class PlatformEffector2DTweens { public static Tween TweenSurfaceArc(this PlatformEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.surfaceArc, (source, value) => source.surfaceArc = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.surfaceArc, (target, value) => target.surfaceArc = value, to, duration) + .SetReference(effector); public static Tween TweenSideArc(this PlatformEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.sideArc, (source, value) => source.sideArc = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.sideArc, (target, value) => target.sideArc = value, to, duration) + .SetReference(effector); public static Tween TweenRotationalOffset(this PlatformEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.rotationalOffset, (source, value) => source.rotationalOffset = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.rotationalOffset, (target, value) => target.rotationalOffset = value, to, duration) + .SetReference(effector); } } diff --git a/Runtime/Extensions/Physics2D/PointEffector2DTweens.cs b/Runtime/Extensions/Physics2D/PointEffector2DTweens.cs index f182891..d5e3dc5 100644 --- a/Runtime/Extensions/Physics2D/PointEffector2DTweens.cs +++ b/Runtime/Extensions/Physics2D/PointEffector2DTweens.cs @@ -5,24 +5,24 @@ namespace Zigurous.Tweening public static class PointEffector2DTweens { public static Tween TweenDrag(this PointEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.drag, (source, value) => source.drag = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.drag, (target, value) => target.drag = value, to, duration) + .SetReference(effector); public static Tween TweenAngularDrag(this PointEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.angularDrag, (source, value) => source.angularDrag = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.angularDrag, (target, value) => target.angularDrag = value, to, duration) + .SetReference(effector); public static Tween TweenForceMagnitude(this PointEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.forceMagnitude, (source, value) => source.forceMagnitude = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.forceMagnitude, (target, value) => target.forceMagnitude = value, to, duration) + .SetReference(effector); public static Tween TweenForceVariation(this PointEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.forceVariation, (source, value) => source.forceVariation = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.forceVariation, (target, value) => target.forceVariation = value, to, duration) + .SetReference(effector); public static Tween TweenDistanceScale(this PointEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.distanceScale, (source, value) => source.distanceScale = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.distanceScale, (target, value) => target.distanceScale = value, to, duration) + .SetReference(effector); } } diff --git a/Runtime/Extensions/Physics2D/RelativeJoint2DTweens.cs b/Runtime/Extensions/Physics2D/RelativeJoint2DTweens.cs index 72915fd..0b3321e 100644 --- a/Runtime/Extensions/Physics2D/RelativeJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/RelativeJoint2DTweens.cs @@ -5,24 +5,24 @@ namespace Zigurous.Tweening public static class RelativeJoint2DTweens { public static Tween TweenMaxForce(this RelativeJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.maxForce, (source, value) => source.maxForce = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.maxForce, (target, value) => target.maxForce = value, to, duration) + .SetReference(joint); public static Tween TweenMaxTorque(this RelativeJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.maxTorque, (source, value) => source.maxTorque = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.maxTorque, (target, value) => target.maxTorque = value, to, duration) + .SetReference(joint); public static Tween TweenCorrectionScale(this RelativeJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.correctionScale, (source, value) => source.correctionScale = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.correctionScale, (target, value) => target.correctionScale = value, to, duration) + .SetReference(joint); public static Tween TweenLinearOffset(this RelativeJoint2D joint, Vector2 to, float duration) => - Tweening.To(joint, (source) => source.linearOffset, (source, value) => source.linearOffset = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.linearOffset, (target, value) => target.linearOffset = value, to, duration) + .SetReference(joint); public static Tween TweenAngularOffset(this RelativeJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.angularOffset, (source, value) => source.angularOffset = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.angularOffset, (target, value) => target.angularOffset = value, to, duration) + .SetReference(joint); } } diff --git a/Runtime/Extensions/Physics2D/Rigidbody2DTweens.cs b/Runtime/Extensions/Physics2D/Rigidbody2DTweens.cs index 542c88c..2583377 100644 --- a/Runtime/Extensions/Physics2D/Rigidbody2DTweens.cs +++ b/Runtime/Extensions/Physics2D/Rigidbody2DTweens.cs @@ -5,44 +5,44 @@ namespace Zigurous.Tweening public static class Rigidbody2DTweens { public static Tween TweenPosition(this Rigidbody2D rigidbody, Vector2 to, float duration) => - Tweening.To(rigidbody, (source) => source.position, (source, value) => source.position = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.position, (target, value) => target.position = value, to, duration) + .SetReference(rigidbody); public static Tween TweenRotation(this Rigidbody2D rigidbody, float to, float duration) => - Tweening.To(rigidbody, (source) => source.rotation, (source, value) => source.rotation = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.rotation, (target, value) => target.rotation = value, to, duration) + .SetReference(rigidbody); public static Tween TweenVelocity(this Rigidbody2D rigidbody, Vector2 to, float duration) => - Tweening.To(rigidbody, (source) => source.velocity, (source, value) => source.velocity = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.velocity, (target, value) => target.velocity = value, to, duration) + .SetReference(rigidbody); public static Tween TweenAngularVelocity(this Rigidbody2D rigidbody, float to, float duration) => - Tweening.To(rigidbody, (source) => source.angularVelocity, (source, value) => source.angularVelocity = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.angularVelocity, (target, value) => target.angularVelocity = value, to, duration) + .SetReference(rigidbody); public static Tween TweenMass(this Rigidbody2D rigidbody, float to, float duration) => - Tweening.To(rigidbody, (source) => source.mass, (source, value) => source.mass = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.mass, (target, value) => target.mass = value, to, duration) + .SetReference(rigidbody); public static Tween TweenCenterOfMass(this Rigidbody2D rigidbody, Vector2 to, float duration) => - Tweening.To(rigidbody, (source) => source.centerOfMass, (source, value) => source.centerOfMass = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.centerOfMass, (target, value) => target.centerOfMass = value, to, duration) + .SetReference(rigidbody); public static Tween TweenDrag(this Rigidbody2D rigidbody, float to, float duration) => - Tweening.To(rigidbody, (source) => source.drag, (source, value) => source.drag = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.drag, (target, value) => target.drag = value, to, duration) + .SetReference(rigidbody); public static Tween TweenAngularDrag(this Rigidbody2D rigidbody, float to, float duration) => - Tweening.To(rigidbody, (source) => source.angularDrag, (source, value) => source.angularDrag = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.angularDrag, (target, value) => target.angularDrag = value, to, duration) + .SetReference(rigidbody); public static Tween TweenInertia(this Rigidbody2D rigidbody, float to, float duration) => - Tweening.To(rigidbody, (source) => source.inertia, (source, value) => source.inertia = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.inertia, (target, value) => target.inertia = value, to, duration) + .SetReference(rigidbody); public static Tween TweenGravityScale(this Rigidbody2D rigidbody, float to, float duration) => - Tweening.To(rigidbody, (source) => source.gravityScale, (source, value) => source.gravityScale = value, to, duration) - .SetTarget(rigidbody); + Tweening.To(rigidbody, (target) => target.gravityScale, (target, value) => target.gravityScale = value, to, duration) + .SetReference(rigidbody); } } diff --git a/Runtime/Extensions/Physics2D/SliderJoint2DTweens.cs b/Runtime/Extensions/Physics2D/SliderJoint2DTweens.cs index 6758408..46a465e 100644 --- a/Runtime/Extensions/Physics2D/SliderJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/SliderJoint2DTweens.cs @@ -5,8 +5,8 @@ namespace Zigurous.Tweening public static class SliderJoint2DTweens { public static Tween TweenAngle(this SliderJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.angle, (source, value) => source.angle = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.angle, (target, value) => target.angle = value, to, duration) + .SetReference(joint); } } diff --git a/Runtime/Extensions/Physics2D/SpringJoint2DTweens.cs b/Runtime/Extensions/Physics2D/SpringJoint2DTweens.cs index 7a834b6..b0812e6 100644 --- a/Runtime/Extensions/Physics2D/SpringJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/SpringJoint2DTweens.cs @@ -5,16 +5,16 @@ namespace Zigurous.Tweening public static class SpringJoint2DTweens { public static Tween TweenDistance(this SpringJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.distance, (source, value) => source.distance = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.distance, (target, value) => target.distance = value, to, duration) + .SetReference(joint); public static Tween TweenDampingRatio(this SpringJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.dampingRatio, (source, value) => source.dampingRatio = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.dampingRatio, (target, value) => target.dampingRatio = value, to, duration) + .SetReference(joint); public static Tween TweenFrequency(this SpringJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.frequency, (source, value) => source.frequency = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.frequency, (target, value) => target.frequency = value, to, duration) + .SetReference(joint); } } diff --git a/Runtime/Extensions/Physics2D/SurfaceEffector2DTweens.cs b/Runtime/Extensions/Physics2D/SurfaceEffector2DTweens.cs index 317d1b9..d578754 100644 --- a/Runtime/Extensions/Physics2D/SurfaceEffector2DTweens.cs +++ b/Runtime/Extensions/Physics2D/SurfaceEffector2DTweens.cs @@ -5,16 +5,16 @@ namespace Zigurous.Tweening public static class SurfaceEffector2DTweens { public static Tween TweenSpeed(this SurfaceEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.speed, (source, value) => source.speed = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.speed, (target, value) => target.speed = value, to, duration) + .SetReference(effector); public static Tween TweenSpeedVariation(this SurfaceEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.speedVariation, (source, value) => source.speedVariation = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.speedVariation, (target, value) => target.speedVariation = value, to, duration) + .SetReference(effector); public static Tween TweenForceScale(this SurfaceEffector2D effector, float to, float duration) => - Tweening.To(effector, (source) => source.forceScale, (source, value) => source.forceScale = value, to, duration) - .SetTarget(effector); + Tweening.To(effector, (target) => target.forceScale, (target, value) => target.forceScale = value, to, duration) + .SetReference(effector); } } diff --git a/Runtime/Extensions/Physics2D/TargetJoint2DTweens.cs b/Runtime/Extensions/Physics2D/TargetJoint2DTweens.cs index 6d0be5a..f1d708e 100644 --- a/Runtime/Extensions/Physics2D/TargetJoint2DTweens.cs +++ b/Runtime/Extensions/Physics2D/TargetJoint2DTweens.cs @@ -5,24 +5,24 @@ namespace Zigurous.Tweening public static class TargetJoint2DTweens { public static Tween TweenAnchor(this TargetJoint2D joint, Vector2 to, float duration) => - Tweening.To(joint, (source) => source.anchor, (source, value) => source.anchor = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.anchor, (target, value) => target.anchor = value, to, duration) + .SetReference(joint); public static Tween TweenTarget(this TargetJoint2D joint, Vector2 to, float duration) => - Tweening.To(joint, (source) => source.target, (source, value) => source.target = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.target, (target, value) => target.target = value, to, duration) + .SetReference(joint); public static Tween TweenMaxForce(this TargetJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.maxForce, (source, value) => source.maxForce = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.maxForce, (target, value) => target.maxForce = value, to, duration) + .SetReference(joint); public static Tween TweenDampingRatio(this TargetJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.dampingRatio, (source, value) => source.dampingRatio = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.dampingRatio, (target, value) => target.dampingRatio = value, to, duration) + .SetReference(joint); public static Tween TweenFrequency(this TargetJoint2D joint, float to, float duration) => - Tweening.To(joint, (source) => source.frequency, (source, value) => source.frequency = value, to, duration) - .SetTarget(joint); + Tweening.To(joint, (target) => target.frequency, (target, value) => target.frequency = value, to, duration) + .SetReference(joint); } } diff --git a/Runtime/Extensions/Rendering/AnimatorTweens.cs b/Runtime/Extensions/Rendering/AnimatorTweens.cs index ed93322..2c560c3 100644 --- a/Runtime/Extensions/Rendering/AnimatorTweens.cs +++ b/Runtime/Extensions/Rendering/AnimatorTweens.cs @@ -5,32 +5,32 @@ namespace Zigurous.Tweening public static class AnimatorTweens { public static Tween TweenSpeed(this Animator animator, float to, float duration) => - Tweening.To(animator, (source) => source.speed, (source, value) => source.speed = value, to, duration) - .SetTarget(animator); + Tweening.To(animator, (target) => target.speed, (target, value) => target.speed = value, to, duration) + .SetReference(animator); public static Tween TweenPlaybackTime(this Animator animator, float to, float duration) => - Tweening.To(animator, (source) => source.playbackTime, (source, value) => source.playbackTime = value, to, duration) - .SetTarget(animator); + Tweening.To(animator, (target) => target.playbackTime, (target, value) => target.playbackTime = value, to, duration) + .SetReference(animator); public static Tween TweenBodyRotation(this Animator animator, Quaternion to, float duration) => - Tweening.To(animator, (source) => source.bodyRotation, (source, value) => source.bodyRotation = value, to, duration) - .SetTarget(animator); + Tweening.To(animator, (target) => target.bodyRotation, (target, value) => target.bodyRotation = value, to, duration) + .SetReference(animator); public static Tween TweenBodyPosition(this Animator animator, Vector3 to, float duration) => - Tweening.To(animator, (source) => source.bodyPosition, (source, value) => source.bodyPosition = value, to, duration) - .SetTarget(animator); + Tweening.To(animator, (target) => target.bodyPosition, (target, value) => target.bodyPosition = value, to, duration) + .SetReference(animator); public static Tween TweenRootRotation(this Animator animator, Quaternion to, float duration) => - Tweening.To(animator, (source) => source.rootRotation, (source, value) => source.rootRotation = value, to, duration) - .SetTarget(animator); + Tweening.To(animator, (target) => target.rootRotation, (target, value) => target.rootRotation = value, to, duration) + .SetReference(animator); public static Tween TweenRootPosition(this Animator animator, Vector3 to, float duration) => - Tweening.To(animator, (source) => source.rootPosition, (source, value) => source.rootPosition = value, to, duration) - .SetTarget(animator); + Tweening.To(animator, (target) => target.rootPosition, (target, value) => target.rootPosition = value, to, duration) + .SetReference(animator); public static Tween TweenFeetPivotActive(this Animator animator, float to, float duration) => - Tweening.To(animator, (source) => source.feetPivotActive, (source, value) => source.feetPivotActive = value, to, duration) - .SetTarget(animator); + Tweening.To(animator, (target) => target.feetPivotActive, (target, value) => target.feetPivotActive = value, to, duration) + .SetReference(animator); } } diff --git a/Runtime/Extensions/Rendering/CameraTweens.cs b/Runtime/Extensions/Rendering/CameraTweens.cs index 9ca14e8..992b971 100644 --- a/Runtime/Extensions/Rendering/CameraTweens.cs +++ b/Runtime/Extensions/Rendering/CameraTweens.cs @@ -5,60 +5,60 @@ namespace Zigurous.Tweening public static class CameraTweens { public static Tween TweenBackgroundColor(this Camera camera, Color to, float duration) => - Tweening.To(camera, (source) => source.backgroundColor, (source, value) => source.backgroundColor = value, to, duration) - .SetTarget(camera); + Tweening.To(camera, (target) => target.backgroundColor, (target, value) => target.backgroundColor = value, to, duration) + .SetReference(camera); public static Tween TweenAspectRatio(this Camera camera, float to, float duration) => - Tweening.To(camera, (source) => source.aspect, (source, value) => source.aspect = value, to, duration) - .SetTarget(camera); + Tweening.To(camera, (target) => target.aspect, (target, value) => target.aspect = value, to, duration) + .SetReference(camera); public static Tween TweenFieldOfView(this Camera camera, float to, float duration) => - Tweening.To(camera, (source) => source.fieldOfView, (source, value) => source.fieldOfView = value, to, duration) - .SetTarget(camera); + Tweening.To(camera, (target) => target.fieldOfView, (target, value) => target.fieldOfView = value, to, duration) + .SetReference(camera); public static Tween TweenNearClipPlane(this Camera camera, float to, float duration) => - Tweening.To(camera, (source) => source.nearClipPlane, (source, value) => source.nearClipPlane = value, to, duration) - .SetTarget(camera); + Tweening.To(camera, (target) => target.nearClipPlane, (target, value) => target.nearClipPlane = value, to, duration) + .SetReference(camera); public static Tween TweenFarClipPlane(this Camera camera, float to, float duration) => - Tweening.To(camera, (source) => source.farClipPlane, (source, value) => source.farClipPlane = value, to, duration) - .SetTarget(camera); + Tweening.To(camera, (target) => target.farClipPlane, (target, value) => target.farClipPlane = value, to, duration) + .SetReference(camera); public static Tween TweenOrthographicSize(this Camera camera, float to, float duration) => - Tweening.To(camera, (source) => source.orthographicSize, (source, value) => source.orthographicSize = value, to, duration) - .SetTarget(camera); + Tweening.To(camera, (target) => target.orthographicSize, (target, value) => target.orthographicSize = value, to, duration) + .SetReference(camera); public static Tween TweenSensorSize(this Camera camera, Vector2 to, float duration) => - Tweening.To(camera, (source) => source.sensorSize, (source, value) => source.sensorSize = value, to, duration) - .SetTarget(camera); + Tweening.To(camera, (target) => target.sensorSize, (target, value) => target.sensorSize = value, to, duration) + .SetReference(camera); public static Tween TweenFocalLength(this Camera camera, float to, float duration) => - Tweening.To(camera, (source) => source.focalLength, (source, value) => source.focalLength = value, to, duration) - .SetTarget(camera); + Tweening.To(camera, (target) => target.focalLength, (target, value) => target.focalLength = value, to, duration) + .SetReference(camera); public static Tween TweenStereoConvergence(this Camera camera, float to, float duration) => - Tweening.To(camera, (source) => source.stereoConvergence, (source, value) => source.stereoConvergence = value, to, duration) - .SetTarget(camera); + Tweening.To(camera, (target) => target.stereoConvergence, (target, value) => target.stereoConvergence = value, to, duration) + .SetReference(camera); public static Tween TweenStereoSeparation(this Camera camera, float to, float duration) => - Tweening.To(camera, (source) => source.stereoSeparation, (source, value) => source.stereoSeparation = value, to, duration) - .SetTarget(camera); + Tweening.To(camera, (target) => target.stereoSeparation, (target, value) => target.stereoSeparation = value, to, duration) + .SetReference(camera); public static Tween TweenLensShift(this Camera camera, Vector2 to, float duration) => - Tweening.To(camera, (source) => source.lensShift, (source, value) => source.lensShift = value, to, duration) - .SetTarget(camera); + Tweening.To(camera, (target) => target.lensShift, (target, value) => target.lensShift = value, to, duration) + .SetReference(camera); public static Tween TweenRect(this Camera camera, Rect to, float duration) => - Tweening.To(camera, (source) => source.rect, (source, value) => source.rect = value, to, duration) - .SetTarget(camera); + Tweening.To(camera, (target) => target.rect, (target, value) => target.rect = value, to, duration) + .SetReference(camera); public static Tween TweenPixelRect(this Camera camera, Rect to, float duration) => - Tweening.To(camera, (source) => source.pixelRect, (source, value) => source.pixelRect = value, to, duration) - .SetTarget(camera); + Tweening.To(camera, (target) => target.pixelRect, (target, value) => target.pixelRect = value, to, duration) + .SetReference(camera); public static Tween TweenDepth(this Camera camera, float to, float duration) => - Tweening.To(camera, (source) => source.depth, (source, value) => source.depth = value, to, duration) - .SetTarget(camera); + Tweening.To(camera, (target) => target.depth, (target, value) => target.depth = value, to, duration) + .SetReference(camera); } } diff --git a/Runtime/Extensions/Rendering/LensFlareTweens.cs b/Runtime/Extensions/Rendering/LensFlareTweens.cs index 7393594..eed0e2d 100644 --- a/Runtime/Extensions/Rendering/LensFlareTweens.cs +++ b/Runtime/Extensions/Rendering/LensFlareTweens.cs @@ -5,16 +5,16 @@ namespace Zigurous.Tweening public static class LensFlareTweens { public static Tween TweenColor(this LensFlare lensFlare, Color to, float duration) => - Tweening.To(lensFlare, (source) => source.color, (source, value) => source.color = value, to, duration) - .SetTarget(lensFlare); + Tweening.To(lensFlare, (target) => target.color, (target, value) => target.color = value, to, duration) + .SetReference(lensFlare); public static Tween TweenBrightness(this LensFlare lensFlare, float to, float duration) => - Tweening.To(lensFlare, (source) => source.brightness, (source, value) => source.brightness = value, to, duration) - .SetTarget(lensFlare); + Tweening.To(lensFlare, (target) => target.brightness, (target, value) => target.brightness = value, to, duration) + .SetReference(lensFlare); public static Tween TweenFadeSpeed(this LensFlare lensFlare, float to, float duration) => - Tweening.To(lensFlare, (source) => source.fadeSpeed, (source, value) => source.fadeSpeed = value, to, duration) - .SetTarget(lensFlare); + Tweening.To(lensFlare, (target) => target.fadeSpeed, (target, value) => target.fadeSpeed = value, to, duration) + .SetReference(lensFlare); } } diff --git a/Runtime/Extensions/Rendering/LightTweens.cs b/Runtime/Extensions/Rendering/LightTweens.cs index 38971dd..96c32be 100644 --- a/Runtime/Extensions/Rendering/LightTweens.cs +++ b/Runtime/Extensions/Rendering/LightTweens.cs @@ -5,56 +5,56 @@ namespace Zigurous.Tweening public static class LightTweens { public static Tween TweenColor(this Light light, Color to, float duration) => - Tweening.To(light, (source) => source.color, (source, value) => source.color = value, to, duration) - .SetTarget(light); + Tweening.To(light, (target) => target.color, (target, value) => target.color = value, to, duration) + .SetReference(light); public static Tween TweenColorTemperature(this Light light, float to, float duration) => - Tweening.To(light, (source) => source.colorTemperature, (source, value) => source.colorTemperature = value, to, duration) - .SetTarget(light); + Tweening.To(light, (target) => target.colorTemperature, (target, value) => target.colorTemperature = value, to, duration) + .SetReference(light); public static Tween TweenIntensity(this Light light, float to, float duration) => - Tweening.To(light, (source) => source.intensity, (source, value) => source.intensity = value, to, duration) - .SetTarget(light); + Tweening.To(light, (target) => target.intensity, (target, value) => target.intensity = value, to, duration) + .SetReference(light); public static Tween TweenBounceIntensity(this Light light, float to, float duration) => - Tweening.To(light, (source) => source.bounceIntensity, (source, value) => source.bounceIntensity = value, to, duration) - .SetTarget(light); + Tweening.To(light, (target) => target.bounceIntensity, (target, value) => target.bounceIntensity = value, to, duration) + .SetReference(light); public static Tween TweenRange(this Light light, float to, float duration) => - Tweening.To(light, (source) => source.range, (source, value) => source.range = value, to, duration) - .SetTarget(light); + Tweening.To(light, (target) => target.range, (target, value) => target.range = value, to, duration) + .SetReference(light); public static Tween TweenShadowStrength(this Light light, float to, float duration) => - Tweening.To(light, (source) => source.shadowStrength, (source, value) => source.shadowStrength = value, to, duration) - .SetTarget(light); + Tweening.To(light, (target) => target.shadowStrength, (target, value) => target.shadowStrength = value, to, duration) + .SetReference(light); public static Tween TweenShadowBias(this Light light, float to, float duration) => - Tweening.To(light, (source) => source.shadowBias, (source, value) => source.shadowBias = value, to, duration) - .SetTarget(light); + Tweening.To(light, (target) => target.shadowBias, (target, value) => target.shadowBias = value, to, duration) + .SetReference(light); public static Tween TweenShadowNormalBias(this Light light, float to, float duration) => - Tweening.To(light, (source) => source.shadowNormalBias, (source, value) => source.shadowNormalBias = value, to, duration) - .SetTarget(light); + Tweening.To(light, (target) => target.shadowNormalBias, (target, value) => target.shadowNormalBias = value, to, duration) + .SetReference(light); public static Tween TweenShadowNearPlane(this Light light, float to, float duration) => - Tweening.To(light, (source) => source.shadowNearPlane, (source, value) => source.shadowNearPlane = value, to, duration) - .SetTarget(light); + Tweening.To(light, (target) => target.shadowNearPlane, (target, value) => target.shadowNearPlane = value, to, duration) + .SetReference(light); public static Tween TweenSpotAngle(this Light light, float to, float duration) => - Tweening.To(light, (source) => source.spotAngle, (source, value) => source.spotAngle = value, to, duration) - .SetTarget(light); + Tweening.To(light, (target) => target.spotAngle, (target, value) => target.spotAngle = value, to, duration) + .SetReference(light); public static Tween TweenInnerSpotAngle(this Light light, float to, float duration) => - Tweening.To(light, (source) => source.innerSpotAngle, (source, value) => source.innerSpotAngle = value, to, duration) - .SetTarget(light); + Tweening.To(light, (target) => target.innerSpotAngle, (target, value) => target.innerSpotAngle = value, to, duration) + .SetReference(light); public static Tween TweenCookieSize(this Light light, float to, float duration) => - Tweening.To(light, (source) => source.cookieSize, (source, value) => source.cookieSize = value, to, duration) - .SetTarget(light); + Tweening.To(light, (target) => target.cookieSize, (target, value) => target.cookieSize = value, to, duration) + .SetReference(light); public static Tween TweenBoundingSphereOverride(this Light light, Vector4 to, float duration) => - Tweening.To(light, (source) => source.boundingSphereOverride, (source, value) => source.boundingSphereOverride = value, to, duration) - .SetTarget(light); + Tweening.To(light, (target) => target.boundingSphereOverride, (target, value) => target.boundingSphereOverride = value, to, duration) + .SetReference(light); } } diff --git a/Runtime/Extensions/Rendering/LineRendererTweens.cs b/Runtime/Extensions/Rendering/LineRendererTweens.cs index 87fb4f8..4e14fe5 100644 --- a/Runtime/Extensions/Rendering/LineRendererTweens.cs +++ b/Runtime/Extensions/Rendering/LineRendererTweens.cs @@ -5,28 +5,28 @@ namespace Zigurous.Tweening public static class LineRendererTweens { public static Tween TweenStartColor(this LineRenderer renderer, Color to, float duration) => - Tweening.To(renderer, (source) => source.startColor, (source, value) => source.startColor = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.startColor, (target, value) => target.startColor = value, to, duration) + .SetReference(renderer); public static Tween TweenEndColor(this LineRenderer renderer, Color to, float duration) => - Tweening.To(renderer, (source) => source.endColor, (source, value) => source.endColor = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.endColor, (target, value) => target.endColor = value, to, duration) + .SetReference(renderer); public static Tween TweenStartWidth(this LineRenderer renderer, float to, float duration) => - Tweening.To(renderer, (source) => source.startWidth, (source, value) => source.startWidth = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.startWidth, (target, value) => target.startWidth = value, to, duration) + .SetReference(renderer); public static Tween TweenEndWidth(this LineRenderer renderer, float to, float duration) => - Tweening.To(renderer, (source) => source.endWidth, (source, value) => source.endWidth = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.endWidth, (target, value) => target.endWidth = value, to, duration) + .SetReference(renderer); public static Tween TweenWidthMultiplier(this LineRenderer renderer, float to, float duration) => - Tweening.To(renderer, (source) => source.widthMultiplier, (source, value) => source.widthMultiplier = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.widthMultiplier, (target, value) => target.widthMultiplier = value, to, duration) + .SetReference(renderer); public static Tween TweenShadowBias(this LineRenderer renderer, float to, float duration) => - Tweening.To(renderer, (source) => source.shadowBias, (source, value) => source.shadowBias = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.shadowBias, (target, value) => target.shadowBias = value, to, duration) + .SetReference(renderer); } } diff --git a/Runtime/Extensions/Rendering/MaterialPropertyBlockTweens.cs b/Runtime/Extensions/Rendering/MaterialPropertyBlockTweens.cs new file mode 100644 index 0000000..65c9bf1 --- /dev/null +++ b/Runtime/Extensions/Rendering/MaterialPropertyBlockTweens.cs @@ -0,0 +1,72 @@ +using UnityEngine; + +namespace Zigurous.Tweening +{ + public static class MaterialPropertyBlockTweens + { + public static Tween TweenColor(this MaterialPropertyBlock propertyBlock, int nameID, Color to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetColor(nameID), (target, value) => target.SetColor(nameID, value), to, duration) + .SetId(propertyBlock.GetHashCode()); + + public static Tween TweenColor(this MaterialPropertyBlock propertyBlock, string name, Color to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetColor(name), (target, value) => target.SetColor(name, value), to, duration) + .SetId(propertyBlock.GetHashCode()); + + public static Tween TweenRed(this MaterialPropertyBlock propertyBlock, int nameID, float to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetColor(nameID).r, (target, value) => target.SetColor(nameID, target.GetColor(nameID).WithRed(value)), to, duration) + .SetId(propertyBlock.GetHashCode()); + + public static Tween TweenRed(this MaterialPropertyBlock propertyBlock, string name, float to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetColor(name).r, (target, value) => target.SetColor(name, target.GetColor(name).WithRed(value)), to, duration) + .SetId(propertyBlock.GetHashCode()); + + public static Tween TweenGreen(this MaterialPropertyBlock propertyBlock, int nameID, float to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetColor(nameID).g, (target, value) => target.SetColor(nameID, target.GetColor(nameID).WithGreen(value)), to, duration) + .SetId(propertyBlock.GetHashCode()); + + public static Tween TweenGreen(this MaterialPropertyBlock propertyBlock, string name, float to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetColor(name).g, (target, value) => target.SetColor(name, target.GetColor(name).WithGreen(value)), to, duration) + .SetId(propertyBlock.GetHashCode()); + + public static Tween TweenBlue(this MaterialPropertyBlock propertyBlock, int nameID, float to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetColor(nameID).b, (target, value) => target.SetColor(nameID, target.GetColor(nameID).WithBlue(value)), to, duration) + .SetId(propertyBlock.GetHashCode()); + + public static Tween TweenBlue(this MaterialPropertyBlock propertyBlock, string name, float to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetColor(name).b, (target, value) => target.SetColor(name, target.GetColor(name).WithBlue(value)), to, duration) + .SetId(propertyBlock.GetHashCode()); + + public static Tween TweenAlpha(this MaterialPropertyBlock propertyBlock, int nameID, float to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetColor(nameID).a, (target, value) => target.SetColor(nameID, target.GetColor(nameID).WithAlpha(value)), to, duration) + .SetId(propertyBlock.GetHashCode()); + + public static Tween TweenAlpha(this MaterialPropertyBlock propertyBlock, string name, float to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetColor(name).a, (target, value) => target.SetColor(name, target.GetColor(name).WithAlpha(value)), to, duration) + .SetId(propertyBlock.GetHashCode()); + + public static Tween TweenVector(this MaterialPropertyBlock propertyBlock, int nameID, Vector4 to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetVector(nameID), (target, value) => target.SetVector(nameID, value), to, duration) + .SetId(propertyBlock.GetHashCode()); + + public static Tween TweenVector(this MaterialPropertyBlock propertyBlock, string name, Vector4 to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetVector(name), (target, value) => target.SetVector(name, value), to, duration) + .SetId(propertyBlock.GetHashCode()); + + public static Tween TweenFloat(this MaterialPropertyBlock propertyBlock, int nameID, float to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetFloat(nameID), (target, value) => target.SetFloat(nameID, value), to, duration) + .SetId(propertyBlock.GetHashCode()); + + public static Tween TweenFloat(this MaterialPropertyBlock propertyBlock, string name, float to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetFloat(name), (target, value) => target.SetFloat(name, value), to, duration) + .SetId(propertyBlock.GetHashCode()); + + public static Tween TweenInt(this MaterialPropertyBlock propertyBlock, int nameID, int to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetInt(nameID), (target, value) => target.SetInt(nameID, value), to, duration) + .SetId(propertyBlock.GetHashCode()); + + public static Tween TweenInt(this MaterialPropertyBlock propertyBlock, string name, int to, float duration) => + Tweening.To(propertyBlock, (target) => target.GetInt(name), (target, value) => target.SetInt(name, value), to, duration) + .SetId(propertyBlock.GetHashCode()); + } + +} diff --git a/Runtime/Extensions/Rendering/MaterialPropertyBlockTweens.cs.meta b/Runtime/Extensions/Rendering/MaterialPropertyBlockTweens.cs.meta new file mode 100644 index 0000000..df4e7c5 --- /dev/null +++ b/Runtime/Extensions/Rendering/MaterialPropertyBlockTweens.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eb852c19ded4d96479888dab393c579e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Extensions/Rendering/MaterialTweens.cs b/Runtime/Extensions/Rendering/MaterialTweens.cs index 5e39832..454aa5c 100644 --- a/Runtime/Extensions/Rendering/MaterialTweens.cs +++ b/Runtime/Extensions/Rendering/MaterialTweens.cs @@ -5,68 +5,104 @@ namespace Zigurous.Tweening public static class MaterialTweens { public static Tween TweenColor(this Material material, Color to, float duration) => - Tweening.To(material, (source) => source.color, (source, value) => source.color = value, to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.color, (target, value) => target.color = value, to, duration) + .SetReference(material); public static Tween TweenColor(this Material material, int nameID, Color to, float duration) => - Tweening.To(material, (source) => source.GetColor(nameID), (source, value) => source.SetColor(nameID, value), to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.GetColor(nameID), (target, value) => target.SetColor(nameID, value), to, duration) + .SetReference(material); public static Tween TweenColor(this Material material, string name, Color to, float duration) => - Tweening.To(material, (source) => source.GetColor(name), (source, value) => source.SetColor(name, value), to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.GetColor(name), (target, value) => target.SetColor(name, value), to, duration) + .SetReference(material); + + public static Tween TweenRed(this Material material, float to, float duration) => + Tweening.To(material, (target) => target.color.r, (target, value) => target.color = target.color.WithRed(value), to, duration) + .SetReference(material); + + public static Tween TweenRed(this Material material, int nameID, float to, float duration) => + Tweening.To(material, (target) => target.GetColor(nameID).r, (target, value) => target.SetColor(nameID, target.GetColor(nameID).WithRed(value)), to, duration) + .SetReference(material); + + public static Tween TweenRed(this Material material, string name, float to, float duration) => + Tweening.To(material, (target) => target.GetColor(name).r, (target, value) => target.SetColor(name, target.GetColor(name).WithRed(value)), to, duration) + .SetReference(material); + + public static Tween TweenGreen(this Material material, float to, float duration) => + Tweening.To(material, (target) => target.color.g, (target, value) => target.color = target.color.WithGreen(value), to, duration) + .SetReference(material); + + public static Tween TweenGreen(this Material material, int nameID, float to, float duration) => + Tweening.To(material, (target) => target.GetColor(nameID).g, (target, value) => target.SetColor(nameID, target.GetColor(nameID).WithGreen(value)), to, duration) + .SetReference(material); + + public static Tween TweenGreen(this Material material, string name, float to, float duration) => + Tweening.To(material, (target) => target.GetColor(name).g, (target, value) => target.SetColor(name, target.GetColor(name).WithGreen(value)), to, duration) + .SetReference(material); + + public static Tween TweenBlue(this Material material, float to, float duration) => + Tweening.To(material, (target) => target.color.b, (target, value) => target.color = target.color.WithBlue(value), to, duration) + .SetReference(material); + + public static Tween TweenBlue(this Material material, int nameID, float to, float duration) => + Tweening.To(material, (target) => target.GetColor(nameID).b, (target, value) => target.SetColor(nameID, target.GetColor(nameID).WithBlue(value)), to, duration) + .SetReference(material); + + public static Tween TweenBlue(this Material material, string name, float to, float duration) => + Tweening.To(material, (target) => target.GetColor(name).b, (target, value) => target.SetColor(name, target.GetColor(name).WithBlue(value)), to, duration) + .SetReference(material); public static Tween TweenAlpha(this Material material, float to, float duration) => - Tweening.To(material, (source) => source.color.a, (source, value) => source.color = new Color(source.color.r, source.color.g, source.color.b, value), to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.color.a, (target, value) => target.color = target.color.WithAlpha(value), to, duration) + .SetReference(material); public static Tween TweenAlpha(this Material material, int nameID, float to, float duration) => - Tweening.To(material, (source) => source.GetColor(nameID).a, (source, value) => source.SetColor(nameID, new Color(source.color.r, source.color.g, source.color.b, value)), to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.GetColor(nameID).a, (target, value) => target.SetColor(nameID, target.GetColor(nameID).WithAlpha(value)), to, duration) + .SetReference(material); public static Tween TweenAlpha(this Material material, string name, float to, float duration) => - Tweening.To(material, (source) => source.GetColor(name).a, (source, value) => source.SetColor(name, new Color(source.color.r, source.color.g, source.color.b, value)), to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.GetColor(name).a, (target, value) => target.SetColor(name, target.GetColor(name).WithAlpha(value)), to, duration) + .SetReference(material); public static Tween TweenFloat(this Material material, int nameID, float to, float duration) => - Tweening.To(material, (source) => source.GetFloat(nameID), (source, value) => source.SetFloat(nameID, value), to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.GetFloat(nameID), (target, value) => target.SetFloat(nameID, value), to, duration) + .SetReference(material); public static Tween TweenFloat(this Material material, string name, float to, float duration) => - Tweening.To(material, (source) => source.GetFloat(name), (source, value) => source.SetFloat(name, value), to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.GetFloat(name), (target, value) => target.SetFloat(name, value), to, duration) + .SetReference(material); public static Tween TweenInt(this Material material, int nameID, int to, float duration) => - Tweening.To(material, (source) => source.GetInt(nameID), (source, value) => source.SetInt(nameID, value), to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.GetInt(nameID), (target, value) => target.SetInt(nameID, value), to, duration) + .SetReference(material); public static Tween TweenInt(this Material material, string name, int to, float duration) => - Tweening.To(material, (source) => source.GetInt(name), (source, value) => source.SetInt(name, value), to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.GetInt(name), (target, value) => target.SetInt(name, value), to, duration) + .SetReference(material); public static Tween TweenMainTextureOffset(this Material material, Vector2 to, float duration) => - Tweening.To(material, (source) => source.mainTextureOffset, (source, value) => source.mainTextureOffset = value, to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.mainTextureOffset, (target, value) => target.mainTextureOffset = value, to, duration) + .SetReference(material); public static Tween TweenMainTextureScale(this Material material, Vector2 to, float duration) => - Tweening.To(material, (source) => source.mainTextureScale, (source, value) => source.mainTextureScale = value, to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.mainTextureScale, (target, value) => target.mainTextureScale = value, to, duration) + .SetReference(material); public static Tween TweenTextureOffset(this Material material, int nameID, Vector2 to, float duration) => - Tweening.To(material, (source) => source.GetTextureOffset(nameID), (source, value) => source.SetTextureOffset(nameID, value), to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.GetTextureOffset(nameID), (target, value) => target.SetTextureOffset(nameID, value), to, duration) + .SetReference(material); public static Tween TweenTextureOffset(this Material material, string name, Vector2 to, float duration) => - Tweening.To(material, (source) => source.GetTextureOffset(name), (source, value) => source.SetTextureOffset(name, value), to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.GetTextureOffset(name), (target, value) => target.SetTextureOffset(name, value), to, duration) + .SetReference(material); public static Tween TweenTextureScale(this Material material, int nameID, Vector2 to, float duration) => - Tweening.To(material, (source) => source.GetTextureScale(nameID), (source, value) => source.SetTextureScale(nameID, value), to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.GetTextureScale(nameID), (target, value) => target.SetTextureScale(nameID, value), to, duration) + .SetReference(material); public static Tween TweenTextureScale(this Material material, string name, Vector2 to, float duration) => - Tweening.To(material, (source) => source.GetTextureScale(name), (source, value) => source.SetTextureScale(name, value), to, duration) - .SetId(material.GetHashCode()); + Tweening.To(material, (target) => target.GetTextureScale(name), (target, value) => target.SetTextureScale(name, value), to, duration) + .SetReference(material); } } diff --git a/Runtime/Extensions/Rendering/OcclusionAreaTweens.cs b/Runtime/Extensions/Rendering/OcclusionAreaTweens.cs index 138d5eb..eb3d474 100644 --- a/Runtime/Extensions/Rendering/OcclusionAreaTweens.cs +++ b/Runtime/Extensions/Rendering/OcclusionAreaTweens.cs @@ -5,12 +5,12 @@ namespace Zigurous.Tweening public static class OcclusionAreaTweens { public static Tween TweenCenter(this OcclusionArea area, Vector3 to, float duration) => - Tweening.To(area, (source) => source.center, (source, value) => source.center = value, to, duration) - .SetTarget(area); + Tweening.To(area, (target) => target.center, (target, value) => target.center = value, to, duration) + .SetReference(area); public static Tween TweenSize(this OcclusionArea area, Vector3 to, float duration) => - Tweening.To(area, (source) => source.size, (source, value) => source.size = value, to, duration) - .SetTarget(area); + Tweening.To(area, (target) => target.size, (target, value) => target.size = value, to, duration) + .SetReference(area); } } diff --git a/Runtime/Extensions/Rendering/ParticleSystemForceFieldTweens.cs b/Runtime/Extensions/Rendering/ParticleSystemForceFieldTweens.cs index b3d24dd..4b2e4ea 100644 --- a/Runtime/Extensions/Rendering/ParticleSystemForceFieldTweens.cs +++ b/Runtime/Extensions/Rendering/ParticleSystemForceFieldTweens.cs @@ -5,24 +5,24 @@ namespace Zigurous.Tweening public static class ParticleSystemForceFieldTweens { public static Tween TweenRotationRandomness(this ParticleSystemForceField forceField, Vector2 to, float duration) => - Tweening.To(forceField, (source) => source.rotationRandomness, (source, value) => source.rotationRandomness = value, to, duration) - .SetTarget(forceField); + Tweening.To(forceField, (target) => target.rotationRandomness, (target, value) => target.rotationRandomness = value, to, duration) + .SetReference(forceField); public static Tween TweenGravityFocus(this ParticleSystemForceField forceField, float to, float duration) => - Tweening.To(forceField, (source) => source.gravityFocus, (source, value) => source.gravityFocus = value, to, duration) - .SetTarget(forceField); + Tweening.To(forceField, (target) => target.gravityFocus, (target, value) => target.gravityFocus = value, to, duration) + .SetReference(forceField); public static Tween TweenLength(this ParticleSystemForceField forceField, float to, float duration) => - Tweening.To(forceField, (source) => source.length, (source, value) => source.length = value, to, duration) - .SetTarget(forceField); + Tweening.To(forceField, (target) => target.length, (target, value) => target.length = value, to, duration) + .SetReference(forceField); public static Tween TweenStartRange(this ParticleSystemForceField forceField, float to, float duration) => - Tweening.To(forceField, (source) => source.startRange, (source, value) => source.startRange = value, to, duration) - .SetTarget(forceField); + Tweening.To(forceField, (target) => target.startRange, (target, value) => target.startRange = value, to, duration) + .SetReference(forceField); public static Tween TweenEndRange(this ParticleSystemForceField forceField, float to, float duration) => - Tweening.To(forceField, (source) => source.endRange, (source, value) => source.endRange = value, to, duration) - .SetTarget(forceField); + Tweening.To(forceField, (target) => target.endRange, (target, value) => target.endRange = value, to, duration) + .SetReference(forceField); } } diff --git a/Runtime/Extensions/Rendering/ParticleSystemTweens.cs b/Runtime/Extensions/Rendering/ParticleSystemTweens.cs index 00fda6c..90f332d 100644 --- a/Runtime/Extensions/Rendering/ParticleSystemTweens.cs +++ b/Runtime/Extensions/Rendering/ParticleSystemTweens.cs @@ -5,8 +5,8 @@ namespace Zigurous.Tweening public static class ParticleSystemTweens { public static Tween TweenTime(this ParticleSystem particleSystem, float to, float duration) => - Tweening.To(particleSystem, (source) => source.time, (source, value) => source.time = value, to, duration) - .SetTarget(particleSystem); + Tweening.To(particleSystem, (target) => target.time, (target, value) => target.time = value, to, duration) + .SetReference(particleSystem); } } diff --git a/Runtime/Extensions/Rendering/ProjectorTweens.cs b/Runtime/Extensions/Rendering/ProjectorTweens.cs index 62f278a..3866280 100644 --- a/Runtime/Extensions/Rendering/ProjectorTweens.cs +++ b/Runtime/Extensions/Rendering/ProjectorTweens.cs @@ -5,24 +5,24 @@ namespace Zigurous.Tweening public static class ProjectorTweens { public static Tween TweenNearClipPlane(this Projector projector, float to, float duration) => - Tweening.To(projector, (source) => source.nearClipPlane, (source, value) => source.nearClipPlane = value, to, duration) - .SetTarget(projector); + Tweening.To(projector, (target) => target.nearClipPlane, (target, value) => target.nearClipPlane = value, to, duration) + .SetReference(projector); public static Tween TweenFarClipPlane(this Projector projector, float to, float duration) => - Tweening.To(projector, (source) => source.farClipPlane, (source, value) => source.farClipPlane = value, to, duration) - .SetTarget(projector); + Tweening.To(projector, (target) => target.farClipPlane, (target, value) => target.farClipPlane = value, to, duration) + .SetReference(projector); public static Tween TweenFieldOfView(this Projector projector, float to, float duration) => - Tweening.To(projector, (source) => source.fieldOfView, (source, value) => source.fieldOfView = value, to, duration) - .SetTarget(projector); + Tweening.To(projector, (target) => target.fieldOfView, (target, value) => target.fieldOfView = value, to, duration) + .SetReference(projector); public static Tween TweenAspectRatio(this Projector projector, float to, float duration) => - Tweening.To(projector, (source) => source.aspectRatio, (source, value) => source.aspectRatio = value, to, duration) - .SetTarget(projector); + Tweening.To(projector, (target) => target.aspectRatio, (target, value) => target.aspectRatio = value, to, duration) + .SetReference(projector); public static Tween TweenOrthographicSize(this Projector projector, float to, float duration) => - Tweening.To(projector, (source) => source.orthographicSize, (source, value) => source.orthographicSize = value, to, duration) - .SetTarget(projector); + Tweening.To(projector, (target) => target.orthographicSize, (target, value) => target.orthographicSize = value, to, duration) + .SetReference(projector); } } diff --git a/Runtime/Extensions/Rendering/ReflectionProbeTweens.cs b/Runtime/Extensions/Rendering/ReflectionProbeTweens.cs index c66e451..cdfd357 100644 --- a/Runtime/Extensions/Rendering/ReflectionProbeTweens.cs +++ b/Runtime/Extensions/Rendering/ReflectionProbeTweens.cs @@ -5,36 +5,36 @@ namespace Zigurous.Tweening public static class ReflectionProbeTweens { public static Tween TweenCenter(this ReflectionProbe probe, Vector3 to, float duration) => - Tweening.To(probe, (source) => source.center, (source, value) => source.center = value, to, duration) - .SetTarget(probe); + Tweening.To(probe, (target) => target.center, (target, value) => target.center = value, to, duration) + .SetReference(probe); public static Tween TweenSize(this ReflectionProbe probe, Vector3 to, float duration) => - Tweening.To(probe, (source) => source.size, (source, value) => source.size = value, to, duration) - .SetTarget(probe); + Tweening.To(probe, (target) => target.size, (target, value) => target.size = value, to, duration) + .SetReference(probe); public static Tween TweenIntensity(this ReflectionProbe probe, float to, float duration) => - Tweening.To(probe, (source) => source.intensity, (source, value) => source.intensity = value, to, duration) - .SetTarget(probe); + Tweening.To(probe, (target) => target.intensity, (target, value) => target.intensity = value, to, duration) + .SetReference(probe); public static Tween TweenFarClipPlane(this ReflectionProbe probe, float to, float duration) => - Tweening.To(probe, (source) => source.farClipPlane, (source, value) => source.farClipPlane = value, to, duration) - .SetTarget(probe); + Tweening.To(probe, (target) => target.farClipPlane, (target, value) => target.farClipPlane = value, to, duration) + .SetReference(probe); public static Tween TweenNearClipPlane(this ReflectionProbe probe, float to, float duration) => - Tweening.To(probe, (source) => source.nearClipPlane, (source, value) => source.nearClipPlane = value, to, duration) - .SetTarget(probe); + Tweening.To(probe, (target) => target.nearClipPlane, (target, value) => target.nearClipPlane = value, to, duration) + .SetReference(probe); public static Tween TweenBlendDistance(this ReflectionProbe probe, float to, float duration) => - Tweening.To(probe, (source) => source.blendDistance, (source, value) => source.blendDistance = value, to, duration) - .SetTarget(probe); + Tweening.To(probe, (target) => target.blendDistance, (target, value) => target.blendDistance = value, to, duration) + .SetReference(probe); public static Tween TweenShadowDistance(this ReflectionProbe probe, float to, float duration) => - Tweening.To(probe, (source) => source.shadowDistance, (source, value) => source.shadowDistance = value, to, duration) - .SetTarget(probe); + Tweening.To(probe, (target) => target.shadowDistance, (target, value) => target.shadowDistance = value, to, duration) + .SetReference(probe); public static Tween TweenBackgroundColor(this ReflectionProbe probe, Color to, float duration) => - Tweening.To(probe, (source) => source.backgroundColor, (source, value) => source.backgroundColor = value, to, duration) - .SetTarget(probe); + Tweening.To(probe, (target) => target.backgroundColor, (target, value) => target.backgroundColor = value, to, duration) + .SetReference(probe); } } diff --git a/Runtime/Extensions/Rendering/SpriteMaskTweens.cs b/Runtime/Extensions/Rendering/SpriteMaskTweens.cs index fc75e0c..6e17619 100644 --- a/Runtime/Extensions/Rendering/SpriteMaskTweens.cs +++ b/Runtime/Extensions/Rendering/SpriteMaskTweens.cs @@ -5,8 +5,8 @@ namespace Zigurous.Tweening public static class SpriteMaskTweens { public static Tween TweenAlphaCutoff(this SpriteMask mask, float to, float duration) => - Tweening.To(mask, (source) => source.alphaCutoff, (source, value) => source.alphaCutoff = value, to, duration) - .SetTarget(mask); + Tweening.To(mask, (target) => target.alphaCutoff, (target, value) => target.alphaCutoff = value, to, duration) + .SetReference(mask); } } diff --git a/Runtime/Extensions/Rendering/SpriteRendererTweens.cs b/Runtime/Extensions/Rendering/SpriteRendererTweens.cs index f077d07..8972a1f 100644 --- a/Runtime/Extensions/Rendering/SpriteRendererTweens.cs +++ b/Runtime/Extensions/Rendering/SpriteRendererTweens.cs @@ -5,20 +5,20 @@ namespace Zigurous.Tweening public static class SpriteRendererTweens { public static Tween TweenColor(this SpriteRenderer renderer, Color to, float duration) => - Tweening.To(renderer, (source) => source.color, (source, value) => source.color = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.color, (target, value) => target.color = value, to, duration) + .SetReference(renderer); public static Tween TweenAlpha(this SpriteRenderer renderer, float to, float duration) => - Tweening.To(renderer, (source) => source.color.a, (source, value) => source.color = new Color(source.color.r, source.color.g, source.color.b, value), to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.color.a, (target, value) => target.color = new Color(target.color.r, target.color.g, target.color.b, value), to, duration) + .SetReference(renderer); public static Tween TweenSize(this SpriteRenderer renderer, Vector2 to, float duration) => - Tweening.To(renderer, (source) => source.size, (source, value) => source.size = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.size, (target, value) => target.size = value, to, duration) + .SetReference(renderer); public static Tween TweenAdaptiveModeThreshold(this SpriteRenderer renderer, float to, float duration) => - Tweening.To(renderer, (source) => source.adaptiveModeThreshold, (source, value) => source.adaptiveModeThreshold = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.adaptiveModeThreshold, (target, value) => target.adaptiveModeThreshold = value, to, duration) + .SetReference(renderer); } } diff --git a/Runtime/Extensions/Rendering/SpriteShapeRendererTweens.cs b/Runtime/Extensions/Rendering/SpriteShapeRendererTweens.cs index b577266..90781a7 100644 --- a/Runtime/Extensions/Rendering/SpriteShapeRendererTweens.cs +++ b/Runtime/Extensions/Rendering/SpriteShapeRendererTweens.cs @@ -6,12 +6,12 @@ namespace Zigurous.Tweening public static class SpriteShapeRendererTweens { public static Tween TweenColor(this SpriteShapeRenderer renderer, Color to, float duration) => - Tweening.To(renderer, (source) => source.color, (source, value) => source.color = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.color, (target, value) => target.color = value, to, duration) + .SetReference(renderer); public static Tween TweenAlpha(this SpriteShapeRenderer renderer, float to, float duration) => - Tweening.To(renderer, (source) => source.color.a, (source, value) => source.color = new Color(source.color.r, source.color.g, source.color.b, value), to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.color.a, (target, value) => target.color = new Color(target.color.r, target.color.g, target.color.b, value), to, duration) + .SetReference(renderer); } } diff --git a/Runtime/Extensions/Rendering/TilemapTweens.cs b/Runtime/Extensions/Rendering/TilemapTweens.cs index 0c5c317..a5253a2 100644 --- a/Runtime/Extensions/Rendering/TilemapTweens.cs +++ b/Runtime/Extensions/Rendering/TilemapTweens.cs @@ -6,24 +6,24 @@ namespace Zigurous.Tweening public static class TilemapTweens { public static Tween TweenColor(this Tilemap tilemap, Color to, float duration) => - Tweening.To(tilemap, (source) => source.color, (source, value) => source.color = value, to, duration) - .SetTarget(tilemap); + Tweening.To(tilemap, (target) => target.color, (target, value) => target.color = value, to, duration) + .SetReference(tilemap); public static Tween TweenOrigin(this Tilemap tilemap, Vector3Int to, float duration) => - Tweening.To(tilemap, (source) => source.origin, (source, value) => source.origin = value, to, duration) - .SetTarget(tilemap); + Tweening.To(tilemap, (target) => target.origin, (target, value) => target.origin = value, to, duration) + .SetReference(tilemap); public static Tween TweenSize(this Tilemap tilemap, Vector3Int to, float duration) => - Tweening.To(tilemap, (source) => source.size, (source, value) => source.size = value, to, duration) - .SetTarget(tilemap); + Tweening.To(tilemap, (target) => target.size, (target, value) => target.size = value, to, duration) + .SetReference(tilemap); public static Tween TweenTileAnchor(this Tilemap tilemap, Vector3 to, float duration) => - Tweening.To(tilemap, (source) => source.tileAnchor, (source, value) => source.tileAnchor = value, to, duration) - .SetTarget(tilemap); + Tweening.To(tilemap, (target) => target.tileAnchor, (target, value) => target.tileAnchor = value, to, duration) + .SetReference(tilemap); public static Tween TweenAnimationFrameRate(this Tilemap tilemap, float to, float duration) => - Tweening.To(tilemap, (source) => source.animationFrameRate, (source, value) => source.animationFrameRate = value, to, duration) - .SetTarget(tilemap); + Tweening.To(tilemap, (target) => target.animationFrameRate, (target, value) => target.animationFrameRate = value, to, duration) + .SetReference(tilemap); } } diff --git a/Runtime/Extensions/Rendering/TrailRendererTweens.cs b/Runtime/Extensions/Rendering/TrailRendererTweens.cs index 2137961..60a35f6 100644 --- a/Runtime/Extensions/Rendering/TrailRendererTweens.cs +++ b/Runtime/Extensions/Rendering/TrailRendererTweens.cs @@ -5,36 +5,36 @@ namespace Zigurous.Tweening public static class TrailRendererTweens { public static Tween TweenTime(this TrailRenderer renderer, float to, float duration) => - Tweening.To(renderer, (source) => source.time, (source, value) => source.time = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.time, (target, value) => target.time = value, to, duration) + .SetReference(renderer); public static Tween TweenStartColor(this TrailRenderer renderer, Color to, float duration) => - Tweening.To(renderer, (source) => source.startColor, (source, value) => source.startColor = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.startColor, (target, value) => target.startColor = value, to, duration) + .SetReference(renderer); public static Tween TweenEndColor(this TrailRenderer renderer, Color to, float duration) => - Tweening.To(renderer, (source) => source.endColor, (source, value) => source.endColor = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.endColor, (target, value) => target.endColor = value, to, duration) + .SetReference(renderer); public static Tween TweenStartWidth(this TrailRenderer renderer, float to, float duration) => - Tweening.To(renderer, (source) => source.startWidth, (source, value) => source.startWidth = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.startWidth, (target, value) => target.startWidth = value, to, duration) + .SetReference(renderer); public static Tween TweenEndWidth(this TrailRenderer renderer, float to, float duration) => - Tweening.To(renderer, (source) => source.endWidth, (source, value) => source.endWidth = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.endWidth, (target, value) => target.endWidth = value, to, duration) + .SetReference(renderer); public static Tween TweenWidthMultiplier(this TrailRenderer renderer, float to, float duration) => - Tweening.To(renderer, (source) => source.widthMultiplier, (source, value) => source.widthMultiplier = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.widthMultiplier, (target, value) => target.widthMultiplier = value, to, duration) + .SetReference(renderer); public static Tween TweenShadowBias(this TrailRenderer renderer, float to, float duration) => - Tweening.To(renderer, (source) => source.shadowBias, (source, value) => source.shadowBias = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.shadowBias, (target, value) => target.shadowBias = value, to, duration) + .SetReference(renderer); public static Tween TweenMinVertexDistance(this TrailRenderer renderer, float to, float duration) => - Tweening.To(renderer, (source) => source.minVertexDistance, (source, value) => source.minVertexDistance = value, to, duration) - .SetTarget(renderer); + Tweening.To(renderer, (target) => target.minVertexDistance, (target, value) => target.minVertexDistance = value, to, duration) + .SetReference(renderer); } } diff --git a/Runtime/Extensions/Rendering/VideoPlayerTweens.cs b/Runtime/Extensions/Rendering/VideoPlayerTweens.cs index c9a30ab..0975b18 100644 --- a/Runtime/Extensions/Rendering/VideoPlayerTweens.cs +++ b/Runtime/Extensions/Rendering/VideoPlayerTweens.cs @@ -5,24 +5,24 @@ namespace Zigurous.Tweening public static class VideoPlayerTweens { public static Tween TweenFrame(this VideoPlayer videoPlayer, long to, float duration) => - Tweening.To(videoPlayer, (source) => source.frame, (source, value) => source.frame = value, to, duration) - .SetTarget(videoPlayer); + Tweening.To(videoPlayer, (target) => target.frame, (target, value) => target.frame = value, to, duration) + .SetReference(videoPlayer); public static Tween TweenTime(this VideoPlayer videoPlayer, double to, float duration) => - Tweening.To(videoPlayer, (source) => source.time, (source, value) => source.time = value, to, duration) - .SetTarget(videoPlayer); + Tweening.To(videoPlayer, (target) => target.time, (target, value) => target.time = value, to, duration) + .SetReference(videoPlayer); public static Tween TweenPlaybackSpeed(this VideoPlayer videoPlayer, float to, float duration) => - Tweening.To(videoPlayer, (source) => source.playbackSpeed, (source, value) => source.playbackSpeed = value, to, duration) - .SetTarget(videoPlayer); + Tweening.To(videoPlayer, (target) => target.playbackSpeed, (target, value) => target.playbackSpeed = value, to, duration) + .SetReference(videoPlayer); public static Tween TweenExternalReferenceTime(this VideoPlayer videoPlayer, double to, float duration) => - Tweening.To(videoPlayer, (source) => source.externalReferenceTime, (source, value) => source.externalReferenceTime = value, to, duration) - .SetTarget(videoPlayer); + Tweening.To(videoPlayer, (target) => target.externalReferenceTime, (target, value) => target.externalReferenceTime = value, to, duration) + .SetReference(videoPlayer); public static Tween TweenTargetCameraAlpha(this VideoPlayer videoPlayer, float to, float duration) => - Tweening.To(videoPlayer, (source) => source.targetCameraAlpha, (source, value) => source.targetCameraAlpha = value, to, duration) - .SetTarget(videoPlayer); + Tweening.To(videoPlayer, (target) => target.targetCameraAlpha, (target, value) => target.targetCameraAlpha = value, to, duration) + .SetReference(videoPlayer); } } diff --git a/Runtime/Extensions/Rendering/WindZoneTweens.cs b/Runtime/Extensions/Rendering/WindZoneTweens.cs index 4d8c2cc..2a674d0 100644 --- a/Runtime/Extensions/Rendering/WindZoneTweens.cs +++ b/Runtime/Extensions/Rendering/WindZoneTweens.cs @@ -5,24 +5,24 @@ namespace Zigurous.Tweening public static class WindZoneTweens { public static Tween TweenRadius(this WindZone windZone, float to, float duration) => - Tweening.To(windZone, (source) => source.radius, (source, value) => source.radius = value, to, duration) - .SetTarget(windZone); + Tweening.To(windZone, (target) => target.radius, (target, value) => target.radius = value, to, duration) + .SetReference(windZone); public static Tween TweenWindMain(this WindZone windZone, float to, float duration) => - Tweening.To(windZone, (source) => source.windMain, (source, value) => source.windMain = value, to, duration) - .SetTarget(windZone); + Tweening.To(windZone, (target) => target.windMain, (target, value) => target.windMain = value, to, duration) + .SetReference(windZone); public static Tween TweenWindTurbulence(this WindZone windZone, float to, float duration) => - Tweening.To(windZone, (source) => source.windTurbulence, (source, value) => source.windTurbulence = value, to, duration) - .SetTarget(windZone); + Tweening.To(windZone, (target) => target.windTurbulence, (target, value) => target.windTurbulence = value, to, duration) + .SetReference(windZone); public static Tween TweenWindPulseMagnitude(this WindZone windZone, float to, float duration) => - Tweening.To(windZone, (source) => source.windPulseMagnitude, (source, value) => source.windPulseMagnitude = value, to, duration) - .SetTarget(windZone); + Tweening.To(windZone, (target) => target.windPulseMagnitude, (target, value) => target.windPulseMagnitude = value, to, duration) + .SetReference(windZone); public static Tween TweenWindPulseFrequency(this WindZone windZone, float to, float duration) => - Tweening.To(windZone, (source) => source.windPulseFrequency, (source, value) => source.windPulseFrequency = value, to, duration) - .SetTarget(windZone); + Tweening.To(windZone, (target) => target.windPulseFrequency, (target, value) => target.windPulseFrequency = value, to, duration) + .SetReference(windZone); } } diff --git a/Runtime/Extensions/UI/AspectRatioFitterTweens.cs b/Runtime/Extensions/UI/AspectRatioFitterTweens.cs index 4cb6e20..1067095 100644 --- a/Runtime/Extensions/UI/AspectRatioFitterTweens.cs +++ b/Runtime/Extensions/UI/AspectRatioFitterTweens.cs @@ -5,8 +5,8 @@ namespace Zigurous.Tweening public static class AspectRatioFitterTweens { public static Tween TweenAspectRatio(this AspectRatioFitter fitter, float to, float duration) => - Tweening.To(fitter, (source) => source.aspectRatio, (source, value) => source.aspectRatio = value, to, duration) - .SetTarget(fitter); + Tweening.To(fitter, (target) => target.aspectRatio, (target, value) => target.aspectRatio = value, to, duration) + .SetReference(fitter); } } diff --git a/Runtime/Extensions/UI/CanvasGroupTweens.cs b/Runtime/Extensions/UI/CanvasGroupTweens.cs index 3854e3a..c4666be 100644 --- a/Runtime/Extensions/UI/CanvasGroupTweens.cs +++ b/Runtime/Extensions/UI/CanvasGroupTweens.cs @@ -5,8 +5,8 @@ namespace Zigurous.Tweening public static class CanvasGroupTweens { public static Tween TweenAlpha(this CanvasGroup canvasGroup, float to, float duration) => - Tweening.To(canvasGroup, (source) => source.alpha, (source, value) => source.alpha = value, to, duration) - .SetTarget(canvasGroup); + Tweening.To(canvasGroup, (target) => target.alpha, (target, value) => target.alpha = value, to, duration) + .SetReference(canvasGroup); } } diff --git a/Runtime/Extensions/UI/CanvasScalerTweens.cs b/Runtime/Extensions/UI/CanvasScalerTweens.cs index b850021..489505c 100644 --- a/Runtime/Extensions/UI/CanvasScalerTweens.cs +++ b/Runtime/Extensions/UI/CanvasScalerTweens.cs @@ -6,32 +6,32 @@ namespace Zigurous.Tweening public static class CanvasScalerTweens { public static Tween TweenScaleFactor(this CanvasScaler scaler, float to, float duration) => - Tweening.To(scaler, (source) => source.scaleFactor, (source, value) => source.scaleFactor = value, to, duration) - .SetTarget(scaler); + Tweening.To(scaler, (target) => target.scaleFactor, (target, value) => target.scaleFactor = value, to, duration) + .SetReference(scaler); public static Tween TweenReferenceResolution(this CanvasScaler scaler, Vector2 to, float duration) => - Tweening.To(scaler, (source) => source.referenceResolution, (source, value) => source.referenceResolution = value, to, duration) - .SetTarget(scaler); + Tweening.To(scaler, (target) => target.referenceResolution, (target, value) => target.referenceResolution = value, to, duration) + .SetReference(scaler); public static Tween TweenMatchWidthOrHeight(this CanvasScaler scaler, float to, float duration) => - Tweening.To(scaler, (source) => source.matchWidthOrHeight, (source, value) => source.matchWidthOrHeight = value, to, duration) - .SetTarget(scaler); + Tweening.To(scaler, (target) => target.matchWidthOrHeight, (target, value) => target.matchWidthOrHeight = value, to, duration) + .SetReference(scaler); public static Tween TweenDefaultSpriteDPI(this CanvasScaler scaler, float to, float duration) => - Tweening.To(scaler, (source) => source.defaultSpriteDPI, (source, value) => source.defaultSpriteDPI = value, to, duration) - .SetTarget(scaler); + Tweening.To(scaler, (target) => target.defaultSpriteDPI, (target, value) => target.defaultSpriteDPI = value, to, duration) + .SetReference(scaler); public static Tween TweenFallbackScreenDPI(this CanvasScaler scaler, float to, float duration) => - Tweening.To(scaler, (source) => source.fallbackScreenDPI, (source, value) => source.fallbackScreenDPI = value, to, duration) - .SetTarget(scaler); + Tweening.To(scaler, (target) => target.fallbackScreenDPI, (target, value) => target.fallbackScreenDPI = value, to, duration) + .SetReference(scaler); public static Tween TweenDynamicPixelsPerUnit(this CanvasScaler scaler, float to, float duration) => - Tweening.To(scaler, (source) => source.dynamicPixelsPerUnit, (source, value) => source.dynamicPixelsPerUnit = value, to, duration) - .SetTarget(scaler); + Tweening.To(scaler, (target) => target.dynamicPixelsPerUnit, (target, value) => target.dynamicPixelsPerUnit = value, to, duration) + .SetReference(scaler); public static Tween TweenReferencePixelsPerUnit(this CanvasScaler scaler, float to, float duration) => - Tweening.To(scaler, (source) => source.referencePixelsPerUnit, (source, value) => source.referencePixelsPerUnit = value, to, duration) - .SetTarget(scaler); + Tweening.To(scaler, (target) => target.referencePixelsPerUnit, (target, value) => target.referencePixelsPerUnit = value, to, duration) + .SetReference(scaler); } } diff --git a/Runtime/Extensions/UI/CanvasTweens.cs b/Runtime/Extensions/UI/CanvasTweens.cs index 56bc6e5..5f0a676 100644 --- a/Runtime/Extensions/UI/CanvasTweens.cs +++ b/Runtime/Extensions/UI/CanvasTweens.cs @@ -5,20 +5,20 @@ namespace Zigurous.Tweening public static class CanvasTweens { public static Tween TweenScaleFactor(this Canvas canvas, float to, float duration) => - Tweening.To(canvas, (source) => source.scaleFactor, (source, value) => source.scaleFactor = value, to, duration) - .SetTarget(canvas); + Tweening.To(canvas, (target) => target.scaleFactor, (target, value) => target.scaleFactor = value, to, duration) + .SetReference(canvas); public static Tween TweenPlaneDistance(this Canvas canvas, float to, float duration) => - Tweening.To(canvas, (source) => source.planeDistance, (source, value) => source.planeDistance = value, to, duration) - .SetTarget(canvas); + Tweening.To(canvas, (target) => target.planeDistance, (target, value) => target.planeDistance = value, to, duration) + .SetReference(canvas); public static Tween TweenReferencePixelsPerUnit(this Canvas canvas, float to, float duration) => - Tweening.To(canvas, (source) => source.referencePixelsPerUnit, (source, value) => source.referencePixelsPerUnit = value, to, duration) - .SetTarget(canvas); + Tweening.To(canvas, (target) => target.referencePixelsPerUnit, (target, value) => target.referencePixelsPerUnit = value, to, duration) + .SetReference(canvas); public static Tween TweenNormalizedSortingGridSize(this Canvas canvas, float to, float duration) => - Tweening.To(canvas, (source) => source.normalizedSortingGridSize, (source, value) => source.normalizedSortingGridSize = value, to, duration) - .SetTarget(canvas); + Tweening.To(canvas, (target) => target.normalizedSortingGridSize, (target, value) => target.normalizedSortingGridSize = value, to, duration) + .SetReference(canvas); } } diff --git a/Runtime/Extensions/UI/GraphicTweens.cs b/Runtime/Extensions/UI/GraphicTweens.cs index 15128d1..0d9ce9c 100644 --- a/Runtime/Extensions/UI/GraphicTweens.cs +++ b/Runtime/Extensions/UI/GraphicTweens.cs @@ -6,12 +6,12 @@ namespace Zigurous.Tweening public static class GraphicTweens { public static Tween TweenColor(this Graphic graphic, Color to, float duration) => - Tweening.To(graphic, (source) => source.color, (source, value) => source.color = value, to, duration) - .SetTarget(graphic); + Tweening.To(graphic, (target) => target.color, (target, value) => target.color = value, to, duration) + .SetReference(graphic); public static Tween TweenAlpha(this Graphic graphic, float to, float duration) => - Tweening.To(graphic, (source) => source.color.a, (source, value) => source.color = new Color(source.color.r, source.color.g, source.color.b, value), to, duration) - .SetTarget(graphic); + Tweening.To(graphic, (target) => target.color.a, (target, value) => target.color = new Color(target.color.r, target.color.g, target.color.b, value), to, duration) + .SetReference(graphic); } } diff --git a/Runtime/Extensions/UI/GridLayoutGroupTweens.cs b/Runtime/Extensions/UI/GridLayoutGroupTweens.cs index 0ec8976..acb9a22 100644 --- a/Runtime/Extensions/UI/GridLayoutGroupTweens.cs +++ b/Runtime/Extensions/UI/GridLayoutGroupTweens.cs @@ -6,12 +6,12 @@ namespace Zigurous.Tweening public static class GridLayoutGroupTweens { public static Tween TweenSpacing(this GridLayoutGroup layoutGroup, Vector2 to, float duration) => - Tweening.To(layoutGroup, (source) => source.spacing, (source, value) => source.spacing = value, to, duration) - .SetTarget(layoutGroup); + Tweening.To(layoutGroup, (target) => target.spacing, (target, value) => target.spacing = value, to, duration) + .SetReference(layoutGroup); public static Tween TweenCellSize(this GridLayoutGroup layoutGroup, Vector2 to, float duration) => - Tweening.To(layoutGroup, (source) => source.cellSize, (source, value) => source.cellSize = value, to, duration) - .SetTarget(layoutGroup); + Tweening.To(layoutGroup, (target) => target.cellSize, (target, value) => target.cellSize = value, to, duration) + .SetReference(layoutGroup); } } diff --git a/Runtime/Extensions/UI/HorizontalOrVerticalLayoutGroupTweens.cs b/Runtime/Extensions/UI/HorizontalOrVerticalLayoutGroupTweens.cs index 00abb5d..6a6bf65 100644 --- a/Runtime/Extensions/UI/HorizontalOrVerticalLayoutGroupTweens.cs +++ b/Runtime/Extensions/UI/HorizontalOrVerticalLayoutGroupTweens.cs @@ -5,8 +5,8 @@ namespace Zigurous.Tweening public static class HorizontalOrVerticalLayoutGroupTweens { public static Tween TweenSpacing(this HorizontalOrVerticalLayoutGroup layoutGroup, float to, float duration) => - Tweening.To(layoutGroup, (source) => source.spacing, (source, value) => source.spacing = value, to, duration) - .SetTarget(layoutGroup); + Tweening.To(layoutGroup, (target) => target.spacing, (target, value) => target.spacing = value, to, duration) + .SetReference(layoutGroup); } } diff --git a/Runtime/Extensions/UI/RectMask2DTweens.cs b/Runtime/Extensions/UI/RectMask2DTweens.cs index 2f24b22..d7cbf98 100644 --- a/Runtime/Extensions/UI/RectMask2DTweens.cs +++ b/Runtime/Extensions/UI/RectMask2DTweens.cs @@ -6,12 +6,12 @@ namespace Zigurous.Tweening public static class RectMask2DTweens { public static Tween TweenPadding(this RectMask2D mask, Vector4 to, float duration) => - Tweening.To(mask, (source) => source.padding, (source, value) => source.padding = value, to, duration) - .SetTarget(mask); + Tweening.To(mask, (target) => target.padding, (target, value) => target.padding = value, to, duration) + .SetReference(mask); public static Tween TweenSoftness(this RectMask2D mask, Vector2Int to, float duration) => - Tweening.To(mask, (source) => source.softness, (source, value) => source.softness = value, to, duration) - .SetTarget(mask); + Tweening.To(mask, (target) => target.softness, (target, value) => target.softness = value, to, duration) + .SetReference(mask); } } diff --git a/Runtime/Extensions/UI/RectTransformTweens.cs b/Runtime/Extensions/UI/RectTransformTweens.cs index 3d4b53d..b2d2e65 100644 --- a/Runtime/Extensions/UI/RectTransformTweens.cs +++ b/Runtime/Extensions/UI/RectTransformTweens.cs @@ -5,36 +5,36 @@ namespace Zigurous.Tweening public static class RectTransformTweens { public static Tween TweenAnchoredPosition(this RectTransform transform, Vector2 to, float duration) => - Tweening.To(transform, (source) => source.anchoredPosition, (source, value) => source.anchoredPosition = value, to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.anchoredPosition, (target, value) => target.anchoredPosition = value, to, duration) + .SetReference(transform); public static Tween TweenAnchoredPosition3D(this RectTransform transform, Vector3 to, float duration) => - Tweening.To(transform, (source) => source.anchoredPosition3D, (source, value) => source.anchoredPosition3D = value, to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.anchoredPosition3D, (target, value) => target.anchoredPosition3D = value, to, duration) + .SetReference(transform); public static Tween TweenAnchorMin(this RectTransform transform, Vector2 to, float duration) => - Tweening.To(transform, (source) => source.anchorMin, (source, value) => source.anchorMin = value, to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.anchorMin, (target, value) => target.anchorMin = value, to, duration) + .SetReference(transform); public static Tween TweenAnchorMax(this RectTransform transform, Vector2 to, float duration) => - Tweening.To(transform, (source) => source.anchorMax, (source, value) => source.anchorMax = value, to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.anchorMax, (target, value) => target.anchorMax = value, to, duration) + .SetReference(transform); public static Tween TweenOffsetMin(this RectTransform transform, Vector2 to, float duration) => - Tweening.To(transform, (source) => source.offsetMin, (source, value) => source.offsetMin = value, to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.offsetMin, (target, value) => target.offsetMin = value, to, duration) + .SetReference(transform); public static Tween TweenOffsetMax(this RectTransform transform, Vector2 to, float duration) => - Tweening.To(transform, (source) => source.offsetMax, (source, value) => source.offsetMax = value, to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.offsetMax, (target, value) => target.offsetMax = value, to, duration) + .SetReference(transform); public static Tween TweenPivot(this RectTransform transform, Vector2 to, float duration) => - Tweening.To(transform, (source) => source.pivot, (source, value) => source.pivot = value, to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.pivot, (target, value) => target.pivot = value, to, duration) + .SetReference(transform); public static Tween TweenSizeDelta(this RectTransform transform, Vector2 to, float duration) => - Tweening.To(transform, (source) => source.sizeDelta, (source, value) => source.sizeDelta = value, to, duration) - .SetTarget(transform); + Tweening.To(transform, (target) => target.sizeDelta, (target, value) => target.sizeDelta = value, to, duration) + .SetReference(transform); } } diff --git a/Runtime/Extensions/UI/ScrollRectTweens.cs b/Runtime/Extensions/UI/ScrollRectTweens.cs index 00b8ca0..8eb2a62 100644 --- a/Runtime/Extensions/UI/ScrollRectTweens.cs +++ b/Runtime/Extensions/UI/ScrollRectTweens.cs @@ -6,40 +6,40 @@ namespace Zigurous.Tweening public static class ScrollRectTweens { public static Tween TweenElasticity(this ScrollRect scrollRect, float to, float duration) => - Tweening.To(scrollRect, (source) => source.elasticity, (source, value) => source.elasticity = value, to, duration) - .SetTarget(scrollRect); + Tweening.To(scrollRect, (target) => target.elasticity, (target, value) => target.elasticity = value, to, duration) + .SetReference(scrollRect); public static Tween TweenDecelerationRate(this ScrollRect scrollRect, float to, float duration) => - Tweening.To(scrollRect, (source) => source.decelerationRate, (source, value) => source.decelerationRate = value, to, duration) - .SetTarget(scrollRect); + Tweening.To(scrollRect, (target) => target.decelerationRate, (target, value) => target.decelerationRate = value, to, duration) + .SetReference(scrollRect); public static Tween TweenScrollSensitivity(this ScrollRect scrollRect, float to, float duration) => - Tweening.To(scrollRect, (source) => source.scrollSensitivity, (source, value) => source.scrollSensitivity = value, to, duration) - .SetTarget(scrollRect); + Tweening.To(scrollRect, (target) => target.scrollSensitivity, (target, value) => target.scrollSensitivity = value, to, duration) + .SetReference(scrollRect); public static Tween TweenVelocity(this ScrollRect scrollRect, Vector2 to, float duration) => - Tweening.To(scrollRect, (source) => source.velocity, (source, value) => source.velocity = value, to, duration) - .SetTarget(scrollRect); + Tweening.To(scrollRect, (target) => target.velocity, (target, value) => target.velocity = value, to, duration) + .SetReference(scrollRect); public static Tween TweenNormalizedPosition(this ScrollRect scrollRect, Vector2 to, float duration) => - Tweening.To(scrollRect, (source) => source.normalizedPosition, (source, value) => source.normalizedPosition = value, to, duration) - .SetTarget(scrollRect); + Tweening.To(scrollRect, (target) => target.normalizedPosition, (target, value) => target.normalizedPosition = value, to, duration) + .SetReference(scrollRect); public static Tween TweenHorizontalNormalizedPosition(this ScrollRect scrollRect, float to, float duration) => - Tweening.To(scrollRect, (source) => source.horizontalNormalizedPosition, (source, value) => source.horizontalNormalizedPosition = value, to, duration) - .SetTarget(scrollRect); + Tweening.To(scrollRect, (target) => target.horizontalNormalizedPosition, (target, value) => target.horizontalNormalizedPosition = value, to, duration) + .SetReference(scrollRect); public static Tween TweenVerticalNormalizedPosition(this ScrollRect scrollRect, float to, float duration) => - Tweening.To(scrollRect, (source) => source.verticalNormalizedPosition, (source, value) => source.verticalNormalizedPosition = value, to, duration) - .SetTarget(scrollRect); + Tweening.To(scrollRect, (target) => target.verticalNormalizedPosition, (target, value) => target.verticalNormalizedPosition = value, to, duration) + .SetReference(scrollRect); public static Tween TweenHorizontalScrollbarSpacing(this ScrollRect scrollRect, float to, float duration) => - Tweening.To(scrollRect, (source) => source.horizontalScrollbarSpacing, (source, value) => source.horizontalScrollbarSpacing = value, to, duration) - .SetTarget(scrollRect); + Tweening.To(scrollRect, (target) => target.horizontalScrollbarSpacing, (target, value) => target.horizontalScrollbarSpacing = value, to, duration) + .SetReference(scrollRect); public static Tween TweenVerticalScrollbarSpacing(this ScrollRect scrollRect, float to, float duration) => - Tweening.To(scrollRect, (source) => source.verticalScrollbarSpacing, (source, value) => source.verticalScrollbarSpacing = value, to, duration) - .SetTarget(scrollRect); + Tweening.To(scrollRect, (target) => target.verticalScrollbarSpacing, (target, value) => target.verticalScrollbarSpacing = value, to, duration) + .SetReference(scrollRect); } } diff --git a/Runtime/Extensions/UI/ScrollbarTweens.cs b/Runtime/Extensions/UI/ScrollbarTweens.cs index 09cf474..cb436b8 100644 --- a/Runtime/Extensions/UI/ScrollbarTweens.cs +++ b/Runtime/Extensions/UI/ScrollbarTweens.cs @@ -5,12 +5,12 @@ namespace Zigurous.Tweening public static class ScrollbarTweens { public static Tween TweenValue(this Scrollbar scrollbar, float to, float duration) => - Tweening.To(scrollbar, (source) => source.value, (source, value) => source.value = value, to, duration) - .SetTarget(scrollbar); + Tweening.To(scrollbar, (target) => target.value, (target, value) => target.value = value, to, duration) + .SetReference(scrollbar); public static Tween TweenSize(this Scrollbar scrollbar, float to, float duration) => - Tweening.To(scrollbar, (source) => source.size, (source, value) => source.size = value, to, duration) - .SetTarget(scrollbar); + Tweening.To(scrollbar, (target) => target.size, (target, value) => target.size = value, to, duration) + .SetReference(scrollbar); } } diff --git a/Runtime/Extensions/UI/ShadowTweens.cs b/Runtime/Extensions/UI/ShadowTweens.cs index c220877..7519125 100644 --- a/Runtime/Extensions/UI/ShadowTweens.cs +++ b/Runtime/Extensions/UI/ShadowTweens.cs @@ -6,16 +6,16 @@ namespace Zigurous.Tweening public static class ShadowTweens { public static Tween TweenColor(this Shadow shadow, Color to, float duration) => - Tweening.To(shadow, (source) => source.effectColor, (source, value) => source.effectColor = value, to, duration) - .SetTarget(shadow); + Tweening.To(shadow, (target) => target.effectColor, (target, value) => target.effectColor = value, to, duration) + .SetReference(shadow); public static Tween TweenAlpha(this Shadow shadow, float to, float duration) => - Tweening.To(shadow, (source) => source.effectColor.a, (source, value) => source.effectColor = new Color(source.effectColor.r, source.effectColor.g, source.effectColor.b, value), to, duration) - .SetTarget(shadow); + Tweening.To(shadow, (target) => target.effectColor.a, (target, value) => target.effectColor = new Color(target.effectColor.r, target.effectColor.g, target.effectColor.b, value), to, duration) + .SetReference(shadow); public static Tween TweenDistance(this Shadow shadow, Vector2 to, float duration) => - Tweening.To(shadow, (source) => source.effectDistance, (source, value) => source.effectDistance = value, to, duration) - .SetTarget(shadow); + Tweening.To(shadow, (target) => target.effectDistance, (target, value) => target.effectDistance = value, to, duration) + .SetReference(shadow); } } diff --git a/Runtime/Extensions/UI/SliderTweens.cs b/Runtime/Extensions/UI/SliderTweens.cs index e690d88..5749b57 100644 --- a/Runtime/Extensions/UI/SliderTweens.cs +++ b/Runtime/Extensions/UI/SliderTweens.cs @@ -5,20 +5,20 @@ namespace Zigurous.Tweening public static class SliderTweens { public static Tween TweenValue(this Slider slider, float to, float duration) => - Tweening.To(slider, (source) => source.value, (source, value) => source.value = value, to, duration) - .SetTarget(slider); + Tweening.To(slider, (target) => target.value, (target, value) => target.value = value, to, duration) + .SetReference(slider); public static Tween TweenNormalizedValue(this Slider slider, float to, float duration) => - Tweening.To(slider, (source) => source.normalizedValue, (source, value) => source.normalizedValue = value, to, duration) - .SetTarget(slider); + Tweening.To(slider, (target) => target.normalizedValue, (target, value) => target.normalizedValue = value, to, duration) + .SetReference(slider); public static Tween TweenMinValue(this Slider slider, float to, float duration) => - Tweening.To(slider, (source) => source.minValue, (source, value) => source.minValue = value, to, duration) - .SetTarget(slider); + Tweening.To(slider, (target) => target.minValue, (target, value) => target.minValue = value, to, duration) + .SetReference(slider); public static Tween TweenMaxValue(this Slider slider, float to, float duration) => - Tweening.To(slider, (source) => source.maxValue, (source, value) => source.maxValue = value, to, duration) - .SetTarget(slider); + Tweening.To(slider, (target) => target.maxValue, (target, value) => target.maxValue = value, to, duration) + .SetReference(slider); } } diff --git a/Runtime/Extensions/UI/TextMeshTweens.cs b/Runtime/Extensions/UI/TextMeshTweens.cs index f22b778..1121ebe 100644 --- a/Runtime/Extensions/UI/TextMeshTweens.cs +++ b/Runtime/Extensions/UI/TextMeshTweens.cs @@ -5,32 +5,32 @@ namespace Zigurous.Tweening public static class TextMeshTweens { public static Tween TweenColor(this TextMesh textMesh, Color to, float duration) => - Tweening.To(textMesh, (source) => source.color, (source, value) => source.color = value, to, duration) - .SetTarget(textMesh); + Tweening.To(textMesh, (target) => target.color, (target, value) => target.color = value, to, duration) + .SetReference(textMesh); public static Tween TweenAlpha(this TextMesh textMesh, float to, float duration) => - Tweening.To(textMesh, (source) => source.color.a, (source, value) => source.color = new Color(source.color.r, source.color.g, source.color.b, value), to, duration) - .SetTarget(textMesh); + Tweening.To(textMesh, (target) => target.color.a, (target, value) => target.color = new Color(target.color.r, target.color.g, target.color.b, value), to, duration) + .SetReference(textMesh); public static Tween TweenFontSize(this TextMesh textMesh, int to, float duration) => - Tweening.To(textMesh, (source) => source.fontSize, (source, value) => source.fontSize = value, to, duration) - .SetTarget(textMesh); + Tweening.To(textMesh, (target) => target.fontSize, (target, value) => target.fontSize = value, to, duration) + .SetReference(textMesh); public static Tween TweenOffsetZ(this TextMesh textMesh, float to, float duration) => - Tweening.To(textMesh, (source) => source.offsetZ, (source, value) => source.offsetZ = value, to, duration) - .SetTarget(textMesh); + Tweening.To(textMesh, (target) => target.offsetZ, (target, value) => target.offsetZ = value, to, duration) + .SetReference(textMesh); public static Tween TweenCharacterSize(this TextMesh textMesh, float to, float duration) => - Tweening.To(textMesh, (source) => source.characterSize, (source, value) => source.characterSize = value, to, duration) - .SetTarget(textMesh); + Tweening.To(textMesh, (target) => target.characterSize, (target, value) => target.characterSize = value, to, duration) + .SetReference(textMesh); public static Tween TweenLineSpacing(this TextMesh textMesh, float to, float duration) => - Tweening.To(textMesh, (source) => source.lineSpacing, (source, value) => source.lineSpacing = value, to, duration) - .SetTarget(textMesh); + Tweening.To(textMesh, (target) => target.lineSpacing, (target, value) => target.lineSpacing = value, to, duration) + .SetReference(textMesh); public static Tween TweenTabSize(this TextMesh textMesh, float to, float duration) => - Tweening.To(textMesh, (source) => source.tabSize, (source, value) => source.tabSize = value, to, duration) - .SetTarget(textMesh); + Tweening.To(textMesh, (target) => target.tabSize, (target, value) => target.tabSize = value, to, duration) + .SetReference(textMesh); } } diff --git a/Runtime/Extensions/UI/TextTweens.cs b/Runtime/Extensions/UI/TextTweens.cs index 9474577..688aa43 100644 --- a/Runtime/Extensions/UI/TextTweens.cs +++ b/Runtime/Extensions/UI/TextTweens.cs @@ -5,8 +5,8 @@ namespace Zigurous.Tweening public static class TextTweens { public static Tween TweenFontSize(this Text text, int to, float duration) => - Tweening.To(text, (source) => source.fontSize, (source, value) => source.fontSize = value, to, duration) - .SetTarget(text); + Tweening.To(text, (target) => target.fontSize, (target, value) => target.fontSize = value, to, duration) + .SetReference(text); } } diff --git a/Runtime/PropertyChaining.cs b/Runtime/PropertyChaining.cs index b8b2c9d..a4ad0a8 100644 --- a/Runtime/PropertyChaining.cs +++ b/Runtime/PropertyChaining.cs @@ -1,5 +1,3 @@ -using UnityEngine; - namespace Zigurous.Tweening { /// @@ -10,38 +8,133 @@ namespace Zigurous.Tweening public static class PropertyChaining { /// - /// Sets the id of the tween to the target component so the tween can be - /// retrieved and destroyed based on that target. + /// Sets the target object of the tween. + /// + /// The type of object being tweened. + /// The type of parameter being tweened. + /// The tween to assign the target to. + /// The target object to tween. + /// The tween itself to allow for chaining. + public static Tweener SetTarget(this Tweener tween, T target) + { + if (tween != null) + { + tween.target = target; + + if (target is UnityEngine.Component component) { + SetReference(tween, component); + } else if (target is UnityEngine.GameObject gameObject) { + SetReference(tween, gameObject); + } else if (target is UnityEngine.Object obj) { + SetReference(tween, obj); + } + } + + return tween; + } + + /// + /// Sets the getter function of the tween. + /// + /// The type of object being tweened. + /// The type of parameter being tweened. + /// The tween to assign the getter to. + /// The getter function to set. + /// The tween itself to allow for chaining. + public static Tweener SetGetter(this Tweener tween, TweenGetter getter) + { + if (tween != null) { + tween.getter = getter; + } + + return tween; + } + + /// + /// Sets the setter function of the tween. + /// + /// The type of object being tweened. + /// The type of parameter being tweened. + /// The tween to assign the setter to. + /// The setter function to set. + /// The tween itself to allow for chaining. + public static Tweener SetSetter(this Tweener tween, TweenSetter setter) + { + if (tween != null) { + tween.setter = setter; + } + + return tween; + } + + /// + /// Sets the end value of the tween. + /// + /// The type of object being tweened. + /// The type of parameter being tweened. + /// The tween to assign the setter to. + /// The end value to set. + /// The tween itself to allow for chaining. + public static Tweener SetEndValue(this Tweener tween, U endValue) + { + if (tween != null) { + tween.endValue = endValue; + } + + return tween; + } + + /// + /// Sets the id and scene index of the tween to the reference component + /// so the tween can be retrieved and destroyed based on that component. /// /// The type of the tween. - /// The tween to assign the value to. - /// The target component. + /// The tween to assign the reference to. + /// The reference component. /// The tween itself to allow for chaining. - public static T SetTarget(this T tween, Component target) where T : Tween + public static T SetReference(this T tween, UnityEngine.Component reference) where T : Tween { - if (tween != null && target != null) + if (tween != null && reference != null) { - tween.id = target.GetHashCode(); - tween.sceneIndex = target.gameObject.scene.buildIndex; + tween.id = reference.GetInstanceID(); + tween.sceneIndex = reference.gameObject.scene.buildIndex; } return tween; } /// - /// Sets the id of the tween to the target game object so the tween can - /// be retrieved and destroyed based on that game object. + /// Sets the id and scene index of the tween to the reference game + /// object so the tween can be retrieved and destroyed based on that + /// game object. /// /// The type of the tween. - /// The tween to assign the value to. - /// The target component. + /// The tween to assign the reference to. + /// The reference game object. /// The tween itself to allow for chaining. - public static T SetTarget(this T tween, GameObject target) where T : Tween + public static T SetReference(this T tween, UnityEngine.GameObject reference) where T : Tween { - if (tween != null && target != null) + if (tween != null && reference != null) { - tween.id = target.GetHashCode(); - tween.sceneIndex = target.scene.buildIndex; + tween.id = reference.GetInstanceID(); + tween.sceneIndex = reference.scene.buildIndex; + } + + return tween; + } + + /// + /// Sets the id and scene index of the tween to the reference object so + /// the tween can be retrieved and destroyed based on that object. + /// + /// The type of the tween. + /// The tween to assign the reference to. + /// The reference object. + /// The tween itself to allow for chaining. + public static T SetReference(this T tween, UnityEngine.Object reference) where T : Tween + { + if (tween != null && reference != null) { + tween.id = reference.GetInstanceID(); } return tween; @@ -51,7 +144,7 @@ public static T SetTarget(this T tween, GameObject target) where T : Tween /// Sets the id of the tween to the given value. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to assign the id to. /// The id to set. /// The tween itself to allow for chaining. public static T SetId(this T tween, int id) where T : Tween @@ -67,7 +160,7 @@ public static T SetId(this T tween, int id) where T : Tween /// Sets the scene index of the tween to the given value. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to assign the scene index to. /// The scene index to set. /// The tween itself to allow for chaining. public static T SetSceneIndex(this T tween, int index) where T : Tween @@ -83,7 +176,7 @@ public static T SetSceneIndex(this T tween, int index) where T : Tween /// Sets the ease of the tween to the given value. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to assign the ease to. /// The ease to set. /// The tween itself to allow for chaining. public static T SetEase(this T tween, Ease ease) where T : Tween @@ -99,7 +192,7 @@ public static T SetEase(this T tween, Ease ease) where T : Tween /// Sets the duration of the tween to the given value. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to assign the duration to. /// The duration to set. /// The tween itself to allow for chaining. public static T SetDuration(this T tween, float duration) where T : Tween @@ -115,7 +208,7 @@ public static T SetDuration(this T tween, float duration) where T : Tween /// Sets the delay of the tween to the given value. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to assign the delay to. /// The delay to set. /// The tween itself to allow for chaining. public static T SetDelay(this T tween, float delay) where T : Tween @@ -131,7 +224,7 @@ public static T SetDelay(this T tween, float delay) where T : Tween /// Sets the number of loops of the tween to the given value. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to loop. /// The number of loops to set. /// The type of loop style to set. /// The tween itself to allow for chaining. @@ -150,7 +243,7 @@ public static T SetLoops(this T tween, int loops, LoopType loopType = LoopTyp /// Sets the tween to play in reverse. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to reverse. /// True if the tween is to be played in reverse. /// The tween itself to allow for chaining. public static T SetReversed(this T tween, bool reversed = true) where T : Tween @@ -166,7 +259,7 @@ public static T SetReversed(this T tween, bool reversed = true) where T : Twe /// Sets the tween to snap interpolated values to whole numbers. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to enable snapping on. /// True if interpolated values should be snapped to whole numbers. /// The tween itself to allow for chaining. public static T SetSnapping(this T tween, bool snapping = true) where T : Tween @@ -182,10 +275,10 @@ public static T SetSnapping(this T tween, bool snapping = true) where T : Twe /// Sets the tween to be recycled after being completed. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to recycle. /// True if the tween is to be recycled. /// The tween itself to allow for chaining. - public static T SetRecyclable(this T tween, bool recyclable) where T : Tween + public static T SetRecyclable(this T tween, bool recyclable = true) where T : Tween { if (tween != null) { tween.recyclable = recyclable; @@ -198,10 +291,10 @@ public static T SetRecyclable(this T tween, bool recyclable) where T : Tween /// Sets the tween to auto start after being initialized. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to auto start. /// True if the tween is to be started automatically. /// The tween itself to allow for chaining. - public static T SetAutoStart(this T tween, bool autoStart) where T : Tween + public static T SetAutoStart(this T tween, bool autoStart = true) where T : Tween { if (tween != null) { tween.autoStart = autoStart; @@ -214,10 +307,10 @@ public static T SetAutoStart(this T tween, bool autoStart) where T : Tween /// Sets the tween to auto kill after being completed. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to auto kill. /// True if the tween is to be killed automatically. /// The tween itself to allow for chaining. - public static T SetAutoKill(this T tween, bool autoKill) where T : Tween + public static T SetAutoKill(this T tween, bool autoKill = true) where T : Tween { if (tween != null) { tween.autoKill = autoKill; @@ -230,7 +323,7 @@ public static T SetAutoKill(this T tween, bool autoKill) where T : Tween /// Sets the callback to invoke when the tween is updated. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to assign the callback to. /// The callback to invoke. /// The tween itself to allow for chaining. public static T OnUpdate(this T tween, TweenCallback callback) where T : Tween @@ -246,7 +339,7 @@ public static T OnUpdate(this T tween, TweenCallback callback) where T : Twee /// Sets the callback to invoke when the tween is started. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to assign the callback to. /// The callback to invoke. /// The tween itself to allow for chaining. public static T OnStart(this T tween, TweenCallback callback) where T : Tween @@ -262,7 +355,7 @@ public static T OnStart(this T tween, TweenCallback callback) where T : Tween /// Sets the callback to invoke when the tween is stopped. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to assign the callback to. /// The callback to invoke. /// The tween itself to allow for chaining. public static T OnStop(this T tween, TweenCallback callback) where T : Tween @@ -278,7 +371,7 @@ public static T OnStop(this T tween, TweenCallback callback) where T : Tween /// Sets the callback to invoke when the tween is looped. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to assign the callback to. /// The callback to invoke. /// The tween itself to allow for chaining. public static T OnLoop(this T tween, TweenCallback callback) where T : Tween @@ -294,7 +387,7 @@ public static T OnLoop(this T tween, TweenCallback callback) where T : Tween /// Sets the callback to invoke when the tween is completed. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to assign the callback to. /// The callback to invoke. /// The tween itself to allow for chaining. public static T OnComplete(this T tween, TweenCallback callback) where T : Tween @@ -310,7 +403,7 @@ public static T OnComplete(this T tween, TweenCallback callback) where T : Tw /// Sets the callback to invoke when the tween is killed. /// /// The type of the tween. - /// The tween to assign the value to. + /// The tween to assign the callback to. /// The callback to invoke. /// The tween itself to allow for chaining. public static T OnKill(this T tween, TweenCallback callback) where T : Tween diff --git a/Runtime/Sequence.cs b/Runtime/Sequence.cs index 0302898..0c9e672 100644 --- a/Runtime/Sequence.cs +++ b/Runtime/Sequence.cs @@ -16,7 +16,7 @@ public sealed class Sequence : Tween /// /// The tweens contained in the sequence (Read only). /// - public List tweens { get; internal set; } = new List(); + public readonly List tweens = new List(); /// /// The tween in the sequence currently being played (Read only). diff --git a/Runtime/TweenManager.cs b/Runtime/TweenManager.cs index 435d2cc..4545908 100644 --- a/Runtime/TweenManager.cs +++ b/Runtime/TweenManager.cs @@ -12,7 +12,7 @@ namespace Zigurous.Tweening internal sealed class TweenManager : MonoBehaviour { private static bool isUnloading = false; - private static object lockObject = new object(); + private static readonly object lockObject = new object(); private static volatile TweenManager instance; internal static TweenManager Instance @@ -56,7 +56,7 @@ private void Awake() if (instance == null) { instance = this; - SceneManager.sceneUnloaded += SceneUnloaded; + SceneManager.sceneUnloaded += OnSceneUnloaded; } else { @@ -71,7 +71,7 @@ private void OnDestroy() if (instance == this) { instance = null; - SceneManager.sceneUnloaded -= SceneUnloaded; + SceneManager.sceneUnloaded -= OnSceneUnloaded; } foreach (Tween tween in tweens) { @@ -114,23 +114,23 @@ private void Update() /// /// Recycles or creates a new tween object. /// - internal Tweener BuildTweener() + internal Tweener BuildTweener() { - Tweener tweener = null; + Tweener tweener = null; foreach (Tween tween in tweens) { if (tween.internalState == InternalTweenState.Recycled && tween.type == TweenType.Tweener && - tween.template == typeof(Tweener)) + tween.template == typeof(Tweener)) { - tweener = (Tweener)tween; + tweener = (Tweener)tween; break; } } if (tweener == null) { - tweener = new Tweener(); + tweener = new Tweener(); } else { tweener.Reset(); } @@ -184,7 +184,7 @@ internal void Track(Tween tween) /// /// Kills all tweens that are animating objects on the unloaded scene. /// - private void SceneUnloaded(Scene scene) + private void OnSceneUnloaded(Scene scene) { foreach (Tween tween in tweens) { diff --git a/Runtime/Tweener.cs b/Runtime/Tweener.cs index fbc0b55..bd5cabe 100644 --- a/Runtime/Tweener.cs +++ b/Runtime/Tweener.cs @@ -1,44 +1,44 @@ namespace Zigurous.Tweening { /// - /// A tween that animates a parameter over time on a source object from a - /// start value to an end value. + /// A tween that animates a parameter over time on an object from a start + /// value to an end value. /// - /// The type of object to tween. - /// The type of parameter to tween. - public class Tweener : Tween + /// The type of object to tween. + /// The type of parameter to tween. + public class Tweener : Tween { /// - /// The source object being tweened. + /// The object being tweened. /// - public S source; - - /// - /// The function that interpolates values between the tween's start and - /// end value. - /// - public Interpolater interpolater; + public T target; /// /// The function that gets the current value of the parameter being /// tweened. /// - public TweenGetter getter; + public TweenGetter getter; /// /// The function that sets a new value of the parameter being tweened. /// - public TweenSetter setter; + public TweenSetter setter; + + /// + /// The function that interpolates values between the tween's start and + /// end value. + /// + public Interpolater interpolater; /// /// The initial value of the parameter at the start of the tween. /// - public T startValue; + public U startValue; /// /// The desired value of the parameter at the end of the tween. /// - public T endValue; + public U endValue; /// /// Creates a new tweener. @@ -46,7 +46,16 @@ public class Tweener : Tween public Tweener() : base() { type = TweenType.Tweener; - template = typeof(Tweener); + template = typeof(Tweener); + } + + /// + /// Creates a new tweener with the specified target object. + /// + /// The object to tween. + public Tweener(T target) : this() + { + this.SetTarget(target); } /// @@ -63,21 +72,21 @@ public override void Animate() } float time = EaseFunction.lookup[ease](percent); - setter(source, interpolater(startValue, endValue, time, snapping)); + setter(target, interpolater(startValue, endValue, time, snapping)); } /// protected override void OnStart() { if (iterations == 0 && getter != null) { - startValue = getter(source); + startValue = getter(target); } } /// protected override void OnKill() { - source = default(S); + target = default(T); interpolater = null; getter = null; setter = null; @@ -86,7 +95,7 @@ protected override void OnKill() /// protected override void OnReset() { - source = default(S); + target = default(T); interpolater = null; getter = null; setter = null; diff --git a/Runtime/Tweening.cs b/Runtime/Tweening.cs index 7326506..caea82e 100644 --- a/Runtime/Tweening.cs +++ b/Runtime/Tweening.cs @@ -12,7 +12,7 @@ public static class Tweening /// The number of tweens currently alive. This includes tweens that have /// been recycled and are not currently active (Read only). /// - public static int count + public static int Count { get { @@ -27,7 +27,7 @@ public static int count /// /// The number of tweens that are currently alive and active (Read only). /// - public static int activeCount + public static int ActiveCount { get { @@ -53,208 +53,208 @@ public static int activeCount /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(S source, TweenGetter getter, TweenSetter setter, float endValue, float duration) => - To(Interpolation._float, source, getter, setter, endValue, duration); + public static Tween To(T target, TweenGetter getter, TweenSetter setter, float endValue, float duration) => + To(Interpolation._float, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(S source, TweenGetter getter, TweenSetter setter, double endValue, float duration) => - To(Interpolation._double, source, getter, setter, endValue, duration); + public static Tween To(T target, TweenGetter getter, TweenSetter setter, double endValue, float duration) => + To(Interpolation._double, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(S source, TweenGetter getter, TweenSetter setter, int endValue, float duration) => - To(Interpolation._int, source, getter, setter, endValue, duration); + public static Tween To(T target, TweenGetter getter, TweenSetter setter, int endValue, float duration) => + To(Interpolation._int, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(S source, TweenGetter getter, TweenSetter setter, long endValue, float duration) => - To(Interpolation._long, source, getter, setter, endValue, duration); + public static Tween To(T target, TweenGetter getter, TweenSetter setter, long endValue, float duration) => + To(Interpolation._long, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(S source, TweenGetter getter, TweenSetter setter, short endValue, float duration) => - To(Interpolation._short, source, getter, setter, endValue, duration); + public static Tween To(T target, TweenGetter getter, TweenSetter setter, short endValue, float duration) => + To(Interpolation._short, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(S source, TweenGetter getter, TweenSetter setter, Vector2 endValue, float duration) => - To(Interpolation._Vector2, source, getter, setter, endValue, duration); + public static Tween To(T target, TweenGetter getter, TweenSetter setter, Vector2 endValue, float duration) => + To(Interpolation._Vector2, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(S source, TweenGetter getter, TweenSetter setter, Vector2Int endValue, float duration) => - To(Interpolation._Vector2Int, source, getter, setter, endValue, duration); + public static Tween To(T target, TweenGetter getter, TweenSetter setter, Vector2Int endValue, float duration) => + To(Interpolation._Vector2Int, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(S source, TweenGetter getter, TweenSetter setter, Vector3 endValue, float duration) => - To(Interpolation._Vector3, source, getter, setter, endValue, duration); + public static Tween To(T target, TweenGetter getter, TweenSetter setter, Vector3 endValue, float duration) => + To(Interpolation._Vector3, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(S source, TweenGetter getter, TweenSetter setter, Vector3Int endValue, float duration) => - To(Interpolation._Vector3Int, source, getter, setter, endValue, duration); + public static Tween To(T target, TweenGetter getter, TweenSetter setter, Vector3Int endValue, float duration) => + To(Interpolation._Vector3Int, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(S source, TweenGetter getter, TweenSetter setter, Vector4 endValue, float duration) => - To(Interpolation._Vector4, source, getter, setter, endValue, duration); + public static Tween To(T target, TweenGetter getter, TweenSetter setter, Vector4 endValue, float duration) => + To(Interpolation._Vector4, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(S source, TweenGetter getter, TweenSetter setter, Quaternion endValue, float duration) => - To(Interpolation._Quaternion, source, getter, setter, endValue, duration); + public static Tween To(T target, TweenGetter getter, TweenSetter setter, Quaternion endValue, float duration) => + To(Interpolation._Quaternion, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(S source, TweenGetter getter, TweenSetter setter, Rect endValue, float duration) => - To(Interpolation._Rect, source, getter, setter, endValue, duration); + public static Tween To(T target, TweenGetter getter, TweenSetter setter, Rect endValue, float duration) => + To(Interpolation._Rect, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter to a given end value over /// a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(S source, TweenGetter getter, TweenSetter setter, Color endValue, float duration) => - To(Interpolation._Color, source, getter, setter, endValue, duration); + public static Tween To(T target, TweenGetter getter, TweenSetter setter, Color endValue, float duration) => + To(Interpolation._Color, target, getter, setter, endValue, duration); /// - /// Creates a tween that animates a parameter on a source object to a - /// given end value over a set duration. + /// Creates a tween that animates a parameter on an object to a given + /// end value over a set duration. /// - /// The type of object to tween. - /// The type of parameter to tween. + /// The type of object to tween. + /// The type of parameter to tween. /// The function that interpolates values between the start and end value. - /// The source object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween To(Interpolater interpolater, S source, TweenGetter getter, TweenSetter setter, T endValue, float duration) + public static Tween To(Interpolater interpolater, T target, TweenGetter getter, TweenSetter setter, U endValue, float duration) { if (TweenManager.Unloading) { return null; } - Tweener tween = TweenManager.Instance.BuildTweener(); - tween.source = source; - tween.interpolater = interpolater; + Tweener tween = TweenManager.Instance.BuildTweener(); + tween.target = target; tween.getter = getter; tween.setter = setter; + tween.interpolater = interpolater; tween.endValue = endValue; tween.duration = duration; tween.reversed = false; @@ -266,208 +266,208 @@ public static Tween To(Interpolater interpolater, S source, TweenGetter< /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(S source, TweenGetter getter, TweenSetter setter, float endValue, float duration) => - From(Interpolation.Lerp, source, getter, setter, endValue, duration); + public static Tween From(T target, TweenGetter getter, TweenSetter setter, float endValue, float duration) => + From(Interpolation.Lerp, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(S source, TweenGetter getter, TweenSetter setter, double endValue, float duration) => - From(Interpolation.Lerp, source, getter, setter, endValue, duration); + public static Tween From(T target, TweenGetter getter, TweenSetter setter, double endValue, float duration) => + From(Interpolation.Lerp, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(S source, TweenGetter getter, TweenSetter setter, int endValue, float duration) => - From(Interpolation.Lerp, source, getter, setter, endValue, duration); + public static Tween From(T target, TweenGetter getter, TweenSetter setter, int endValue, float duration) => + From(Interpolation.Lerp, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(S source, TweenGetter getter, TweenSetter setter, long endValue, float duration) => - From(Interpolation.Lerp, source, getter, setter, endValue, duration); + public static Tween From(T target, TweenGetter getter, TweenSetter setter, long endValue, float duration) => + From(Interpolation.Lerp, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(S source, TweenGetter getter, TweenSetter setter, short endValue, float duration) => - From(Interpolation.Lerp, source, getter, setter, endValue, duration); + public static Tween From(T target, TweenGetter getter, TweenSetter setter, short endValue, float duration) => + From(Interpolation.Lerp, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(S source, TweenGetter getter, TweenSetter setter, Vector2 endValue, float duration) => - From(Interpolation.Lerp, source, getter, setter, endValue, duration); + public static Tween From(T target, TweenGetter getter, TweenSetter setter, Vector2 endValue, float duration) => + From(Interpolation.Lerp, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(S source, TweenGetter getter, TweenSetter setter, Vector2Int endValue, float duration) => - From(Interpolation.Lerp, source, getter, setter, endValue, duration); + public static Tween From(T target, TweenGetter getter, TweenSetter setter, Vector2Int endValue, float duration) => + From(Interpolation.Lerp, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(S source, TweenGetter getter, TweenSetter setter, Vector3 endValue, float duration) => - From(Interpolation.Lerp, source, getter, setter, endValue, duration); + public static Tween From(T target, TweenGetter getter, TweenSetter setter, Vector3 endValue, float duration) => + From(Interpolation.Lerp, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(S source, TweenGetter getter, TweenSetter setter, Vector3Int endValue, float duration) => - From(Interpolation.Lerp, source, getter, setter, endValue, duration); + public static Tween From(T target, TweenGetter getter, TweenSetter setter, Vector3Int endValue, float duration) => + From(Interpolation.Lerp, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(S source, TweenGetter getter, TweenSetter setter, Vector4 endValue, float duration) => - From(Interpolation.Lerp, source, getter, setter, endValue, duration); + public static Tween From(T target, TweenGetter getter, TweenSetter setter, Vector4 endValue, float duration) => + From(Interpolation.Lerp, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(S source, TweenGetter getter, TweenSetter setter, Quaternion endValue, float duration) => - From(Interpolation.Lerp, source, getter, setter, endValue, duration); + public static Tween From(T target, TweenGetter getter, TweenSetter setter, Quaternion endValue, float duration) => + From(Interpolation.Lerp, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(S source, TweenGetter getter, TweenSetter setter, Rect endValue, float duration) => - From(Interpolation.Lerp, source, getter, setter, endValue, duration); + public static Tween From(T target, TweenGetter getter, TweenSetter setter, Rect endValue, float duration) => + From(Interpolation.Lerp, target, getter, setter, endValue, duration); /// /// Creates a tween that animates a parameter from a given end value to /// the current value over a set duration. /// - /// The type of object to tween. - /// The source object to tween. + /// The type of object to tween. + /// The object to tween. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(S source, TweenGetter getter, TweenSetter setter, Color endValue, float duration) => - From(Interpolation.Lerp, source, getter, setter, endValue, duration); + public static Tween From(T target, TweenGetter getter, TweenSetter setter, Color endValue, float duration) => + From(Interpolation.Lerp, target, getter, setter, endValue, duration); /// - /// Creates a tween that animates a parameter on a source object from a - /// given end value to the current value over a set duration. + /// Creates a tween that animates a parameter on an object from a given + /// end value to the current value over a set duration. /// - /// The type of object to tween. - /// The type of parameter to tween. - /// The source object to tween. + /// The type of object to tween. + /// The type of parameter to tween. + /// The object to tween. /// The function that interpolates values between the start and end value. /// The function that gets the current value of the parameter. /// The function that sets a new value of the parameter. /// The end value of the parameter. /// The duration of the tween. /// A new tween that animates the parameter. - public static Tween From(Interpolater interpolater, S source, TweenGetter getter, TweenSetter setter, T endValue, float duration) + public static Tween From(Interpolater interpolater, T target, TweenGetter getter, TweenSetter setter, U endValue, float duration) { if (TweenManager.Unloading) { return null; } - Tweener tween = TweenManager.Instance.BuildTweener(); - tween.source = source; - tween.interpolater = interpolater; + Tweener tween = TweenManager.Instance.BuildTweener(); + tween.target = target; tween.getter = getter; tween.setter = setter; + tween.interpolater = interpolater; tween.endValue = endValue; tween.duration = duration; tween.reversed = true; From 7804a99b175e16db9d120fb40fbb29edf59ebffd Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Sat, 21 Oct 2023 19:36:52 -0500 Subject: [PATCH 10/19] Add event handler interface to respond to events without GC allocations --- Runtime/Delegates.cs | 10 ++++- Runtime/ITweenEventHandler.cs | 46 +++++++++++++++++++++ Runtime/ITweenEventHandler.cs.meta | 11 +++++ Runtime/PropertyChaining.cs | 16 ++++++++ Runtime/Tween.cs | 64 +++++++++++++++++++++++------- 5 files changed, 130 insertions(+), 17 deletions(-) create mode 100644 Runtime/ITweenEventHandler.cs create mode 100644 Runtime/ITweenEventHandler.cs.meta diff --git a/Runtime/Delegates.cs b/Runtime/Delegates.cs index 3397bde..596db84 100644 --- a/Runtime/Delegates.cs +++ b/Runtime/Delegates.cs @@ -20,11 +20,17 @@ public delegate void TweenSetter(T target, U value); /// - /// A function delegate that can be invoked during various tween events - /// and/or state changes, such as on complete. + /// A function delegate invoked during tween lifecycle events. /// public delegate void TweenCallback(); + /// + /// A function delegate invoked during tween lifecycle events with a + /// provided reference to the tween that invoked the event. + /// + /// The tween that invoked the event. + public delegate void TweenReferenceCallback(Tween tween); + /// /// A function delegate that interpolates the value between /// and by . diff --git a/Runtime/ITweenEventHandler.cs b/Runtime/ITweenEventHandler.cs new file mode 100644 index 0000000..42366f0 --- /dev/null +++ b/Runtime/ITweenEventHandler.cs @@ -0,0 +1,46 @@ +namespace Zigurous.Tweening +{ + /// + /// A type that responds to tween lifecycle events. + /// + public interface ITweenEventHandler + { + /// + /// An event invoked every time the tween is updated, i.e., any time the + /// parameter being animated is changed. + /// + /// The tween that invoked the event. + void OnTweenUpdate(Tween tween); + + /// + /// An event invoked when the tween is started. + /// + /// The tween that invoked the event. + void OnTweenStart(Tween tween); + + /// + /// An event invoked when the tween is stopped. + /// + /// The tween that invoked the event. + void OnTweenStop(Tween tween); + + /// + /// An event invoked when the tween is looped. + /// + /// The tween that invoked the event. + void OnTweenLoop(Tween tween); + + /// + /// An event invoked when the tween is completed. + /// + /// The tween that invoked the event. + void OnTweenComplete(Tween tween); + + /// + /// An event invoked when the tween is killed. + /// + /// The tween that invoked the event. + void OnTweenKill(Tween tween); + } + +} diff --git a/Runtime/ITweenEventHandler.cs.meta b/Runtime/ITweenEventHandler.cs.meta new file mode 100644 index 0000000..e8cd905 --- /dev/null +++ b/Runtime/ITweenEventHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 023846bfd8af34743afd4f4f27045458 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/PropertyChaining.cs b/Runtime/PropertyChaining.cs index a4ad0a8..8cb7483 100644 --- a/Runtime/PropertyChaining.cs +++ b/Runtime/PropertyChaining.cs @@ -319,6 +319,22 @@ public static T SetAutoKill(this T tween, bool autoKill = true) where T : Twe return tween; } + /// + /// Sets the event handler on the tween. + /// + /// The type of the tween. + /// The tween to assign the event handler to. + /// The event handler to assign. + /// The tween itself to allow for chaining. + public static T SetEventHandler(this T tween, ITweenEventHandler eventHandler) where T : Tween + { + if (tween != null) { + tween.eventHandler = eventHandler; + } + + return tween; + } + /// /// Sets the callback to invoke when the tween is updated. /// diff --git a/Runtime/Tween.cs b/Runtime/Tween.cs index 3fad86e..f28ed95 100644 --- a/Runtime/Tween.cs +++ b/Runtime/Tween.cs @@ -182,35 +182,40 @@ public bool autoKill } /// - /// The callback invoked every time the tween is updated, i.e., any time - /// the parameter being animated is changed. + /// An event handler that responds to lifecycle events of the tween. /// - public TweenCallback onUpdate; + public ITweenEventHandler eventHandler; /// - /// The callback invoked when the tween is started. + /// An event invoked every time the tween is updated, i.e., any time the + /// parameter being animated is changed. /// - public TweenCallback onStart; + public event TweenCallback onUpdate; /// - /// The callback invoked when the tween is stopped. + /// An event invoked when the tween is started. /// - public TweenCallback onStop; + public event TweenCallback onStart; /// - /// The callback invoked when the tween is looped. + /// An event invoked when the tween is stopped. /// - public TweenCallback onLoop; + public event TweenCallback onStop; /// - /// The callback invoked when the tween is completed. + /// An event invoked when the tween is looped. /// - public TweenCallback onComplete; + public event TweenCallback onLoop; /// - /// The callback invoked when the tween is killed. + /// An event invoked when the tween is completed. /// - public TweenCallback onKill; + public event TweenCallback onComplete; + + /// + /// An event invoked when the tween is killed. + /// + public event TweenCallback onKill; /// /// Creates a new tween object. @@ -251,6 +256,10 @@ internal void Update(float deltaTime) Animate(); OnUpdate(); + if (eventHandler != null) { + eventHandler.OnTweenUpdate(this); + } + if (onUpdate != null) { onUpdate.Invoke(); } @@ -313,6 +322,10 @@ private void Start() { OnLoop(); + if (eventHandler != null) { + eventHandler.OnTweenLoop(this); + } + if (onLoop != null) { onLoop.Invoke(); } @@ -321,8 +334,15 @@ private void Start() OnStart(); Animate(); - if (iterations == 0 && onStart != null) { - onStart.Invoke(); + if (iterations == 0) + { + if (eventHandler != null) { + eventHandler.OnTweenStart(this); + } + + if (onStart != null) { + onStart.Invoke(); + } } } @@ -339,6 +359,10 @@ public void Stop() OnStop(); + if (eventHandler != null) { + eventHandler.OnTweenStop(this); + } + if (onStop != null) { onStop.Invoke(); } @@ -397,6 +421,10 @@ public void Complete() Animate(); OnComplete(); + if (eventHandler != null) { + eventHandler.OnTweenComplete(this); + } + if (onComplete != null) { onComplete.Invoke(); } @@ -421,10 +449,15 @@ public void Kill() OnKill(); + if (eventHandler != null) { + eventHandler.OnTweenKill(this); + } + if (onKill != null) { onKill.Invoke(); } + eventHandler = null; onKill = null; onUpdate = null; onStart = null; @@ -470,6 +503,7 @@ internal void Reset() autoKill = Settings.autoKill; recyclable = Settings.recyclable; + eventHandler = null; onUpdate = null; onStart = null; onStop = null; From b7f4469c663acaef71aaf11a19775285c6341663 Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Sat, 21 Oct 2023 20:25:24 -0500 Subject: [PATCH 11/19] Update property name casing --- Runtime/Sequence.cs | 50 +++++++++++------------ Runtime/Tween.cs | 88 ++++++++++++++++++++--------------------- Runtime/TweenManager.cs | 4 +- Runtime/Tweener.cs | 2 +- Runtime/Tweening.cs | 2 +- 5 files changed, 73 insertions(+), 73 deletions(-) diff --git a/Runtime/Sequence.cs b/Runtime/Sequence.cs index 0c9e672..74090c3 100644 --- a/Runtime/Sequence.cs +++ b/Runtime/Sequence.cs @@ -11,22 +11,22 @@ public sealed class Sequence : Tween /// /// The index of the current tween in the sequence being played (Read only). /// - public int currentIndex { get; private set; } = -1; + public int CurrentIndex { get; private set; } = -1; /// /// The tweens contained in the sequence (Read only). /// - public readonly List tweens = new List(); + public readonly List Tweens = new List(); /// /// The tween in the sequence currently being played (Read only). /// - public Tween activeTween + public Tween ActiveTween { get { - if (currentIndex >= 0 && currentIndex < tweens.Count) { - return tweens[currentIndex]; + if (CurrentIndex >= 0 && CurrentIndex < Tweens.Count) { + return Tweens[CurrentIndex]; } else { return null; } @@ -65,7 +65,7 @@ public override void Animate() /// The sequence itself to allow for chaining. public Sequence Append(Tween tween) { - tweens.Add(Prepare(tween)); + Tweens.Add(Prepare(tween)); return this; } @@ -76,7 +76,7 @@ public Sequence Append(Tween tween) /// The sequence itself to allow for chaining. public Sequence Prepend(Tween tween) { - tweens.Insert(0, Prepare(tween)); + Tweens.Insert(0, Prepare(tween)); return this; } @@ -91,12 +91,12 @@ private Tween Prepare(Tween tween) private void Next() { if (reversed) { - currentIndex--; + CurrentIndex--; } else { - currentIndex++; + CurrentIndex++; } - Tween tween = activeTween; + Tween tween = ActiveTween; if (tween != null) { tween.Play(); @@ -107,9 +107,9 @@ private void Next() protected override bool IsFinished() { if (reversed) { - return currentIndex < 0; + return CurrentIndex < 0; } else { - return currentIndex >= tweens.Count; + return CurrentIndex >= Tweens.Count; } } @@ -117,12 +117,12 @@ protected override bool IsFinished() protected override void OnStart() { if (reversed) { - currentIndex = tweens.Count - 1; + CurrentIndex = Tweens.Count - 1; } else { - currentIndex = 0; + CurrentIndex = 0; } - Tween tween = activeTween; + Tween tween = ActiveTween; if (tween != null) { tween.Play(); @@ -132,7 +132,7 @@ protected override void OnStart() /// protected override void OnStop() { - Tween tween = activeTween; + Tween tween = ActiveTween; if (tween != null) { tween.Stop(); @@ -142,7 +142,7 @@ protected override void OnStop() /// protected override void OnResume() { - Tween tween = activeTween; + Tween tween = ActiveTween; if (tween != null) { tween.Play(); @@ -152,13 +152,13 @@ protected override void OnResume() /// protected override void OnLoop() { - foreach (Tween tween in tweens) + foreach (Tween tween in Tweens) { if (loopType == LoopType.PingPong || loopType == LoopType.PingPongWithDelay) { tween.reversed = !tween.reversed; } - tween.elapsed = 0f; + tween.Elapsed = 0f; tween.Animate(); } } @@ -166,7 +166,7 @@ protected override void OnLoop() /// protected override void OnComplete() { - foreach (Tween tween in tweens) + foreach (Tween tween in Tweens) { if (tween != null) { tween.Complete(); @@ -177,22 +177,22 @@ protected override void OnComplete() /// protected override void OnKill() { - foreach (Tween tween in tweens) + foreach (Tween tween in Tweens) { if (tween != null) { tween.Kill(); } } - tweens.Clear(); - currentIndex = -1; + Tweens.Clear(); + CurrentIndex = -1; } /// protected override void OnReset() { - tweens.Clear(); - currentIndex = -1; + Tweens.Clear(); + CurrentIndex = -1; } } diff --git a/Runtime/Tween.cs b/Runtime/Tween.cs index f28ed95..b766c82 100644 --- a/Runtime/Tween.cs +++ b/Runtime/Tween.cs @@ -53,27 +53,27 @@ internal enum Flag /// /// The animation state of the tween. /// - public TweenState state { get; internal set; } = TweenState.Ready; + public TweenState State { get; internal set; } = TweenState.Ready; /// /// Whether the tween is playing. /// - public bool IsPlaying => state == TweenState.Playing; + public bool IsPlaying => State == TweenState.Playing; /// /// Whether the tween is stopped. /// - public bool IsStopped => state == TweenState.Stopped; + public bool IsStopped => State == TweenState.Stopped; /// /// Whether the tween is complete. /// - public bool IsComplete => state == TweenState.Complete; + public bool IsComplete => State == TweenState.Complete; /// /// Whether the tween is killed. /// - public bool IsKilled => state == TweenState.Killed; + public bool IsKilled => State == TweenState.Killed; /// /// The easing function type used by the tween to animate values. @@ -88,12 +88,12 @@ internal enum Flag /// /// The amount of seconds that have elapsed since the tween started. /// - public float elapsed { get; internal set; } + public float Elapsed { get; internal set; } /// /// The tween's percentage of completion. /// - public float PercentComplete => duration > 0f ? UnityEngine.Mathf.Clamp01(elapsed / duration) : 1f; + public float PercentComplete => duration > 0f ? UnityEngine.Mathf.Clamp01(Elapsed / duration) : 1f; /// /// The amount of seconds the tween waits before playing after being @@ -105,14 +105,14 @@ internal enum Flag /// The amount of seconds that have elapsed during the tween's delayed /// state, when applicable. /// - public float delayElapsed { get; internal set; } + public float DelayElapsed { get; internal set; } /// /// Whether the tween is currently in a delayed state, i.e., the tween /// has been started but the elapsed time has not exceeded the delay /// duration. /// - public bool IsDelayed => delayElapsed < delay; + public bool IsDelayed => DelayElapsed < delay; /// /// The number of times the tween loops. A value of -1 will loop the @@ -128,12 +128,12 @@ internal enum Flag /// /// The number of times the tween has completed. /// - public int iterations { get; internal set; } + public int Iterations { get; internal set; } /// /// The configuration flags set on the tween. /// - internal Flag flags = 0; + private Flag Flags = 0; /// /// Animates from the end value to the start value as opposed to @@ -243,7 +243,7 @@ internal void Update(float deltaTime) { if (!IsPlaying) { - if (state == TweenState.Ready && autoStart) { + if (State == TweenState.Ready && autoStart) { Play(); } return; @@ -251,7 +251,7 @@ internal void Update(float deltaTime) if (!IsDelayed) { - elapsed += deltaTime; + Elapsed += deltaTime; Animate(); OnUpdate(); @@ -272,12 +272,12 @@ internal void Update(float deltaTime) } else { - delayElapsed += deltaTime; + DelayElapsed += deltaTime; // Start the tween once the delay is complete and only if the // elapsed time is zero which indicates it has never been // updated yet - if (delayElapsed >= delay && elapsed == 0) { + if (DelayElapsed >= delay && Elapsed == 0f) { Start(); } } @@ -289,13 +289,13 @@ internal void Update(float deltaTime) /// public void Play() { - if (!state.CanTransition(TweenState.Playing)) { + if (!State.CanTransition(TweenState.Playing)) { return; } - TweenState previousState = state; + TweenState previousState = State; - state = TweenState.Playing; + State = TweenState.Playing; internalState = InternalTweenState.Active; if (previousState == TweenState.Stopped) @@ -304,8 +304,8 @@ public void Play() } else { - elapsed = 0f; - delayElapsed = 0f; + Elapsed = 0f; + DelayElapsed = 0f; if (!IsDelayed) { Start(); @@ -318,7 +318,7 @@ public void Play() /// private void Start() { - if (iterations > 0) + if (Iterations > 0) { OnLoop(); @@ -334,7 +334,7 @@ private void Start() OnStart(); Animate(); - if (iterations == 0) + if (Iterations == 0) { if (eventHandler != null) { eventHandler.OnTweenStart(this); @@ -351,11 +351,11 @@ private void Start() /// public void Stop() { - if (!state.CanTransition(TweenState.Stopped)) { + if (!State.CanTransition(TweenState.Stopped)) { return; } - state = TweenState.Stopped; + State = TweenState.Stopped; OnStop(); @@ -374,18 +374,18 @@ public void Stop() /// True if the tween is looped. private bool Loop() { - iterations++; + Iterations++; - if (iterations >= loops && loops != -1) { + if (Iterations >= loops && loops != -1) { return false; } - elapsed = 0f; + Elapsed = 0f; switch (loopType) { case LoopType.RestartWithDelay: - delayElapsed = 0f; + DelayElapsed = 0f; break; case LoopType.PingPong: @@ -394,7 +394,7 @@ private bool Loop() case LoopType.PingPongWithDelay: reversed = !reversed; - delayElapsed = 0f; + DelayElapsed = 0f; break; } @@ -410,13 +410,13 @@ private bool Loop() /// public void Complete() { - if (!state.CanTransition(TweenState.Complete)) { + if (!State.CanTransition(TweenState.Complete)) { return; } - state = TweenState.Complete; - elapsed = duration; - delayElapsed = delay; + State = TweenState.Complete; + Elapsed = duration; + DelayElapsed = delay; Animate(); OnComplete(); @@ -440,11 +440,11 @@ public void Complete() /// public void Kill() { - if (!state.CanTransition(TweenState.Killed)) { + if (!State.CanTransition(TweenState.Killed)) { return; } - state = TweenState.Killed; + State = TweenState.Killed; internalState = InternalTweenState.Dequeued; OnKill(); @@ -483,20 +483,20 @@ internal void Reset() id = -1; sceneIndex = -1; - state = TweenState.Ready; + State = TweenState.Ready; internalState = InternalTweenState.Queued; ease = Settings.defaultEase; duration = Settings.defaultDuration; - elapsed = 0f; + Elapsed = 0f; delay = Settings.defaultDelay; - delayElapsed = 0f; + DelayElapsed = 0f; loops = 0; loopType = LoopType.Restart; - iterations = 0; + Iterations = 0; - flags = 0; + Flags = 0; reversed = false; snapping = false; autoStart = Settings.autoStart; @@ -516,15 +516,15 @@ internal void Reset() internal bool GetFlag(Flag flag) { - return flags.Has(flag); + return Flags.Has(flag); } internal void SetFlag(Flag flag, bool on) { if (on) { - flags |= flag; + Flags |= flag; } else { - flags &= ~flag; + Flags &= ~flag; } } @@ -532,7 +532,7 @@ internal void SetFlag(Flag flag, bool on) /// Determines if the tween has finished playing. /// /// True if the tween has finished playing. - protected virtual bool IsFinished() => elapsed >= duration; + protected virtual bool IsFinished() => Elapsed >= duration; /// /// Override to handle custom logic when the tween is updated. diff --git a/Runtime/TweenManager.cs b/Runtime/TweenManager.cs index 4545908..fdd3d88 100644 --- a/Runtime/TweenManager.cs +++ b/Runtime/TweenManager.cs @@ -135,7 +135,7 @@ internal Tweener BuildTweener() tweener.Reset(); } - tweener.state = TweenState.Ready; + tweener.State = TweenState.Ready; tweener.internalState = InternalTweenState.Queued; return tweener; @@ -164,7 +164,7 @@ internal Sequence BuildSequence() sequence.Reset(); } - sequence.state = TweenState.Ready; + sequence.State = TweenState.Ready; sequence.internalState = InternalTweenState.Queued; return sequence; diff --git a/Runtime/Tweener.cs b/Runtime/Tweener.cs index bd5cabe..4562341 100644 --- a/Runtime/Tweener.cs +++ b/Runtime/Tweener.cs @@ -78,7 +78,7 @@ public override void Animate() /// protected override void OnStart() { - if (iterations == 0 && getter != null) { + if (Iterations == 0 && getter != null) { startValue = getter(target); } } diff --git a/Runtime/Tweening.cs b/Runtime/Tweening.cs index caea82e..7e35d61 100644 --- a/Runtime/Tweening.cs +++ b/Runtime/Tweening.cs @@ -502,7 +502,7 @@ public static Sequence Sequence(params Tween[] tweens) Sequence sequence = TweenManager.Instance.BuildSequence(); if (tweens != null && tweens.Length > 0) { - sequence.tweens.AddRange(tweens); + sequence.Tweens.AddRange(tweens); } return sequence; From 2c1633d2526ee58860a7a31d9921faf6e85b1cbe Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Sat, 21 Oct 2023 20:27:45 -0500 Subject: [PATCH 12/19] Update documentation --- Documentation~/articles/callbacks.md | 36 -------- Documentation~/articles/events.md | 95 ++++++++++++++++++++ Documentation~/articles/index.md | 2 +- Documentation~/articles/managing-tweens.md | 20 +++-- Documentation~/articles/property-chaining.md | 16 +++- Documentation~/articles/supported-types.md | 1 + Documentation~/articles/tweens.md | 36 ++++---- Documentation~/data/sidenav.json | 4 +- 8 files changed, 142 insertions(+), 68 deletions(-) delete mode 100644 Documentation~/articles/callbacks.md create mode 100644 Documentation~/articles/events.md diff --git a/Documentation~/articles/callbacks.md b/Documentation~/articles/callbacks.md deleted file mode 100644 index a5fbd48..0000000 --- a/Documentation~/articles/callbacks.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -slug: "/manual/callbacks" ---- - -# Callbacks - -Callbacks are used to respond to state changes of a tween. A [TweenCallback](/api/Zigurous.Tweening/TweenCallback) function delegate is invoked for each of the following events: - -- [onUpdate](/api/Zigurous.Tweening/Tween/onUpdate): Invoked every time the tween is updated -- [onStart](/api/Zigurous.Tweening/Tween/onStart): Invoked when the tween is started -- [onStop](/api/Zigurous.Tweening/Tween/onStop): Invoked when the tween is stopped -- [onLoop](/api/Zigurous.Tweening/Tween/onLoop): Invoked when the tween is looped -- [onComplete](/api/Zigurous.Tweening/Tween/onComplete): Invoked when the tween is completed -- [onKill](/api/Zigurous.Tweening/Tween/onKill): Invoked when the tween is killed - -
- -## 🗣️ Assigning callbacks - -Tween callbacks can be assigned with lambdas or normal functions. You can also use [property chaining](/manual/property-chaining) to make it easier in some cases. Tween callbacks have no parameters or return types. - -```csharp -// assigning callbacks with lambdas -tween.onUpdate = () => Debug.Log("Updated"); -tween.onStart = () => Debug.Log("Started"); -tween.onStop = () => Debug.Log("Stopped"); -tween.onLoop = () => Debug.Log("Looped"); -tween.onComplete = () => Debug.Log("Completed"); -tween.onKill = () => Debug.Log("Killed"); -``` - -```csharp -// assigning a callback with a function -Tween tween = transform.TweenPosition(Vector3.zero, 1f); -tween.onComplete = SomeFunction; -``` diff --git a/Documentation~/articles/events.md b/Documentation~/articles/events.md new file mode 100644 index 0000000..6388ba3 --- /dev/null +++ b/Documentation~/articles/events.md @@ -0,0 +1,95 @@ +--- +slug: "/manual/events" +--- + +# Events + +Various events are invoked throughout the tween lifecycle. A [TweenCallback](/api/Zigurous.Tweening/TweenCallback) function delegate can be used to respond to the following events: + +- [onUpdate](/api/Zigurous.Tweening/Tween/onUpdate): Invoked every time the tween is updated +- [onStart](/api/Zigurous.Tweening/Tween/onStart): Invoked when the tween is started +- [onStop](/api/Zigurous.Tweening/Tween/onStop): Invoked when the tween is stopped +- [onLoop](/api/Zigurous.Tweening/Tween/onLoop): Invoked when the tween is looped +- [onComplete](/api/Zigurous.Tweening/Tween/onComplete): Invoked when the tween is completed +- [onKill](/api/Zigurous.Tweening/Tween/onKill): Invoked when the tween is killed + +
+ +## 🗣️ Assigning callbacks + +Tween callbacks can be assigned with delegates or lambdas. They have no parameters or return types. You can also use [property chaining](/manual/property-chaining) to make it easier to set multiple callbacks. + +```csharp +// assigning callbacks with functions +tween.onUpdate += OnTweenUpdated +tween.onStart += OnTweenStarted; +tween.onStop += OnTweenStopped; +tween.onLoop += OnTweenLooped; +tween.onComplete += OnTweenCompleted; +tween.onKill += OnTweenKilled; +``` + +```csharp +// assigning callbacks with lambdas +tween.onUpdate += () => Debug.Log("Updated"); +tween.onStart += () => Debug.Log("Started"); +tween.onStop += () => Debug.Log("Stopped"); +tween.onLoop += () => Debug.Log("Looped"); +tween.onComplete += () => Debug.Log("Completed"); +tween.onKill += () => Debug.Log("Killed"); +``` + +```csharp +// assigning callbacks with property chaining +transform.TweenPosition(Vector3.zero, 1f) + .OnUpdate(OnTweenUpdated) + .OnStart(OnTweenStarted) + .OnStop(OnTweenStopped) + .OnLoop(OnTweenLooped) + .OnComplete(OnTweenCompleted) + .OnKill(OnTweenKilled); +``` + +## 🎫 Event Handler + +One drawback of using delegates is that it produces GC allocations. If you are highly concerned about performance, you can use the [ITweenEventHandler](/api/Zigurous.Tweening/ITweenEventHandler) interface to avoid allocations. + +```csharp +public class Example : MonoBehaviour, ITweenEventHandler +{ + private void Start() + { + transform.TweenPosition(Vector3.zero, 1f) + .SetEventHandler(this); + } + + public void OnTweenUpdate(Tween tween) + { + Debug.Log("Updated"); + } + + public void OnTweenStart(Tween tween) + { + Debug.Log("Started"); + } + + public void OnTweenStop(Tween tween) + { + Debug.Log("Stopped"); + } + + public void OnTweenLoop(Tween tween) + { + Debug.Log("Looped"); + } + + public void OnTweenComplete(Tween tween) + { + Debug.Log("Completed"); + } + + public void OnTweenKill(Tween tween) + { + Debug.Log("Killed"); + } +} diff --git a/Documentation~/articles/index.md b/Documentation~/articles/index.md index 4b1c032..f91dc43 100644 --- a/Documentation~/articles/index.md +++ b/Documentation~/articles/index.md @@ -30,7 +30,7 @@ The system is lightweight, optimized, type-safe, and memory efficient. Hundreds #### 〽️ [Easing](/manual/easing) -#### 🗣️ [Callbacks](/manual/callbacks) +#### 🎫 [Events](/manual/events) #### ⛓️ [Property Chaining](/manual/property-chaining) diff --git a/Documentation~/articles/managing-tweens.md b/Documentation~/articles/managing-tweens.md index 9f47ca8..5966600 100644 --- a/Documentation~/articles/managing-tweens.md +++ b/Documentation~/articles/managing-tweens.md @@ -17,15 +17,15 @@ Tweening.KillAll(); You can also get the current amount of tweens: ```csharp -int count = Tweening.Count; // the number of tweens alive (not necessarily active) -int alive = Tweening.ActiveCount; // the number of tween active +int count = Tweening.Count; // the number of alive tweens (not necessarily active) +int activeCount = Tweening.ActiveCount; // the number of active tweens ```
## 🏷️ Tween Ids -You can also target specific tweens by id. Every tween has an `id` property which allows you to distinguish it from others. However, this is not required, nor is the id unique. The id is set automatically unless you create tweens manually using the generic approach. +You can also target specific tweens by id. Every tween has an `id` property which allows you to distinguish it from others. However, this is not required, nor is the id unique. The id is set automatically unless you create tweens manually using the generic approach. All ids are implement as `int` values. ```csharp Tweening.Play(id); @@ -35,6 +35,12 @@ Tweening.Complete(id); Tweening.Kill(id); ``` +To manually set the id of a tween: + +```csharp +tween.id = id; +``` +
## 🎯 Target References @@ -49,18 +55,18 @@ Tweening.Complete(transform); Tweening.Kill(transform); ``` -If you create tweens manually using the generic approach, you should indicate to the tween what its target game object or component is, which will set the id of the tween based on that object's hash code. +If you create tweens manually using the generic approach, you should indicate to the tween what game object or component it is referencing. This sets both the id (see above) and scene index (see below) of the tween. ```csharp -tween.SetTarget(gameObject); -tween.SetTarget(component); +tween.SetReference(gameObject); +tween.SetReference(component); ```
## 🎬 Scene Unloading -Tweens will be killed automatically when the scene they are apart of is unloaded which prevents errors. However, this only works automatically if the tween knows which target object it is animating (see above). You should only need to worry about this if you are creating tweens manually using the generic approach. +Tweens will be killed automatically when the scene they are apart of is unloaded which prevents errors accessing objects that have been destroyed. However, this only works automatically if the tween knows which target object it is animating (see above). You should only need to worry about this if you are creating tweens manually using the generic approach. Make sure to kill your tweens before transitioning scenes, or set the target reference as outlined above. You can also manually set the scene index if desired. diff --git a/Documentation~/articles/property-chaining.md b/Documentation~/articles/property-chaining.md index 25a90b1..817d220 100644 --- a/Documentation~/articles/property-chaining.md +++ b/Documentation~/articles/property-chaining.md @@ -8,13 +8,25 @@ Property/method chaining is a technique that allows multiple properties to be as
-## ⛓️ Example +## ⛓️ Examples ```csharp +// using a tween shortcut transform.TweenPosition(Vector3.zero, 1f) .SetDelay(3f) - .SetReversed(true) + .SetReversed() .SetEase(Ease.CubicInOut) .SetLoops(-1, LoopType.PingPong) .OnLoop(() => Debug.Log("looped!")); ``` + +```csharp +// building from scratch +Tween tween = new Tweener(transform) + .SetGetter((target) => target.position) + .SetSetter((target, value) => target.position = value) + .SetEndValue(Vector3.zero) + .SetDuration(1f) + .SetEase(Ease.QuadOut) + .OnComplete(() => Debug.Log("complete!")); +``` diff --git a/Documentation~/articles/supported-types.md b/Documentation~/articles/supported-types.md index 28152bf..f96d1a3 100644 --- a/Documentation~/articles/supported-types.md +++ b/Documentation~/articles/supported-types.md @@ -76,6 +76,7 @@ All of the following types offer shortcut functions for creating tweens: - `LineRenderer` - `LookAtConstraint` - `Material` +- `MaterialPropertyBlock` - `NavMeshAgent` - `NavMeshObstacle` - `OcclusionArea` diff --git a/Documentation~/articles/tweens.md b/Documentation~/articles/tweens.md index 2e6f790..c7414f7 100644 --- a/Documentation~/articles/tweens.md +++ b/Documentation~/articles/tweens.md @@ -18,29 +18,25 @@ A tween is an animation of a value from a start position to an end position usin Most of the time you will be creating tweens by using the shortcut extension methods available on most Unity objects. See the [Supported Types](/manual/supported-types) manual for the full list of classes that provide shortcut functions. Here are just a few examples: ```csharp -transform.TweenPosition(endValue, duration); -material.TweenColor(endValue, duration); -camera.TweenFieldOfView(endValue, duration); -light.TweenIntensity(endValue, duration); +transform.TweenPosition(Vector3.zero, duration); +material.TweenColor(Color.white, duration); +camera.TweenFieldOfView(90f, duration); +light.TweenIntensity(1f, duration); ```
### Generic Approach -Although most of the time you will not be creating tweens with this approach, it is the basis of the entire tweening system so it is valuable to understand how it works. Essentially any value represented by a number can be tweened. The [Supported Types](/manual/supported-types) manual lists all of the specific types that can be tweened. +Although most of the time you will not be creating tweens with this approach, it is the basis of the entire tweening system so it is valuable to understand how it works. Essentially any value represented by a number can be tweened. The [Supported Types](/manual/supported-types) manual provides a list of all types that can be tweened. ```csharp -float currentValue, endValue, duration; - // Setup delegates to get and set a value -TweenGetter getter = () => { return currentValue; }; -TweenSetter setter = newValue => { currentValue = newValue; }; - -// Create a tween that animates to the end value from the current value -Tweening.To(getter, setter, endValue, duration); +TweenGetter getter = (target) => target.position; +TweenSetter setter = (target, value) => target.position = value; -// Create a tween that animates from the end value to the current value -Tweening.From(getter, setter, endValue, duration); +// Create a tween that animates to the end value over a duration +Tweening.To(transform, getter, setter, Vector3.one, 1f); +Tweening.From(transform, getter, setter, Vector3.one, 1f); ```
@@ -69,10 +65,10 @@ All of these properties can be set with [property chaining](/manual/property-cha ## 🌪️ Controlling tweens -Often times you might want to manually control the state of the tween, even if it is just pausing and resuming a tween. There are several methods available to transition a tween to a different state. *Note*: not all states can be transitioned to depending on the current state. See [Managing Tweens](/manual/managing-tweens) for ways to control tweens globally. +Often times you might want to manually control the state of the tween, even if it is just pausing and resuming a tween. There are several methods available to transition a tween to a different state. *Note:* not all states can be transitioned to depending on the current state. See [Managing Tweens](/manual/managing-tweens) for ways to control tweens globally. ```csharp -tween.Play(); // starts or resumes the the tween +tween.Play(); // starts or resumes the tween tween.Stop(); // pauses the tween if it is already playing tween.Restart(); // restarts the tween from the beginning if not killed tween.Complete(); // completes the tween, jumping to the end value @@ -92,7 +88,7 @@ There are a number of properties available to read the current state of a tween. - `Killed`: The tween is killed, making it no longer usable. ```csharp -TweenState state = tween.state; // the current animation state of the tween +TweenState state = tween.State; // the current animation state of the tween bool playing = tween.IsPlaying; // true if playing bool stopped = tween.IsStopped; // true if stopped @@ -100,9 +96,9 @@ bool complete = tween.IsComplete; // true if complete bool killed = tween.IsKilled; // true if killed bool delayed = tween.IsDelayed; // true if delayed -float elapsed = tween.elapsed; // the amount of seconds playing +float elapsed = tween.Elapsed; // the amount of seconds playing float percent = tween.PercentComplete; // the percentage of completion -float delayElapsed = tween.delayElapsed; // the amount of seconds delayed +float delayElapsed = tween.DelayElapsed; // the amount of seconds delayed -int iterations = tween.iterations; // the number of times completed +int iterations = tween.Iterations; // the number of times completed ``` diff --git a/Documentation~/data/sidenav.json b/Documentation~/data/sidenav.json index f2604cd..07cebfd 100644 --- a/Documentation~/data/sidenav.json +++ b/Documentation~/data/sidenav.json @@ -36,8 +36,8 @@ "path": "/manual/easing" }, { - "name": "Callbacks", - "path": "/manual/callbacks" + "name": "Events", + "path": "/manual/events" }, { "name": "Property Chaining", From 428ef702e7c49906cbae4ecd99059eab2a404375 Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Sat, 21 Oct 2023 20:28:00 -0500 Subject: [PATCH 13/19] Update package version to 3.0.0 --- CHANGELOG.md | 27 ++++++++++++++++++--------- package.json | 2 +- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index efc8794..c2e53ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,26 +5,35 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [2.6.2] - 2022/10/16 - -### Fixed - -- Fixed tweens not updating when the duration is set to zero +## [3.0.0] - TBD ### Added -- New extension method `ShadowTweens.TweenAlpha` +- Support for creating generic tweens with `short` values +- New extension methods for tweening `MaterialPropertyBlock` +- New extension method `Shadow.TweenAlpha` +- New interface `ITweenEventHandler` that can be used to respond to tween events without allocating GC from delegates +- New utility functions to change color components ### Changed -- Renamed `ShadowTweens.TweenEffectColor` to `ShadowTweens.TweenColor` -- Renamed `ShadowTweens.TweenEffectDistance` to `ShadowTweens.TweenDistance` +- Refactored tween extensions to not use closures to reduce GC allocations + - Source objects are now cached in the tween and passed to the getter/setter functions +- Changed property name casing to match C# conventions +- Renamed `Transform.TweenScale` to `Transform.TweenLocalScale` +- Renamed `Shadow.TweenEffectColor` to `Shadow.TweenColor` +- Renamed `Shadow.TweenEffectDistance` to `Shadow.TweenDistance` + +### Fixed + +- Fixed tweens not updating when the duration is set to zero +- Fixed interpolation snapping to round to the nearest integer instead of always rounding down ## [2.6.1] - 2022/05/11 ### Fixed -- Prevented errors caused when tweens are created while the game or scene is unloading +- Prevented errors when tweens are created while the game or scene is unloading ### Changed diff --git a/package.json b/package.json index 357fdc2..f7ce72a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.zigurous.tweening", - "version": "2.6.2", + "version": "3.0.0", "displayName": "Tweening", "description": "The Tweening package provides a system for tweening object properties in Unity. A tween is an animation of a value from a start position to an end position using an easing function, providing a natural sense of motion.\n\nThe system is lightweight, optimized, type-safe, and memory efficient. Hundreds of predefined tweening functions can be called on many common Unity classes, or you can animate anything using generic tweening functions. Tweens can be controlled with many different control methods and various callback functions.", "unity": "2019.4", From 240a2b9ab9580b4f67f1f2d5bd5e612e2062e117 Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Sat, 21 Oct 2023 20:35:28 -0500 Subject: [PATCH 14/19] Update workflow to use template --- .github/workflows/generate_docs.yml | 96 +++-------------------------- 1 file changed, 10 insertions(+), 86 deletions(-) diff --git a/.github/workflows/generate_docs.yml b/.github/workflows/generate_docs.yml index 6300c96..1b808cb 100644 --- a/.github/workflows/generate_docs.yml +++ b/.github/workflows/generate_docs.yml @@ -10,90 +10,14 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - BASE_PATH: com.zigurous.tweening - PACKAGE_TITLE: "Tweening System" - jobs: - build: - name: Build - runs-on: windows-latest - steps: - - name: Checkout package - uses: actions/checkout@v3 - with: - token: ${{ secrets.DOCS_TOKEN }} - - - name: Checkout docs template - uses: actions/checkout@v3 - with: - repository: zigurous/docs-template - ref: unity-package - token: ${{ secrets.DOCS_TOKEN }} - path: docs~ - - - name: Setup dotnet - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.x - - - name: Setup docfx - uses: crazy-max/ghaction-chocolatey@v1 - with: - args: install docfx - - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 14 - cache: yarn - cache-dependency-path: docs~/yarn.lock - - - name: Install dependencies - working-directory: docs~ - run: yarn install - env: - NPM_TOKEN: ${{ secrets.DOCS_TOKEN }} - - - name: Generate documentation - working-directory: docs~ - run: yarn generate $env:BASE_PATH $env:PACKAGE_TITLE - env: - NPM_TOKEN: ${{ secrets.DOCS_TOKEN }} - - - name: Build docs - working-directory: docs~ - continue-on-error: false - run: yarn build - env: - NPM_TOKEN: ${{ secrets.DOCS_TOKEN }} - - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: docs - path: docs~/public - - publish: - name: Publish - needs: build - runs-on: windows-latest - steps: - - name: Dispatch workflow - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.DOCS_TOKEN }} - script: | - await github.rest.actions.createWorkflowDispatch({ - owner: 'zigurous', - repo: 'docs', - ref: 'main', - workflow_id: 'publish_artifact.yml', - inputs: { - destination_path: process.env.BASE_PATH, - artifact_repo: process.env.GITHUB_REPOSITORY, - artifact_commit: process.env.GITHUB_SHA, - artifact_workflow: 'generate_docs.yml', - artifact_name: 'docs' - } - }) + generate: + name: Docs + uses: zigurous/docs/.github/workflows/unity-package.yml@main + with: + package_title: "Tweening System" + package_base_path: com.zigurous.tweening + package_workflow: generate-docs.yml + package_artifact: docs + secrets: + token: ${{ secrets.DOCS_TOKEN }} From d0b098f2df360feb208af71b35e5380ec72efa5e Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Sat, 21 Oct 2023 21:10:40 -0500 Subject: [PATCH 15/19] Rename workflow to generate-docs.yml --- .github/workflows/{generate_docs.yml => generate-docs.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{generate_docs.yml => generate-docs.yml} (100%) diff --git a/.github/workflows/generate_docs.yml b/.github/workflows/generate-docs.yml similarity index 100% rename from .github/workflows/generate_docs.yml rename to .github/workflows/generate-docs.yml From 64a5639f71371f48503a98e17de5a1b12cea63cb Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Sat, 21 Oct 2023 22:11:30 -0500 Subject: [PATCH 16/19] Update docs link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cb5e8e1..65b8c84 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The system is lightweight, optimized, type-safe, and memory efficient. Hundreds - [Tweens](https://docs.zigurous.com/com.zigurous.tweening/manual/tweens) - [Sequences](https://docs.zigurous.com/com.zigurous.tweening/manual/sequences) - [Easing](https://docs.zigurous.com/com.zigurous.tweening/manual/easing) -- [Callbacks](https://docs.zigurous.com/com.zigurous.tweening/manual/callbacks) +- [Events](https://docs.zigurous.com/com.zigurous.tweening/manual/events) - [Property Chaining](https://docs.zigurous.com/com.zigurous.tweening/manual/property-chaining) - [Managing Tweens](https://docs.zigurous.com/com.zigurous.tweening/manual/managing-tweens) - [Supported Types](https://docs.zigurous.com/com.zigurous.tweening/manual/supported-types) From d5bf3d95b62c866b5abff685d0d3da07d5af9b1b Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Sat, 21 Oct 2023 23:48:14 -0500 Subject: [PATCH 17/19] Set docs version number --- .github/workflows/generate-docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml index 1b808cb..2a685d1 100644 --- a/.github/workflows/generate-docs.yml +++ b/.github/workflows/generate-docs.yml @@ -3,7 +3,7 @@ name: Generate Docs on: push: branches: - - main + - release/3.0.0 workflow_dispatch: concurrency: @@ -16,7 +16,7 @@ jobs: uses: zigurous/docs/.github/workflows/unity-package.yml@main with: package_title: "Tweening System" - package_base_path: com.zigurous.tweening + package_base_path: com.zigurous.tweening@3.0.0 package_workflow: generate-docs.yml package_artifact: docs secrets: From 52c0d120ad719f05cf7654c87a9616537dc30f9b Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Sun, 22 Oct 2023 00:26:12 -0500 Subject: [PATCH 18/19] Update 3.0.0 release date --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2e53ed..d263e25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [3.0.0] - TBD +## [3.0.0] - 2023/10/22 ### Added From bc748276aa0360f9553a7d169d04bc2fa83fa5cb Mon Sep 17 00:00:00 2001 From: Adam Graham Date: Thu, 9 Nov 2023 10:47:23 -0600 Subject: [PATCH 19/19] Fix broken docs links --- Documentation~/articles/tweens.md | 4 ++-- Documentation~/filterconfig.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation~/articles/tweens.md b/Documentation~/articles/tweens.md index c7414f7..107fa72 100644 --- a/Documentation~/articles/tweens.md +++ b/Documentation~/articles/tweens.md @@ -6,7 +6,7 @@ slug: "/manual/tweens" A tween is an animation of a value from a start position to an end position using an easing function, providing a natural sense of motion. The **Tweening** package provides two main types of tweens, both of which inherit from the base class [Tween](/api/Zigurous.Tweening/Tween). -- [Tweener](/api/Zigurous.Tweening/Tweener-1) +- [Tweener](/api/Zigurous.Tweening/Tweener-2) - [Sequence](/api/Zigurous.Tweening/Sequence)
@@ -58,7 +58,7 @@ tween.autoStart = true; // starts the tween automatically after being initialize tween.autoKill = true; // kills the tween automatically after completing ``` -There are also [callback functions](/manual/callbacks) that can be set on any tween.
+There are also [callback functions](/manual/events) that can be set on any tween.
All of these properties can be set with [property chaining](/manual/property-chaining) methods.
diff --git a/Documentation~/filterconfig.yml b/Documentation~/filterconfig.yml index ed45165..6f28c45 100644 --- a/Documentation~/filterconfig.yml +++ b/Documentation~/filterconfig.yml @@ -16,10 +16,10 @@ apiRules: - exclude: uidRegex: ^Zigurous.Tweening.Tween.On* - exclude: - uidRegex: ^Zigurous.Tweening.Tweener`1.Animate + uidRegex: ^Zigurous.Tweening.Tweener`2.Animate - exclude: - uidRegex: ^Zigurous.Tweening.Tweener`1.IsFinished + uidRegex: ^Zigurous.Tweening.Tweener`2.IsFinished - exclude: - uidRegex: ^Zigurous.Tweening.Tweener`1.On* + uidRegex: ^Zigurous.Tweening.Tweener`2.On* - exclude: uidRegex: ^Zigurous.Tweening.*.Tweens