Skip to content

Commit dff76bc

Browse files
committed
feat(Effect): Add more hooks for tweeners
1 parent 782e626 commit dff76bc

File tree

5 files changed

+61
-45
lines changed

5 files changed

+61
-45
lines changed

Assets/JCSUnity/Scripts/Effects/Tweener/JCS_ColorTweener.cs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,16 @@ public class JCS_ColorTweener : JCS_UnityObject
2525
private TweenDelegate mEasingBlue = null;
2626
private TweenDelegate mEasingAlpha = null;
2727

28-
private Action mColorCallback = null;
28+
29+
// Callback to execute when start tweening.
30+
public Action onStart = null;
31+
32+
// Callback to execute when done tweening.
33+
public Action onDone = null;
34+
35+
// Callback to execute when done tweening but only with that
36+
// specific function call.
37+
private Action mOnDone = null;
2938

3039
/**
3140
* time to calculate the progress.
@@ -222,10 +231,6 @@ public JCS_TweenType EaseTypeA
222231
public bool IgnoreG { get { return this.mIgnoreG; } set { this.mIgnoreG = value; } }
223232
public bool IgnoreB { get { return this.mIgnoreB; } set { this.mIgnoreB = value; } }
224233
public bool IgnoreA { get { return this.mIgnoreA; } set { this.mIgnoreA = value; } }
225-
public void SetCallback(Action func)
226-
{
227-
this.mColorCallback = func;
228-
}
229234

230235
/* Functions */
231236

@@ -354,6 +359,8 @@ public void DoTween(
354359
float inDurationA,
355360
Action func = null)
356361
{
362+
onStart?.Invoke();
363+
357364
this.mFromColor = inFromColor;
358365
this.mTargetColor = inToColor;
359366

@@ -372,7 +379,7 @@ public void DoTween(
372379
this.mEasingB = true;
373380
this.mEasingA = true;
374381

375-
SetCallback(func);
382+
mOnDone = func;
376383
}
377384

378385
/// <summary>
@@ -524,13 +531,11 @@ private void CheckDoneEasing()
524531
if (mEasingA || mEasingR || mEasingG || mEasingB)
525532
return;
526533

527-
// trigger callback.
528-
if (mColorCallback != null)
529-
mColorCallback.Invoke();
534+
mOnDone?.Invoke();
535+
536+
mUnityCallback?.Invoke();
530537

531-
// trigger unity callback.
532-
if (mUnityCallback != null)
533-
mUnityCallback.Invoke();
538+
onDone?.Invoke();
534539
}
535540

536541
/// <summary>

Assets/JCSUnity/Scripts/Effects/Tweener/JCS_FloatTweener.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ public class JCS_FloatTweener : MonoBehaviour
2828
public SetFloat onValueChange = null;
2929
public GetFloat onValueReturn = null;
3030

31-
private Action mValueCallback = null;
31+
// Callback to execute when start tweening.
32+
public Action onStart = null;
33+
34+
// Callback to execute when done tweening.
35+
public Action onDone = null;
36+
37+
// Callback to execute when done tweening but only with that
38+
// specific function call.
39+
private Action mOnDone = null;
3240

3341
private TweenDelegate mEasingFunc = null;
3442

@@ -215,13 +223,11 @@ private bool CheckValid()
215223
/// </summary>
216224
private void DoDoneEasing()
217225
{
218-
// trigger callback.
219-
if (mValueCallback != null)
220-
mValueCallback.Invoke();
226+
mOnDone?.Invoke();
227+
228+
mUnityCallback?.Invoke();
221229

222-
// trigger unity callback.
223-
if (mUnityCallback != null)
224-
mUnityCallback.Invoke();
230+
onDone?.Invoke();
225231
}
226232

