JD2022-TU1/main/tools/framework/JD.Serialization/Timeline/Clips/SoundSetClip.cs

36 lines
1.2 KiB
C#

using System.ComponentModel;
using System.Linq;
namespace JD.Serialization
{
public partial class SoundSetClip
{
private SoundComponent_Template _soundSet;
private string _loadedSoundSet;
[Category("SoundSet")]
[Description("The actor to use to localize the sound")]
[ReadOnly(true)]
[Browsable(true)]
public SoundComponent_Template SoundSet
{
get
{
if (_soundSet == null && SoundSetPath?.getAbsolute() != null && SoundSetPath.getAbsolute() != _loadedSoundSet)
{
try
{
var actor = (Actor_Template)new LuaSerializer().LoadObjectFromFile(SoundSetPath.getAbsolute());
_soundSet = actor.COMPONENTS.OfType<SoundComponent_Template>().FirstOrDefault();
_loadedSoundSet = SoundSetPath.getAbsolute();
}
catch
{
// Ignore any loading failures (missing file, invalid lua, ...).
}
}
return _soundSet;
}
}
}
}