Skip to content

Commit c2c463f

Browse files
committed
feat(Button): Add action buttons
1 parent ee8102a commit c2c463f

13 files changed

+157
-10
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* $File: JCS_ActionButton.cs $
3+
* $Date: 2023-07-29 12:05:00 $
4+
* $Revision: $
5+
* $Creator: Jen-Chieh Shen $
6+
* $Notice: See LICENSE.txt for modification and distribution information
7+
* Copyright (c) 2023 by Shen, Jen-Chieh $
8+
*/
9+
using UnityEngine;
10+
using UnityEngine.Events;
11+
using MyBox;
12+
13+
namespace JCSUnity
14+
{
15+
/// <summary>
16+
/// Button that accept any event.
17+
/// </summary>
18+
public class JCS_ActionButton : JCS_Button
19+
{
20+
/* Variables */
21+
22+
protected EmptyFunction onAction = null;
23+
24+
[Separator("Runtime Variables (JCS_ActionButton)")]
25+
26+
[Tooltip("Execute this when it's triggered.")]
27+
[SerializeField]
28+
protected UnityEvent mOnAction = null;
29+
30+
/* Setter & Getter */
31+
32+
/* Functions */
33+
34+
/// <summary>
35+
/// On click event.
36+
/// </summary>
37+
public override void OnClick()
38+
{
39+
Execute();
40+
}
41+
42+
/// <summary>
43+
/// Execute the action.
44+
/// </summary>
45+
public void Execute()
46+
{
47+
if (onAction != null)
48+
onAction.Invoke();
49+
50+
if (mOnAction != null)
51+
mOnAction.Invoke();
52+
}
53+
}
54+
}

Assets/JCSUnity/Scripts/UI/Button/System/JCS_ActionButton.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* $File: JCS_ActionGamePadButton.cs $
3+
* $Date: 2023-07-29 12:05:00 $
4+
* $Revision: $
5+
* $Creator: Jen-Chieh Shen $
6+
* $Notice: See LICENSE.txt for modification and distribution information
7+
* Copyright (c) 2023 by Shen, Jen-Chieh $
8+
*/
9+
using UnityEngine;
10+
using UnityEngine.Events;
11+
using MyBox;
12+
13+
namespace JCSUnity
14+
{
15+
/// <summary>
16+
/// Button that accept any event. (Gamepad)
17+
/// </summary>
18+
public class JCS_ActionGamePadButton : JCS_GamepadButton
19+
{
20+
/* Variables */
21+
22+
protected EmptyFunction onAction = null;
23+
24+
[Separator("Runtime Variables (JCS_ActionGamePadButton)")]
25+
26+
[Tooltip("Execute this when it's triggered.")]
27+
[SerializeField]
28+
protected UnityEvent mOnAction = null;
29+
30+
/* Setter & Getter */
31+
32+
/* Functions */
33+
34+
/// <summary>
35+
/// On click event.
36+
/// </summary>
37+
public override void OnClick()
38+
{
39+
Execute();
40+
}
41+
42+
/// <summary>
43+
/// Execute the action.
44+
/// </summary>
45+
public void Execute()
46+
{
47+
if (onAction != null)
48+
onAction.Invoke();
49+
50+
if (mOnAction != null)
51+
mOnAction.Invoke();
52+
}
53+
}
54+
}

Assets/JCSUnity/Scripts/UI/Button/System/JCS_ActionGamePadButton.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/_Project/Scenes/UI/FT_TextSlider.unity

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RenderSettings:
3838
m_ReflectionIntensity: 1
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 0}
41-
m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1}
41+
m_IndirectSpecularColor: {r: 0.3708985, g: 0.3783704, b: 0.35722548, a: 1}
4242
m_UseRadianceAmbientProbe: 0
4343
--- !u!157 &3
4444
LightmapSettings:
@@ -67,9 +67,6 @@ LightmapSettings:
6767
m_LightmapParameters: {fileID: 0}
6868
m_LightmapsBakeMode: 1
6969
m_TextureCompression: 1
70-
m_FinalGather: 0
71-
m_FinalGatherFiltering: 1
72-
m_FinalGatherRayCount: 256
7370
m_ReflectionCompression: 2
7471
m_MixedBakeMode: 2
7572
m_BakeBackend: 1
@@ -275,6 +272,7 @@ Canvas:
275272
m_OverrideSorting: 0
276273
m_OverridePixelPerfect: 0
277274
m_SortingBucketNormalizedSize: 0
275+
m_VertexColorAlwaysGammaSpace: 0
278276
m_AdditionalShaderChannelsFlag: 0
279277
m_UpdateRectTransformForStandalone: 0
280278
m_SortingLayerID: 0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# JCS_ExitAppGamepadButton
22

3-
Please see [JCS_ExitAppButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_Scene_sl_JCS_ExitAppGamePadButton)
3+
Please see [JCS_ExitAppButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_Scene_sl_JCS_ExitAppGamePadButton).
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# JCS_LoadSceneGamepadButton
22

3-
Please see [JCS_LoadSceneButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_Scene_sl_JCS_LoadSceneButton)
3+
Please see [JCS_LoadSceneButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_Scene_sl_JCS_LoadSceneButton).
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# JCS_SlideScreenGamepadButton
22

3-
Please see [JCS_SlideScreenButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_JCS_SlideScreenButton)
3+
Please see [JCS_SlideScreenButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_Scene_sl_JCS_SlideScreenButton).
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# JCS_ActionButton
2+
3+
Echo out a string on the console window when this button triggered.
4+
5+
## Variables
6+
7+
| Name | Description |
8+
|:----------|:----------------------------------|
9+
| onAction | Callback when it's triggered. |
10+
| mOnAction | Execute this when it's triggered. |
11+
12+
## Functions
13+
14+
| Name | Description |
15+
|:--------|:--------------------|
16+
| Execute | Execute the action. |
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# JCS_ActionGamePadButton
2+
3+
Please see [JCS_ActionButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_System_sl_JCS_ActionButton).

0 commit comments

Comments
 (0)