71 lines
1.3 KiB
C#
71 lines
1.3 KiB
C#
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()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|