feat: mute music button
This commit is contained in:
parent
fa45a83124
commit
08162191c8
@ -19,6 +19,18 @@ AudioMixerGroupController:
|
|||||||
m_Mute: 0
|
m_Mute: 0
|
||||||
m_Solo: 0
|
m_Solo: 0
|
||||||
m_BypassEffects: 0
|
m_BypassEffects: 0
|
||||||
|
--- !u!245 &-1355774588778556265
|
||||||
|
AudioMixerSnapshotController:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Mute
|
||||||
|
m_AudioMixer: {fileID: 24100000}
|
||||||
|
m_SnapshotID: c62c2c8de17c3ae408be156383a52057
|
||||||
|
m_FloatValues:
|
||||||
|
526d9581d6f68479082360ed52a3573d: -80
|
||||||
|
m_TransitionOverrides: {}
|
||||||
--- !u!241 &24100000
|
--- !u!241 &24100000
|
||||||
AudioMixerController:
|
AudioMixerController:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -30,6 +42,7 @@ AudioMixerController:
|
|||||||
m_MasterGroup: {fileID: 24300002}
|
m_MasterGroup: {fileID: 24300002}
|
||||||
m_Snapshots:
|
m_Snapshots:
|
||||||
- {fileID: 24500006}
|
- {fileID: 24500006}
|
||||||
|
- {fileID: -1355774588778556265}
|
||||||
m_StartSnapshot: {fileID: 24500006}
|
m_StartSnapshot: {fileID: 24500006}
|
||||||
m_SuspendThreshold: -80
|
m_SuspendThreshold: -80
|
||||||
m_EnableSuspend: 1
|
m_EnableSuspend: 1
|
||||||
@ -84,7 +97,7 @@ AudioMixerSnapshotController:
|
|||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name: Snapshot
|
m_Name: Default
|
||||||
m_AudioMixer: {fileID: 24100000}
|
m_AudioMixer: {fileID: 24100000}
|
||||||
m_SnapshotID: c416757bd7a954c1ba54bd6ca634b0f1
|
m_SnapshotID: c416757bd7a954c1ba54bd6ca634b0f1
|
||||||
m_FloatValues: {}
|
m_FloatValues: {}
|
||||||
|
@ -1885,6 +1885,9 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: ccc6142918f2946509e0c02fbe0df427, type: 3}
|
m_Script: {fileID: 11500000, guid: ccc6142918f2946509e0c02fbe0df427, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
mixer: {fileID: 24100000, guid: 23695c8b913f2468f8e11226c7661601, type: 2}
|
||||||
|
defaultSnapshot: {fileID: 24500006, guid: 23695c8b913f2468f8e11226c7661601, type: 2}
|
||||||
|
muteSnapshot: {fileID: -1355774588778556265, guid: 23695c8b913f2468f8e11226c7661601, type: 2}
|
||||||
musicSource: {fileID: 1277491651}
|
musicSource: {fileID: 1277491651}
|
||||||
sfxSource: {fileID: 1937957483}
|
sfxSource: {fileID: 1937957483}
|
||||||
musics:
|
musics:
|
||||||
@ -2444,7 +2447,7 @@ GameObject:
|
|||||||
- component: {fileID: 593191227}
|
- component: {fileID: 593191227}
|
||||||
- component: {fileID: 593191226}
|
- component: {fileID: 593191226}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: VolumeButton
|
m_Name: MuteButton_ON
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
@ -2512,7 +2515,43 @@ MonoBehaviour:
|
|||||||
m_TargetGraphic: {fileID: 593191227}
|
m_TargetGraphic: {fileID: 593191227}
|
||||||
m_OnClick:
|
m_OnClick:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
m_Calls: []
|
m_Calls:
|
||||||
|
- m_Target: {fileID: 1503133438}
|
||||||
|
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
|
||||||
|
m_MethodName: SetActive
|
||||||
|
m_Mode: 6
|
||||||
|
m_Arguments:
|
||||||
|
m_ObjectArgument: {fileID: 0}
|
||||||
|
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||||
|
m_IntArgument: 0
|
||||||
|
m_FloatArgument: 0
|
||||||
|
m_StringArgument:
|
||||||
|
m_BoolArgument: 1
|
||||||
|
m_CallState: 2
|
||||||
|
- m_Target: {fileID: 375256415}
|
||||||
|
m_TargetAssemblyTypeName: AudioManager, Assembly-CSharp
|
||||||
|
m_MethodName: ToggleMute
|
||||||
|
m_Mode: 6
|
||||||
|
m_Arguments:
|
||||||
|
m_ObjectArgument: {fileID: 0}
|
||||||
|
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||||
|
m_IntArgument: 0
|
||||||
|
m_FloatArgument: 0
|
||||||
|
m_StringArgument:
|
||||||
|
m_BoolArgument: 1
|
||||||
|
m_CallState: 2
|
||||||
|
- m_Target: {fileID: 593191224}
|
||||||
|
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
|
||||||
|
m_MethodName: SetActive
|
||||||
|
m_Mode: 6
|
||||||
|
m_Arguments:
|
||||||
|
m_ObjectArgument: {fileID: 0}
|
||||||
|
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||||
|
m_IntArgument: 0
|
||||||
|
m_FloatArgument: 0
|
||||||
|
m_StringArgument:
|
||||||
|
m_BoolArgument: 0
|
||||||
|
m_CallState: 2
|
||||||
--- !u!114 &593191227
|
--- !u!114 &593191227
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -4958,6 +4997,7 @@ RectTransform:
|
|||||||
- {fileID: 6747543}
|
- {fileID: 6747543}
|
||||||
- {fileID: 220251970}
|
- {fileID: 220251970}
|
||||||
- {fileID: 593191225}
|
- {fileID: 593191225}
|
||||||
|
- {fileID: 1503133439}
|
||||||
m_Father: {fileID: 610087870}
|
m_Father: {fileID: 610087870}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
@ -6797,6 +6837,162 @@ MonoBehaviour:
|
|||||||
- Nyaaaa ~
|
- Nyaaaa ~
|
||||||
- Coded without JS (I think)
|
- Coded without JS (I think)
|
||||||
- I developed without counting
|
- I developed without counting
|
||||||
|
--- !u!1 &1503133438
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1503133439}
|
||||||
|
- component: {fileID: 1503133442}
|
||||||
|
- component: {fileID: 1503133441}
|
||||||
|
- component: {fileID: 1503133440}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: MuteButton_OFF
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 0
|
||||||
|
--- !u!224 &1503133439
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1503133438}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1117928115}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 1, y: 1}
|
||||||
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
|
m_AnchoredPosition: {x: -25, y: -25}
|
||||||
|
m_SizeDelta: {x: 120, y: 120}
|
||||||
|
m_Pivot: {x: 1, y: 1}
|
||||||
|
--- !u!114 &1503133440
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1503133438}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Navigation:
|
||||||
|
m_Mode: 3
|
||||||
|
m_WrapAround: 0
|
||||||
|
m_SelectOnUp: {fileID: 0}
|
||||||
|
m_SelectOnDown: {fileID: 0}
|
||||||
|
m_SelectOnLeft: {fileID: 0}
|
||||||
|
m_SelectOnRight: {fileID: 0}
|
||||||
|
m_Transition: 1
|
||||||
|
m_Colors:
|
||||||
|
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||||
|
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||||
|
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||||
|
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||||
|
m_ColorMultiplier: 1
|
||||||
|
m_FadeDuration: 0.1
|
||||||
|
m_SpriteState:
|
||||||
|
m_HighlightedSprite: {fileID: 0}
|
||||||
|
m_PressedSprite: {fileID: 0}
|
||||||
|
m_SelectedSprite: {fileID: 0}
|
||||||
|
m_DisabledSprite: {fileID: 0}
|
||||||
|
m_AnimationTriggers:
|
||||||
|
m_NormalTrigger: Normal
|
||||||
|
m_HighlightedTrigger: Highlighted
|
||||||
|
m_PressedTrigger: Pressed
|
||||||
|
m_SelectedTrigger: Selected
|
||||||
|
m_DisabledTrigger: Disabled
|
||||||
|
m_Interactable: 1
|
||||||
|
m_TargetGraphic: {fileID: 1503133441}
|
||||||
|
m_OnClick:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls:
|
||||||
|
- m_Target: {fileID: 593191224}
|
||||||
|
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
|
||||||
|
m_MethodName: SetActive
|
||||||
|
m_Mode: 6
|
||||||
|
m_Arguments:
|
||||||
|
m_ObjectArgument: {fileID: 0}
|
||||||
|
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||||
|
m_IntArgument: 0
|
||||||
|
m_FloatArgument: 0
|
||||||
|
m_StringArgument:
|
||||||
|
m_BoolArgument: 1
|
||||||
|
m_CallState: 2
|
||||||
|
- m_Target: {fileID: 1503133438}
|
||||||
|
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
|
||||||
|
m_MethodName: SetActive
|
||||||
|
m_Mode: 6
|
||||||
|
m_Arguments:
|
||||||
|
m_ObjectArgument: {fileID: 0}
|
||||||
|
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||||
|
m_IntArgument: 0
|
||||||
|
m_FloatArgument: 0
|
||||||
|
m_StringArgument:
|
||||||
|
m_BoolArgument: 0
|
||||||
|
m_CallState: 2
|
||||||
|
- m_Target: {fileID: 375256415}
|
||||||
|
m_TargetAssemblyTypeName: AudioManager, Assembly-CSharp
|
||||||
|
m_MethodName: ToggleMute
|
||||||
|
m_Mode: 6
|
||||||
|
m_Arguments:
|
||||||
|
m_ObjectArgument: {fileID: 0}
|
||||||
|
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||||
|
m_IntArgument: 0
|
||||||
|
m_FloatArgument: 0
|
||||||
|
m_StringArgument:
|
||||||
|
m_BoolArgument: 0
|
||||||
|
m_CallState: 2
|
||||||
|
--- !u!114 &1503133441
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1503133438}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_Sprite: {fileID: 21300000, guid: ed9fd713ff6341f41bf1e09fd4f27435, type: 3}
|
||||||
|
m_Type: 0
|
||||||
|
m_PreserveAspect: 0
|
||||||
|
m_FillCenter: 1
|
||||||
|
m_FillMethod: 4
|
||||||
|
m_FillAmount: 1
|
||||||
|
m_FillClockwise: 1
|
||||||
|
m_FillOrigin: 0
|
||||||
|
m_UseSpriteMesh: 0
|
||||||
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!222 &1503133442
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1503133438}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
--- !u!1 &1542177989
|
--- !u!1 &1542177989
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -1,14 +1,26 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Audio;
|
||||||
|
|
||||||
public class AudioManager : MonoBehaviour
|
public class AudioManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public static AudioManager Instance;
|
||||||
|
|
||||||
|
|
||||||
|
[Header("AudioMixer")]
|
||||||
|
public AudioMixer mixer;
|
||||||
|
public AudioMixerSnapshot defaultSnapshot;
|
||||||
|
public AudioMixerSnapshot muteSnapshot;
|
||||||
|
|
||||||
|
[Header("References")]
|
||||||
public AudioSource musicSource;
|
public AudioSource musicSource;
|
||||||
public AudioSource sfxSource;
|
public AudioSource sfxSource;
|
||||||
|
|
||||||
|
[Header("Musics")]
|
||||||
public List<MusicByTitle> musics = new List<MusicByTitle>();
|
public List<MusicByTitle> musics = new List<MusicByTitle>();
|
||||||
|
|
||||||
public static AudioManager Instance;
|
private bool isMute = false;
|
||||||
|
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
@ -33,6 +45,11 @@ public void PlaySFX(AudioClip _clip)
|
|||||||
Debug.Log($"playing {_clip.name} SFX");
|
Debug.Log($"playing {_clip.name} SFX");
|
||||||
sfxSource.PlayOneShot(_clip);
|
sfxSource.PlayOneShot(_clip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ToggleMute(bool _toggle)
|
||||||
|
{
|
||||||
|
mixer.TransitionToSnapshots(new AudioMixerSnapshot[] { defaultSnapshot, muteSnapshot }, _toggle ? new float[] { 0, 1 } : new float[] { 1, 0 }, 0.2f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
|
Loading…
Reference in New Issue
Block a user