Skip to content

Commit

Permalink
feat(Button): Add action buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jul 30, 2023
1 parent ee8102a commit c2c463f
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 10 deletions.
54 changes: 54 additions & 0 deletions Assets/JCSUnity/Scripts/UI/Button/System/JCS_ActionButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* $File: JCS_ActionButton.cs $
* $Date: 2023-07-29 12:05:00 $
* $Revision: $
* $Creator: Jen-Chieh Shen $
* $Notice: See LICENSE.txt for modification and distribution information
* Copyright (c) 2023 by Shen, Jen-Chieh $
*/
using UnityEngine;
using UnityEngine.Events;
using MyBox;

namespace JCSUnity
{
/// <summary>
/// Button that accept any event.
/// </summary>
public class JCS_ActionButton : JCS_Button
{
/* Variables */

protected EmptyFunction onAction = null;

[Separator("Runtime Variables (JCS_ActionButton)")]

[Tooltip("Execute this when it's triggered.")]
[SerializeField]
protected UnityEvent mOnAction = null;

/* Setter & Getter */

/* Functions */

/// <summary>
/// On click event.
/// </summary>
public override void OnClick()
{
Execute();
}

/// <summary>
/// Execute the action.
/// </summary>
public void Execute()
{
if (onAction != null)
onAction.Invoke();

if (mOnAction != null)
mOnAction.Invoke();
}
}
}
11 changes: 11 additions & 0 deletions Assets/JCSUnity/Scripts/UI/Button/System/JCS_ActionButton.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* $File: JCS_ActionGamePadButton.cs $
* $Date: 2023-07-29 12:05:00 $
* $Revision: $
* $Creator: Jen-Chieh Shen $
* $Notice: See LICENSE.txt for modification and distribution information
* Copyright (c) 2023 by Shen, Jen-Chieh $
*/
using UnityEngine;
using UnityEngine.Events;
using MyBox;

namespace JCSUnity
{
/// <summary>
/// Button that accept any event. (Gamepad)
/// </summary>
public class JCS_ActionGamePadButton : JCS_GamepadButton
{
/* Variables */

protected EmptyFunction onAction = null;

[Separator("Runtime Variables (JCS_ActionGamePadButton)")]

[Tooltip("Execute this when it's triggered.")]
[SerializeField]
protected UnityEvent mOnAction = null;

/* Setter & Getter */

/* Functions */

/// <summary>
/// On click event.
/// </summary>
public override void OnClick()
{
Execute();
}

/// <summary>
/// Execute the action.
/// </summary>
public void Execute()
{
if (onAction != null)
onAction.Invoke();

if (mOnAction != null)
mOnAction.Invoke();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions Assets/_Project/Scenes/UI/FT_TextSlider.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1}
m_IndirectSpecularColor: {r: 0.3708985, g: 0.3783704, b: 0.35722548, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down Expand Up @@ -67,9 +67,6 @@ LightmapSettings:
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
Expand Down Expand Up @@ -275,6 +272,7 @@ Canvas:
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 0
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# JCS_ExitAppGamepadButton

Please see [JCS_ExitAppButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_Scene_sl_JCS_ExitAppGamePadButton)
Please see [JCS_ExitAppButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_Scene_sl_JCS_ExitAppGamePadButton).
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# JCS_LoadSceneGamepadButton

Please see [JCS_LoadSceneButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_Scene_sl_JCS_LoadSceneButton)
Please see [JCS_LoadSceneButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_Scene_sl_JCS_LoadSceneButton).
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# JCS_SlideScreenGamepadButton

Please see [JCS_SlideScreenButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_JCS_SlideScreenButton)
Please see [JCS_SlideScreenButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_Scene_sl_JCS_SlideScreenButton).
16 changes: 16 additions & 0 deletions docs/ScriptReference/UI/Button/System/JCS_ActionButton.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# JCS_ActionButton

Echo out a string on the console window when this button triggered.

## Variables

| Name | Description |
|:----------|:----------------------------------|
| onAction | Callback when it's triggered. |
| mOnAction | Execute this when it's triggered. |

## Functions

| Name | Description |
|:--------|:--------------------|
| Execute | Execute the action. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# JCS_ActionGamePadButton

Please see [JCS_ActionButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_System_sl_JCS_ActionButton).
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# JCS_EchoGamepadButton

Please see [JCS_EchoButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_System_sl_JCS_EchoButton)
Please see [JCS_EchoButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_System_sl_JCS_EchoButton).
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# JCS_EmptyGamepadButton

Please see [JCS_EmptyButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_System_sl_JCS_EmptyButton)
Please see [JCS_EmptyButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_System_sl_JCS_EmptyButton).
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# JCS_ToggleGamepadButton

Please see [JCS_ToggleButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_System_sl_JCS_ToggleButton)
Please see [JCS_ToggleButton](https://jcs090218.github.io/JCSUnity/ScriptReference/index.html?page=UI_sl_Button_sl_System_sl_JCS_ToggleButton).

0 comments on commit c2c463f

Please sign in to comment.