modify
This commit is contained in:
parent
1956de3bda
commit
8f86cc528f
@ -1,27 +0,0 @@
|
|||||||
namespace AlicizaX.UI.Extension.Editor
|
|
||||||
{
|
|
||||||
using AlicizaX.UI.Extension;
|
|
||||||
using UnityEditor;
|
|
||||||
using UnityEditor.UI;
|
|
||||||
|
|
||||||
[CustomEditor(typeof(UIButtonSuper), true)]
|
|
||||||
[CanEditMultipleObjects]
|
|
||||||
public class UIButtonSuperEditor : ButtonEditor
|
|
||||||
{
|
|
||||||
private SerializedProperty m_ButtonUISounds;
|
|
||||||
|
|
||||||
protected override void OnEnable()
|
|
||||||
{
|
|
||||||
base.OnEnable();
|
|
||||||
m_ButtonUISounds = serializedObject.FindProperty("m_ButtonUISounds");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnInspectorGUI()
|
|
||||||
{
|
|
||||||
base.OnInspectorGUI();
|
|
||||||
serializedObject.Update();
|
|
||||||
EditorGUILayout.PropertyField(m_ButtonUISounds); //显示我们创建的属性
|
|
||||||
serializedObject.ApplyModifiedProperties();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: f9c7e374daba4ee8a1092a930327fa2f
|
|
||||||
timeCreated: 1740102365
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 6959ce6dfcdb41dbb548a7472f65626a
|
|
||||||
timeCreated: 1740102262
|
|
@ -1,85 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.EventSystems;
|
|
||||||
using System;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
using AudioType = AlicizaX.Audio.Runtime.AudioType;
|
|
||||||
|
|
||||||
namespace AlicizaX.UI.Extension
|
|
||||||
{
|
|
||||||
public enum ButtonSoundType
|
|
||||||
{
|
|
||||||
Down,
|
|
||||||
Up,
|
|
||||||
Click,
|
|
||||||
Enter,
|
|
||||||
Exit
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class ButtonSoundCell
|
|
||||||
{
|
|
||||||
public ButtonSoundType ButtonSoundType = ButtonSoundType.Click;
|
|
||||||
public string ButtonUISoundName = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public class UIButtonSuper : Button,IButton
|
|
||||||
{
|
|
||||||
public List<ButtonSoundCell> m_ButtonUISounds = new List<ButtonSoundCell>();
|
|
||||||
|
|
||||||
public ButtonSoundCell GetButtonSound(ButtonSoundType buttonSoundType)
|
|
||||||
{
|
|
||||||
foreach (var buttonSound in m_ButtonUISounds)
|
|
||||||
{
|
|
||||||
if (buttonSound.ButtonSoundType == buttonSoundType)
|
|
||||||
{
|
|
||||||
return buttonSound;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PlayButtonSound(ButtonSoundType buttonSoundType)
|
|
||||||
{
|
|
||||||
ButtonSoundCell buttonSound = GetButtonSound(buttonSoundType);
|
|
||||||
if (buttonSound == null || string.IsNullOrEmpty(buttonSound.ButtonUISoundName))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameApp.Audio.Play(AudioType.UISound, buttonSound.ButtonUISoundName, false, GameApp.Audio.UISoundVolume, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnPointerEnter(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
base.OnPointerEnter(eventData);
|
|
||||||
PlayButtonSound(ButtonSoundType.Enter);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnPointerDown(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
base.OnPointerDown(eventData);
|
|
||||||
PlayButtonSound(ButtonSoundType.Down);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnPointerUp(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
base.OnPointerUp(eventData);
|
|
||||||
PlayButtonSound(ButtonSoundType.Up);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnPointerExit(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
base.OnPointerExit(eventData);
|
|
||||||
PlayButtonSound(ButtonSoundType.Exit);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnPointerClick(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
base.OnPointerClick(eventData);
|
|
||||||
PlayButtonSound(ButtonSoundType.Click);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: fa4f44179d534f148b96822ead9e9b8f
|
|
||||||
timeCreated: 1673928618
|
|
@ -16,6 +16,23 @@ public enum ButtonModeType
|
|||||||
Toggle
|
Toggle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ButtonSoundType
|
||||||
|
{
|
||||||
|
Down,
|
||||||
|
Up,
|
||||||
|
Click,
|
||||||
|
Enter,
|
||||||
|
Exit
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class ButtonSoundCell
|
||||||
|
{
|
||||||
|
public ButtonSoundType ButtonSoundType = ButtonSoundType.Click;
|
||||||
|
public string ButtonUISoundName = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class TransitionData
|
public class TransitionData
|
||||||
{
|
{
|
||||||
@ -35,29 +52,13 @@ public struct ButtonSoundData
|
|||||||
|
|
||||||
internal enum SelectionState
|
internal enum SelectionState
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The UI object can be selected.
|
|
||||||
/// </summary>
|
|
||||||
Normal,
|
Normal,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The UI object is highlighted.
|
|
||||||
/// </summary>
|
|
||||||
Highlighted,
|
Highlighted,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The UI object is pressed.
|
|
||||||
/// </summary>
|
|
||||||
Pressed,
|
Pressed,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The UI object is selected
|
|
||||||
/// </summary>
|
|
||||||
Selected,
|
Selected,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The UI object cannot be selected.
|
|
||||||
/// </summary>
|
|
||||||
Disabled,
|
Disabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user