From 60a5246bc587025781f6749086104a1fddea5942 Mon Sep 17 00:00:00 2001 From: SHIN <106070536+FRESH-SHIN@users.noreply.github.com> Date: Thu, 13 Mar 2025 17:49:00 +0900 Subject: [PATCH] Fix an issue where SoundEvents could collide due to asset name conflicts and whitespace handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, SoundEvent identification depended solely on an asset's name. If multiple assets shared the same name—even if located in different paths—it caused collisions, and spaces in asset names led to additional issues. To address these problems, the naming convention has been updated in two specific places: ## PHASESource.cs When playing a SoundEvent, instead of passing `_soundEvent.name` to `Helpers.PHASEPlaySoundEvent`, the code now passes a unique identifier created by concatenating `"SoundEvent_"` with `_soundEvent.GetInstanceID().ToString()`. This change ensures that each SoundEvent played by a PHASESource is uniquely identified at runtime. ## PHASESoundEventNodeGraph.cs During the registration of a SoundEvent asset via `Helpers.PHASERegisterSoundEventAsset`, the asset name parameter is now set to `"SoundEvent_" + GetInstanceID().ToString()` instead of the original asset name. This prevents conflicts when multiple assets share the same name or contain spaces. These modifications guarantee that each SoundEvent, even with identical or whitespace-containing names, will have a unique identifier based on its runtime InstanceID, thereby eliminating naming collisions. --- .../Apple.PHASE/Apple.PHASE_Unity/Assets/Runtime/PHASESource.cs | 2 +- .../Assets/Runtime/SoundEvent/PHASESoundEventNodeGraph.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Runtime/PHASESource.cs b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Runtime/PHASESource.cs index b18a963b..a280e9b9 100644 --- a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Runtime/PHASESource.cs +++ b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Runtime/PHASESource.cs @@ -180,7 +180,7 @@ public void Play() _mixers = _soundEvent.GetMixers(); long[] mixerIds = GetMixerIds(); - var instanceId = Helpers.PHASEPlaySoundEvent(_soundEvent.name, _sourceId, mixerIds, (uint)mixerIds.Length, SoundEventCallback); + var instanceId = Helpers.PHASEPlaySoundEvent("SoundEvent_" + _soundEvent.GetInstanceID().ToString(), _sourceId, mixerIds, (uint)mixerIds.Length, SoundEventCallback); if (instanceId == Helpers.InvalidId) { Debug.LogError($"Failed to play sound event: {_soundEvent.name}."); diff --git a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Runtime/SoundEvent/PHASESoundEventNodeGraph.cs b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Runtime/SoundEvent/PHASESoundEventNodeGraph.cs index edd5c8c2..5fb8b689 100644 --- a/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Runtime/SoundEvent/PHASESoundEventNodeGraph.cs +++ b/plug-ins/Apple.PHASE/Apple.PHASE_Unity/Assets/Runtime/SoundEvent/PHASESoundEventNodeGraph.cs @@ -38,7 +38,7 @@ public void Register() } // Create sound event asset - result = Helpers.PHASERegisterSoundEventAsset(name, m_rootNode.GetNodeId()); + result = Helpers.PHASERegisterSoundEventAsset("SoundEvent_" + GetInstanceID().ToString(), m_rootNode.GetNodeId()); if (result == false) { Debug.LogError($"Failed to register PHASE sound event asset: {name}.");