mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fixed a bug where changing an existing AudioSource to use a specific AudioClip resource didn't work
This commit is contained in:
parent
ee776e384b
commit
e02dd94cad
@ -2,7 +2,6 @@ using NewHorizons.External.SerializableData;
|
||||
using NewHorizons.External.SerializableEnums;
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace NewHorizons.External.Modules
|
||||
{
|
||||
|
||||
@ -27,23 +27,34 @@ namespace NewHorizons.Utility.Files
|
||||
source._clipArrayLength = 0;
|
||||
source._clipSelectionOnPlay = OWAudioSource.ClipSelectionOnPlay.MANUAL;
|
||||
source.clip = clip;
|
||||
NHLogger.LogVerbose($"[{nameof(AudioUtilities)}] : Audio {audio} was loaded from a file");
|
||||
return;
|
||||
}
|
||||
catch
|
||||
{
|
||||
NHLogger.LogError($"Could not load file {audio}");
|
||||
NHLogger.LogError($"[{nameof(AudioUtilities)}] : Could not load file {audio}");
|
||||
}
|
||||
}
|
||||
|
||||
if (EnumUtils.TryParse(audio, out AudioType type))
|
||||
{
|
||||
source._audioLibraryClip = type;
|
||||
NHLogger.LogVerbose($"[{nameof(AudioUtilities)}] : Audio {audio} was an AudioType enum");
|
||||
}
|
||||
else
|
||||
{
|
||||
var audioClip = SearchUtilities.FindResourceOfTypeAndName<AudioClip>(audio);
|
||||
if (audioClip == null) NHLogger.Log($"Couldn't find audio clip {audio}");
|
||||
else source.clip = audioClip;
|
||||
if (audioClip == null)
|
||||
{
|
||||
NHLogger.LogError($"[{nameof(AudioUtilities)}] : Couldn't find audio clip {audio}");
|
||||
}
|
||||
else
|
||||
{
|
||||
NHLogger.LogVerbose($"[{nameof(AudioUtilities)}] : Audio {audio} was an AudioClip resource");
|
||||
// Else if this is set it will try to change the clip back when it starts playing
|
||||
source._audioLibraryClip = AudioType.None;
|
||||
source.clip = audioClip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user