227233
private void UpdateValue()

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1717
* feat(UI): Add new component `JCS_SelectLanguageButton` (f28c03b3ae45300b6e5742c6c0d953105486ea54)
1818
* feat(Audio): Replace the custom audio solution with the built-in mixer (c85e93f68167ebd27c36fa7c0aad2c4b07449081)
1919
* fix(Effect): Handle pause in 3D shake (ec394963cc6e06cf79b1fae085ab2536f4dec65e)
20+
* feat(Effect): Add more public hooks for transform tweener (782e62652e9d3f99bd0a09d49af0032dc9eead55)
2021

2122
## 3.1.0
2223
> Released Apr 11, 2025

docs/ScriptReference/Effects/Tweener/JCS_ColorTweener.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@ Color tweener.
44

55
## Variables
66

7-
| Name | Description |
8-
|:---------------|:----------------------------------------|
9-
| mTimeType | Type of the delta time. |
10-
| mEaseTypeR | Tween type for red channel. |
11-
| mEaseTypeG | Tween type for green channel. |
12-
| mEaseTypeB | Tween type for blue channel. |
13-
| mEaseTypeA | Tween type for alpha channel. |
14-
| mDurationRed | How fast it changes the red channel." |
15-
| mDurationGreen | How fast it changes the green channel." |
16-
| mDurationBlue | How fast it changes the blue channel." |
17-
| mDurationAlpha | How fast it changes the alpha channel." |
18-
| mIgnoreR | Do not do anything with red channel. |
19-
| mIgnoreG | Do not do anything with green channel. |
20-
| mIgnoreB | Do not do anything with blue channel. |
21-
| mIgnoreA | Do not do anything with alpha channel. |
22-
| mUnityCallback | Callback after easing. |
7+
| Name | Description |
8+
|:---------------|:-----------------------------------------|
9+
| onStart | Callback to execute when start tweening. |
10+
| onDone | Callback to execute when done tweening. |
11+
| mTimeType | Type of the delta time. |
12+
| mEaseTypeR | Tween type for red channel. |
13+
| mEaseTypeG | Tween type for green channel. |
14+
| mEaseTypeB | Tween type for blue channel. |
15+
| mEaseTypeA | Tween type for alpha channel. |
16+
| mDurationRed | How fast it changes the red channel. |
17+
| mDurationGreen | How fast it changes the green channel. |
18+
| mDurationBlue | How fast it changes the blue channel. |
19+
| mDurationAlpha | How fast it changes the alpha channel. |
20+
| mIgnoreR | Do not do anything with red channel. |
21+
| mIgnoreG | Do not do anything with green channel. |
22+
| mIgnoreB | Do not do anything with blue channel. |
23+
| mIgnoreA | Do not do anything with alpha channel. |
24+
| mUnityCallback | Callback after easing. |
2325

2426
## Functions
2527

docs/ScriptReference/Effects/Tweener/JCS_FloatTweener.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ Can only use for `float`.
66

77
## Variables
88

9-
| Name | Description |
10-
|:---------------|:---------------------------------|
11-
| onValueChange | Callback that updates the value. |
12-
| onValueReturn | Callback that get the value. |
13-
| Tween | Do the tween effect? |
14-
| Value offset. | ValueOffset |
15-
| Duration | How fast it moves on value. |
16-
| mTimeType | Type of the delta time. |
17-
| Easing | Tweener formula on value. |
18-
| UnityCallback | Callback after easing. |
9+
| Name | Description |
10+
|:---------------|:-----------------------------------------|
11+
| onStart | Callback to execute when start tweening. |
12+
| onDone | Callback to execute when done tweening. |
13+
| onValueChange | Callback that updates the value. |
14+
| onValueReturn | Callback that get the value. |
15+
| Tween | Do the tween effect? |
16+
| Value offset. | ValueOffset |
17+
| Duration | How fast it moves on value. |
18+
| mTimeType | Type of the delta time. |
19+
| Easing | Tweener formula on value. |
20+
| UnityCallback | Callback after easing. |
1921

2022
## Functions
2123

0 commit comments

Comments
 (0)