Added Scripting interface for AudioClips #320

Merged
srishamharan merged 7 commits from AudioScripting into main 2023-01-30 17:08:39 +08:00
2 changed files with 19 additions and 1 deletions
Showing only changes of commit de6f4dd138 - Show all commits

View File

@ -368,6 +368,19 @@ namespace SHADE
sfxChannelGroup->addGroup(channelGroup);
}
void SHAudioSystem::AttachAudioClipToObject(Handle<AudioClip> handle, EntityID eid)
{
if (auto transform = SHComponentManager::GetComponent_s<SHTransformComponent>(eid))
{
handle->transformRef = transform;
}
}
void SHAudioSystem::DetachAudioClipToObject(Handle<AudioClip> handle, EntityID eid)
{
handle->transformRef = nullptr;
}
//AudioClip* SHAudioSystem::CreateAudioClip(const char* path)
//{
// AudioClipID newID{};

View File

@ -26,6 +26,7 @@ namespace SHADE
class AudioClip
{
public:
//expose to sxripting
void Play();
//void Play(SHVec3 position);
void Stop(bool fadeOut = true);
@ -38,7 +39,7 @@ namespace SHADE
friend class SHAudioSystem;
private:
FMOD::Studio::EventInstance* instance = nullptr;
//SHTransformComponent* transformRef;
SHTransformComponent* transformRef = nullptr;
};
class SH_API SHAudioSystem : public SHSystem
@ -68,10 +69,14 @@ namespace SHADE
std::optional<FMOD_GUID> GetEventGUID(const char* path);
//AudioClip* CreateAudioClip(const char* path);
//AUDIO CLIP
Handle<AudioClip> CreateAudioClip(const char* path);
void AddAudioClipToBGMChannelGroup(Handle<AudioClip> handle);
void AddAudioClipToSFXChannelGroup(Handle<AudioClip> handle);
void AttachAudioClipToObject(Handle<AudioClip> handle, EntityID eid);
void DetachAudioClipToObject(Handle<AudioClip> handle, EntityID eid);
///
float GetBgmVolume();
float GetSfxVolume();
float GetMasterVolume();