Added destroy on scene exit property of AudioClipHandles #428
|
@ -822,6 +822,16 @@ namespace SHADE
|
|||
instance->setVolume(volume);
|
||||
}
|
||||
|
||||
bool AudioClip::GetDestroyOnSceneExit()
|
||||
{
|
||||
return destroyOnSceneExit;
|
||||
}
|
||||
|
||||
void AudioClip::SetDestroyOnSceneExit(bool value)
|
||||
{
|
||||
destroyOnSceneExit = value;
|
||||
}
|
||||
|
||||
SHEventHandle SHAudioSystem::onStop(SHEventPtr onStopEvent)
|
||||
{
|
||||
StopAllSounds();
|
||||
|
@ -841,8 +851,11 @@ namespace SHADE
|
|||
auto [begin, end] = audioClipLibrary.GetDenseAccess();
|
||||
for (auto& it = begin; it != end; ++it)
|
||||
{
|
||||
it->instance->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT);
|
||||
it->instance->release();
|
||||
if(it->destroyOnSceneExit)
|
||||
{
|
||||
it->instance->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT);
|
||||
it->instance->release();
|
||||
}
|
||||
}
|
||||
|
||||
return onSceneExitEvent->handle;
|
||||
|
|
|
@ -37,10 +37,13 @@ namespace SHADE
|
|||
float GetParameterValue(const char* paramName);
|
||||
float GetVolume();
|
||||
void SetVolume(float volume);
|
||||
bool GetDestroyOnSceneExit();
|
||||
void SetDestroyOnSceneExit(bool value);
|
||||
friend class SHAudioSystem;
|
||||
private:
|
||||
FMOD::Studio::EventInstance* instance = nullptr;
|
||||
EntityID transformRef = MAX_EID;
|
||||
bool destroyOnSceneExit = true;
|
||||
};
|
||||
|
||||
class SH_API SHAudioSystem : public SHSystem
|
||||
|
|
|
@ -44,6 +44,16 @@ namespace SHADE
|
|||
return SHResourceManagerInterface::GetAssetID(Convert::ToNative(audioClipInstHandle)).value_or(INVALID_ASSET_ID);
|
||||
}
|
||||
|
||||
bool AudioClipHandler::DestroyOnSceneExit::get()
|
||||
{
|
||||
return NativeObject->GetDestroyOnSceneExit();
|
||||
}
|
||||
|
||||
void AudioClipHandler::DestroyOnSceneExit::set(bool value)
|
||||
{
|
||||
NativeObject->SetDestroyOnSceneExit(value);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Constructors/Destructor */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -54,6 +54,12 @@ namespace SHADE
|
|||
AssetID get();
|
||||
}
|
||||
|
||||
property bool DestroyOnSceneExit
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Constructors/Destructor */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in New Issue