Added Slider SFX

This commit is contained in:
maverickdgg 2023-03-31 14:18:09 +08:00
parent b123cd83f8
commit 6ee619d26e
3 changed files with 93 additions and 4 deletions

View File

@ -770,7 +770,11 @@
Hovered: false Hovered: false
Clicked: false Clicked: false
IsActive: true IsActive: true
Scripts: ~ Scripts:
- Type: SHADE_Scripting.UI.SliderFX
Enabled: true
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
- EID: 437 - EID: 437
Name: Slider BG Name: Slider BG
IsActive: true IsActive: true
@ -815,7 +819,11 @@
Hovered: false Hovered: false
Clicked: false Clicked: false
IsActive: true IsActive: true
Scripts: ~ Scripts:
- Type: SHADE_Scripting.UI.SliderFX
Enabled: true
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
- EID: 436 - EID: 436
Name: Slider BG Name: Slider BG
IsActive: true IsActive: true
@ -860,7 +868,11 @@
Hovered: false Hovered: false
Clicked: false Clicked: false
IsActive: true IsActive: true
Scripts: ~ Scripts:
- Type: SHADE_Scripting.UI.SliderFX
Enabled: true
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
- EID: 435 - EID: 435
Name: Slider BG Name: Slider BG
IsActive: true IsActive: true
@ -1025,7 +1037,11 @@
Hovered: false Hovered: false
Clicked: false Clicked: false
IsActive: true IsActive: true
Scripts: ~ Scripts:
- Type: SHADE_Scripting.UI.SliderFX
Enabled: true
onClickSound: event:/UI/button_success
onReleaseSound: event:/UI/button_fail
- EID: 434 - EID: 434
Name: Slider BG Name: Slider BG
IsActive: true IsActive: true

View File

@ -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<Transform>();
if (transform == null)
return;
UIElement ui = GetComponent<UIElement>();
if (ui == null)
return;
ui.OnClick.RegisterAction(() =>
{
if (onClickSound != "Empty")
onClickACHandler.Play();
});
ui.OnRelease.RegisterAction(() =>
{
if (onReleaseSound != "Empty")
onReleaseACHandler.Play();
});
}
protected override void update()
{
}
}
}

View File

@ -0,0 +1,3 @@
Name: SC_SliderFX
ID: 157251414
Type: 9