diff --git a/Assets/Scenes/MainMenu.shade b/Assets/Scenes/MainMenu.shade index 7e624cd3..d3ddd940 100644 --- a/Assets/Scenes/MainMenu.shade +++ b/Assets/Scenes/MainMenu.shade @@ -770,7 +770,11 @@ Hovered: false Clicked: false IsActive: true - Scripts: ~ + Scripts: + - Type: SHADE_Scripting.UI.SliderFX + Enabled: true + onClickSound: event:/UI/button_success + onReleaseSound: event:/UI/button_fail - EID: 437 Name: Slider BG IsActive: true @@ -815,7 +819,11 @@ Hovered: false Clicked: false IsActive: true - Scripts: ~ + Scripts: + - Type: SHADE_Scripting.UI.SliderFX + Enabled: true + onClickSound: event:/UI/button_success + onReleaseSound: event:/UI/button_fail - EID: 436 Name: Slider BG IsActive: true @@ -860,7 +868,11 @@ Hovered: false Clicked: false IsActive: true - Scripts: ~ + Scripts: + - Type: SHADE_Scripting.UI.SliderFX + Enabled: true + onClickSound: event:/UI/button_success + onReleaseSound: event:/UI/button_fail - EID: 435 Name: Slider BG IsActive: true @@ -1025,7 +1037,11 @@ Hovered: false Clicked: false IsActive: true - Scripts: ~ + Scripts: + - Type: SHADE_Scripting.UI.SliderFX + Enabled: true + onClickSound: event:/UI/button_success + onReleaseSound: event:/UI/button_fail - EID: 434 Name: Slider BG IsActive: true diff --git a/Assets/Scripts/UI/SC_SliderFX.cs b/Assets/Scripts/UI/SC_SliderFX.cs new file mode 100644 index 00000000..f2c20dcd --- /dev/null +++ b/Assets/Scripts/UI/SC_SliderFX.cs @@ -0,0 +1,70 @@ +using SHADE; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SHADE_Scripting.UI +{ + public class SliderFX : Script + { + + public string onClickSound = "event:/UI/button_success"; + public string onReleaseSound = "event:/UI/button_fail"; + + + [NonSerialized] + private AudioClipHandler onClickACHandler; + [NonSerialized] + private AudioClipHandler onReleaseACHandler; + + + + protected override void awake() + { + + + if (onClickSound != "Empty") + onClickACHandler = SHADE.Audio.CreateAudioClip(onClickSound); + if (onReleaseSound != "Empty") + onReleaseACHandler = SHADE.Audio.CreateAudioClip(onReleaseSound); + } + + protected override void start() + { + + + Transform transform = GetComponent(); + if (transform == null) + return; + + UIElement ui = GetComponent(); + if (ui == null) + return; + + + ui.OnClick.RegisterAction(() => + { + if (onClickSound != "Empty") + onClickACHandler.Play(); + + }); + + ui.OnRelease.RegisterAction(() => + { + if (onReleaseSound != "Empty") + onReleaseACHandler.Play(); + + }); + + } + + protected override void update() + { + + } + + + } +} diff --git a/Assets/Scripts/UI/SC_SliderFX.cs.shmeta b/Assets/Scripts/UI/SC_SliderFX.cs.shmeta new file mode 100644 index 00000000..fdb814d0 --- /dev/null +++ b/Assets/Scripts/UI/SC_SliderFX.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_SliderFX +ID: 157251414 +Type: 9