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

UnityEngine.AudioClip support #238

Merged
merged 6 commits into from
Aug 3, 2021
Merged

UnityEngine.AudioClip support #238

merged 6 commits into from
Aug 3, 2021

Conversation

Metious
Copy link
Member

@Metious Metious commented Jul 25, 2021

Changes made in this pull request

  • Added UnityEngine.AudioModule.dll to SMLHelper dependencies
  • Added a function to AudioUtils to convert an AudioClip to FMOD.Sound.
  • Added functions to CustomSoundHandler to register an AudioClip as an FMOD.Sound

SMLHelper_SN.STABLE.zip
SMLHelper_BZ.STABLE.zip

Sound Test Mod

In this mod i've implemented a very simple console command that plays an FMOD sound out of a unity engine audio clip.

a Snippet of how the implementation looks like:

using QModManager.API.ModLoading;
using SMLHelper.V2.Handlers;
using UnityEngine;

[QModCore]
public static class Main
{
  private static Assembly myAssembly = Assembly.GetExecutingAssembly();
  private static string ModPath = Path.GetDirectoryName(myAssembly.Location);
  internal static string AssetsFolder = Path.Combine(ModPath, "Assets");

  internal static AssetBundle assetBundle = AssetBundle.LoadFromFile(Path.Combine(AssetsFolder, "soundtest"));

  [QModPatch]
  public static void Patch()
  {
    CustomSoundHandler.RegisterCustomSound("MyCustomSound", assetBundle.LoadAsset<AudioClip>("MetiousTestingSound"));
  
    ConsoleCommandsHandler.Main.RegisterConsoleCommand("testsound", typeof(Main), nameof(Command_TestSound));
  }
  public static void Command_TestSound()
  {
    FMODUWE.PlayOneShot("MyCustomSound", Player.main.transform.position);
  }
}

SoundTestSN1.zip

@Metious Metious merged commit 2cf9f3f into dev Aug 3, 2021
@Metious Metious deleted the SoundHandlerExpansion branch August 3, 2021 20:37
@Metious Metious mentioned this pull request Aug 3, 2021
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.

2 participants