Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6d242d4

Browse files
Add callback function.
1 parent a0a9ad6 commit 6d242d4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎Assets/Scripts/JCS_Toggle.cs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
namespace JCSUnity
1515
{
16+
public delegate void ToggleOnCallback();
17+
public delegate void ToggleOffCallback();
18+
1619
/// <summary>
1720
/// Better version of checkbox/toggle GUI.
1821
/// </summary>
@@ -25,6 +28,9 @@ public class JCS_Toggle
2528
/* Public Variables */
2629
/*******************************************/
2730

31+
public ToggleOnCallback toggleOnCallback = null;
32+
public ToggleOffCallback toggleOffCallback = null;
33+
2834
/*******************************************/
2935
/* Private Variables */
3036
/*******************************************/
@@ -260,12 +266,18 @@ private void DoToggle(bool act)
260266
mToggleSign.TransformTweener.DoTween(mOnPos);
261267
mToggleSign.ColorTweener.DoTween(mOnButtonColor);
262268
mColorTweener.DoTween(mOnBackgroundColor);
269+
270+
if (toggleOnCallback != null)
271+
toggleOnCallback.Invoke();
263272
}
264273
else
265274
{
266275
mToggleSign.TransformTweener.DoTween(mOffPos);
267276
mToggleSign.ColorTweener.DoTween(mOffButtonColor);
268277
mColorTweener.DoTween(mOffBackgroundColor);
278+
279+
if (toggleOffCallback != null)
280+
toggleOffCallback.Invoke();
269281
}
270282
}
271283

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /