Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SoundEvent name collisions by using InstanceID-based unique identifiers #48

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

FRESH-SHIN
Copy link

Problem

Previously, SoundEvent identification relied solely on the asset's name. If multiple assets shared the same name—even if stored in different directories—it caused naming conflicts. Additionally, spaces in asset names led to registration and playback issues.

Solution

To ensure each SoundEvent has a unique identifier and to avoid whitespace-related issues, the naming convention has been updated in the following locations:

  1. PHASESource.cs

    • When calling Helpers.PHASEPlaySoundEvent, the _soundEvent.name parameter has been replaced with "SoundEvent_" + _soundEvent.GetInstanceID().ToString().
    • This guarantees that each SoundEvent played by a PHASESource has a unique name at runtime.
  2. PHASESoundEventNodeGraph.cs

    • The asset name used in Helpers.PHASERegisterSoundEventAsset has been updated to "SoundEvent_" + GetInstanceID().ToString(), ensuring that even if multiple assets have the same name or contain spaces, they will be uniquely registered.

Impact

  • Prevents SoundEvent name collisions across different assets and directories.
  • Avoids issues caused by whitespace in asset names.
  • Ensures that every SoundEvent is uniquely identified during runtime.

Testing

  • Created multiple SoundEvent assets with the same name but in different directories; they now register and play correctly without conflicts.
  • Tested with asset names containing spaces; no longer triggers registration errors.

Additional Notes

  • This change only affects internal SoundEvent naming and does not alter any user-facing functionality.
  • All SoundEvents will now have a runtime-generated unique identifier, ensuring consistent behavior.

…cts and whitespace handling

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant