Added a music fadeout.

This commit is contained in:
2025-08-03 21:15:57 -04:00
parent 22a25b65d8
commit 1841c72eaf
15 changed files with 237 additions and 68 deletions
+65 -1
View File
@@ -44,7 +44,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 32
Data: 33
- Name:
Entry: 7
Data:
@@ -1813,6 +1813,70 @@ MonoBehaviour:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _FadeOutMusic
- Name: $v
Entry: 7
Data: 103|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _FadeOutMusic
- Name: <UserType>k__BackingField
Entry: 7
Data: 104|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 104
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 105|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 106|UnityEngine.HeaderAttribute, UnityEngine.CoreModule
- Name: header
Entry: 1
Data: Private
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
+29 -1
View File
@@ -89,7 +89,28 @@ public class AudioManager : UdonSharpBehaviour
[SerializeField] private AudioClip _CrookTheme_VicTheSlick = null;
[SerializeField] private AudioClip _CrookTheme_WonderRat = null;
[Header("Private")]
private bool _FadeOutMusic = false;
public void Update()
{
if (_FadeOutMusic)
{
float NewVolume = _MusicPlayer.volume - (Time.deltaTime / 2.0f);
if (NewVolume <= 0.0f)
{
StopMusic();
_FadeOutMusic = false;
}
else
{
_MusicPlayer.volume = NewVolume;
}
}
}
[NetworkCallable]
public void PlayMusic(MusicEventType MusicEvent)
{
@@ -108,6 +129,12 @@ public class AudioManager : UdonSharpBehaviour
_PlayMusic_Internal(MusicEventType.None, false);
}
[NetworkCallable]
public void FadeOutMusic()
{
_FadeOutMusic = true;
}
private void _PlayMusic_Internal(MusicEventType MusicEvent, bool Loop)
{
_MusicPlayer.Stop();
@@ -134,6 +161,7 @@ public class AudioManager : UdonSharpBehaviour
_MusicPlayer.loop = Loop;
if (_MusicPlayer.clip != null)
_MusicPlayer.volume = 1.0f;
_MusicPlayer.Play();
}
@@ -74,11 +74,7 @@ public class GameManagerBase : UdonSharpBehaviour
}
public virtual void InitialiseGameMode()
{
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All, "StopMusic");
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All, "StopSFX");
}
public virtual void InitialiseGameMode() { }
public virtual void LoadQuestionData(DataToken Data) { }
@@ -970,6 +970,9 @@ public class GameManagerRound1 : GameManagerBase
(HostCardBetweenRoundsInterface)GetHostCardInterface(RoundSegmentType.BetweenSegments);
Interface.HeaderUI.text = "Round is over. Move to the loot recovery area.";
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlayMusicLoop", MusicEventType.CapitalLoop);
_CaseManager.ContinueToRound2();
EnableInteraction("End Game");
@@ -112,8 +112,7 @@ public class GameManagerRound2 : GameManagerBase
RecoverTheLootInterface.HeaderUI.text = RoundSegmentTypeToString(RoundSegmentType.RecoverTheLootExplainer);
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlayMusicLoop", MusicEventType.CapitalLoop);
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All, "FadeOutMusic");
EnableInteraction("Begin Round");
}
@@ -236,6 +235,9 @@ public class GameManagerRound2 : GameManagerBase
Interface.HeaderUI.text = "Round is over. Let's go to the map!";
_CaseManager.ContinueToRound3();
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlayMusicLoop", MusicEventType.IFeelGood);
}
@@ -127,8 +127,7 @@ public class GameManagerRound3 : GameManagerBase
CaptureCarmenExplainerInterface.HeaderUI.text = RoundSegmentTypeToString(RoundSegmentType.CaptureCarmenExplainer);
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlayMusicLoop", MusicEventType.IFeelGood);
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All, "FadeOutMusic");
EnableInteraction("Begin");
}
@@ -338,7 +337,7 @@ public class GameManagerRound3 : GameManagerBase
(HostCardBetweenRoundsInterface)GetHostCardInterface(RoundSegmentType.BetweenSegments);
Interface.HeaderUI.text = "Game is over. Load a new case file to start again.";
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All, "StopMusic");
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All, "FadeOutMusic");
EnableInteraction("Game is over. Load a new case file to start again.");
}
@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: BoneFollower
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: ccbda9bf23e2f714c9226283c77a92e5,
serializedUdonProgramAsset: {fileID: 11400000, guid: 52ecc8a73071e8e40928c3609699fcf4,
type: 2}
udonAssembly:
assemblyError:
@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: InteractToggle
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: 405e38d3dfb2f514daeed0e28fbb4864,
serializedUdonProgramAsset: {fileID: 11400000, guid: 873dfce61b1514e429c92e0d2fded7de,
type: 2}
udonAssembly:
assemblyError:
@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: PlayerModSetter
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: f938e6c4ff027a74da405a1f9353fd2b,
serializedUdonProgramAsset: {fileID: 11400000, guid: e81558796a212ab4d88e305e2010f24b,
type: 2}
udonAssembly:
assemblyError:
@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: GlobalToggleObject
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: c49c9265a3ef24642a6a4465d0a78872,
serializedUdonProgramAsset: {fileID: 11400000, guid: 2fe8ced6184000f49bca526cd2c5891c,
type: 2}
udonAssembly:
assemblyError:
@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: MasterToggleObject
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: 04024a76ab1924042ba521e11cb76d91,
serializedUdonProgramAsset: {fileID: 11400000, guid: a2d01d9f36ac6df49831be249e48ecc4,
type: 2}
udonAssembly:
assemblyError:
@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: TrackingDataFollower
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: 17f8fbbe6cc186d4f8dbb057b01a4ec2,
serializedUdonProgramAsset: {fileID: 11400000, guid: 1b89d4552983c0448a7389decec3b555,
type: 2}
udonAssembly:
assemblyError:
@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: WorldAudioSettings
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: 128d924a3066b7546b2d1c73e61006ab,
serializedUdonProgramAsset: {fileID: 11400000, guid: 994b559b0f158b4499f8937980ed8694,
type: 2}
udonAssembly:
assemblyError: