Initial Wwise Integration

Created wwise project
Integrated inventory UI sounds
Improved projectile weapon behavior (randomized start position, stopped them from self-destructing at target range when airburst is disabled)
This commit is contained in:
Reinier Vens 2021-02-27 20:53:36 +00:00
commit db8c3c7779
1019 changed files with 76372 additions and 110 deletions

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1367e390a89eb6f49afcec4c429d6b88
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,167 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
/// <summary>
/// This class represents an example audio input manager and is responsible for managing the audio sample and format
/// callbacks provided to the Wwise Audio Input plug-in.
/// </summary>
public static class AkAudioInputManager
{
/// <summary>
/// Sanitized audio format delegate to be used by classes that implement audio input plug-ins. The samples are ALWAYS
/// set to be non-interleaved 32-bit float.
/// </summary>
/// <param name="playingID">The playingID of a sound that uses the audio input plug-in.</param>
/// <param name="format">The C# analog of the C++ AkAudioFormat class.</param>
public delegate void AudioFormatDelegate(uint playingID, AkAudioFormat format);
/// <summary>
/// Audio format delegate that is sent to C++.
/// </summary>
[System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
public delegate void AudioFormatInteropDelegate(uint playingID, System.IntPtr format);
/// <summary>
/// Sanitized audio sample delegate to be used by classes that implement audio input plug-ins. For every event posted,
/// this delegate is called once per audio frame for each channel until the delegates for all the channels associated
/// with this event return false.
/// </summary>
/// <param name="playingID">The playingID of a sound that uses the audio input plug-in.</param>
/// <param name="channelIndex">The number of the channel associated with this specific invocation of the delegate.</param>
/// <param name="samples">The sample array that MUST be filled even when returning false.</param>
/// <returns>Return true when more sample frames are require and false when complete.</returns>
public delegate bool AudioSamplesDelegate(uint playingID, uint channelIndex, float[] samples);
/// <summary>
/// Audio sample delegate that is sent to C++.
/// </summary>
[System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
public delegate bool AudioSamplesInteropDelegate(uint playingID,
[System.Runtime.InteropServices.In]
[System.Runtime.InteropServices.Out]
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPArray, SizeParamIndex = 3)]
float[] samples, uint channelIndex, uint frames);
private static bool initialized;
private static readonly System.Collections.Generic.Dictionary<uint, AudioSamplesDelegate> audioSamplesDelegates =
new System.Collections.Generic.Dictionary<uint, AudioSamplesDelegate>();
private static readonly System.Collections.Generic.Dictionary<uint, AudioFormatDelegate> audioFormatDelegates =
new System.Collections.Generic.Dictionary<uint, AudioFormatDelegate>();
private static readonly AkAudioFormat audioFormat = new AkAudioFormat();
private static readonly AudioSamplesInteropDelegate audioSamplesDelegate = InternalAudioSamplesDelegate;
private static readonly AudioFormatInteropDelegate audioFormatDelegate = InternalAudioFormatDelegate;
/// <summary>
/// This method is used to post events that use the Wwise Audio Input plug-in.
/// </summary>
/// <param name="akEvent">The event to post.</param>
/// <param name="gameObject">The GameObject that the event will be posted on.</param>
/// <param name="sampleDelegate">The C# audio sample delegate.</param>
/// <param name="formatDelegate">
/// The C# audio format delegate. If not specified, defaults to a mono source running at the
/// sample rate of the sound engine.
/// </param>
/// <returns>The playingID of the newly instantiated sound associated with the posted event.</returns>
public static uint PostAudioInputEvent(AK.Wwise.Event akEvent, UnityEngine.GameObject gameObject,
AudioSamplesDelegate sampleDelegate, AudioFormatDelegate formatDelegate = null)
{
TryInitialize();
var playingID = akEvent.Post(gameObject, (uint) AkCallbackType.AK_EndOfEvent, EventCallback);
AddPlayingID(playingID, sampleDelegate, formatDelegate);
return playingID;
}
/// <summary>
/// This method is used to post events that use the Wwise Audio Input plug-in.
/// </summary>
/// <param name="akEventID">The ID of the event to post.</param>
/// <param name="gameObject">The GameObject that the event will be posted on.</param>
/// <param name="sampleDelegate">The C# audio sample delegate.</param>
/// <param name="formatDelegate">
/// The C# audio format delegate. If not specified, defaults to a mono source running at the
/// sample rate of the sound engine.
/// </param>
/// <returns>The playingID of the newly instantiated sound associated with the posted event.</returns>
public static uint PostAudioInputEvent(uint akEventID, UnityEngine.GameObject gameObject,
AudioSamplesDelegate sampleDelegate, AudioFormatDelegate formatDelegate = null)
{
TryInitialize();
var playingID =
AkSoundEngine.PostEvent(akEventID, gameObject, (uint) AkCallbackType.AK_EndOfEvent, EventCallback, null);
AddPlayingID(playingID, sampleDelegate, formatDelegate);
return playingID;
}
/// <summary>
/// This method is used to post events that use the Wwise Audio Input plug-in.
/// </summary>
/// <param name="akEventName">The name of the event to post.</param>
/// <param name="gameObject">The GameObject that the event will be posted on.</param>
/// <param name="sampleDelegate">The C# audio sample delegate.</param>
/// <param name="formatDelegate">
/// The C# audio format delegate. If not specified, defaults to a mono source running at the
/// sample rate of the sound engine.
/// </param>
/// <returns>The playingID of the newly instantiated sound associated with the posted event.</returns>
public static uint PostAudioInputEvent(string akEventName, UnityEngine.GameObject gameObject,
AudioSamplesDelegate sampleDelegate, AudioFormatDelegate formatDelegate = null)
{
TryInitialize();
var playingID =
AkSoundEngine.PostEvent(akEventName, gameObject, (uint) AkCallbackType.AK_EndOfEvent, EventCallback, null);
AddPlayingID(playingID, sampleDelegate, formatDelegate);
return playingID;
}
[AOT.MonoPInvokeCallback(typeof(AudioSamplesInteropDelegate))]
private static bool InternalAudioSamplesDelegate(uint playingID, float[] samples, uint channelIndex, uint frames)
{
return audioSamplesDelegates.ContainsKey(playingID) &&
audioSamplesDelegates[playingID](playingID, channelIndex, samples);
}
[AOT.MonoPInvokeCallback(typeof(AudioFormatInteropDelegate))]
private static void InternalAudioFormatDelegate(uint playingID, System.IntPtr format)
{
if (audioFormatDelegates.ContainsKey(playingID))
{
audioFormat.setCPtr(format);
audioFormatDelegates[playingID](playingID, audioFormat);
}
}
private static void TryInitialize()
{
if (!initialized)
{
initialized = true;
AkSoundEngine.SetAudioInputCallbacks(audioSamplesDelegate, audioFormatDelegate);
}
}
private static void AddPlayingID(uint playingID, AudioSamplesDelegate sampleDelegate,
AudioFormatDelegate formatDelegate)
{
if (playingID == AkSoundEngine.AK_INVALID_PLAYING_ID || sampleDelegate == null)
return;
audioSamplesDelegates.Add(playingID, sampleDelegate);
if (formatDelegate != null)
audioFormatDelegates.Add(playingID, formatDelegate);
}
private static void EventCallback(object cookie, AkCallbackType type, AkCallbackInfo callbackInfo)
{
if (type == AkCallbackType.AK_EndOfEvent)
{
var info = callbackInfo as AkEventCallbackInfo;
if (info != null)
{
audioSamplesDelegates.Remove(info.playingID);
audioFormatDelegates.Remove(info.playingID);
}
}
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4a6d2518a64fb4641aaf22375662c5ed
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,303 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief Maintains the list of loaded SoundBanks loaded. This is currently used only with AkAmbient objects.
public static class AkBankManager
{
private static readonly System.Collections.Generic.Dictionary<string, BankHandle> m_BankHandles =
new System.Collections.Generic.Dictionary<string, BankHandle>();
private static readonly System.Collections.Generic.List<BankHandle> BanksToUnload =
new System.Collections.Generic.List<BankHandle>();
internal static void DoUnloadBanks()
{
var count = BanksToUnload.Count;
for (var i = 0; i < count; ++i)
BanksToUnload[i].UnloadBank();
BanksToUnload.Clear();
}
internal static void Reset()
{
m_BankHandles.Clear();
BanksToUnload.Clear();
}
#if UNITY_EDITOR
internal static void ReloadAllBanks()
{
lock (m_BankHandles)
{
foreach (var bankHandle in m_BankHandles.Values)
{
if (bankHandle != null)
{
bankHandle.UnloadBank();
}
}
UnloadInitBank();
LoadInitBank(false);
foreach (var bankHandle in m_BankHandles.Values)
{
if (bankHandle != null)
{
bankHandle.DoLoadBank();
}
}
}
}
#endif
public static void LoadInitBank(bool doReset = true)
{
if (doReset)
{
Reset();
}
uint BankID;
var result = AkSoundEngine.LoadBank("Init.bnk", out BankID);
if (result != AKRESULT.AK_Success)
{
UnityEngine.Debug.LogError("WwiseUnity: Failed load Init.bnk with result: " + result);
}
}
public static void UnloadInitBank()
{
AkSoundEngine.UnloadBank("Init.bnk", System.IntPtr.Zero);
}
/// Loads a SoundBank. This version blocks until the bank is loaded. See AK::SoundEngine::LoadBank for more information.
public static void LoadBank(string name, bool decodeBank, bool saveDecodedBank)
{
BankHandle handle = null;
lock (m_BankHandles)
{
if (m_BankHandles.TryGetValue(name, out handle))
{
// Bank already loaded, increment its ref count.
handle.IncRef();
return;
}
#if UNITY_SWITCH
// No bank decoding on Nintendo switch
handle = new BankHandle(name);
#else
handle = decodeBank ? new DecodableBankHandle(name, saveDecodedBank) : new BankHandle(name);
#endif
m_BankHandles.Add(name, handle);
}
handle.LoadBank();
}
/// Loads a SoundBank. This version returns right away and loads in background. See AK::SoundEngine::LoadBank for more information.
public static void LoadBankAsync(string name, AkCallbackManager.BankCallback callback = null)
{
BankHandle handle = null;
lock (m_BankHandles)
{
if (m_BankHandles.TryGetValue(name, out handle))
{
// Bank already loaded, increment its ref count.
handle.IncRef();
return;
}
handle = new AsyncBankHandle(name, callback);
m_BankHandles.Add(name, handle);
}
handle.LoadBank();
}
/// Unloads a SoundBank. See AK::SoundEngine::UnloadBank for more information.
public static void UnloadBank(string name)
{
lock (m_BankHandles)
{
BankHandle handle = null;
if (m_BankHandles.TryGetValue(name, out handle))
handle.DecRef();
}
}
private class BankHandle
{
protected readonly string bankName;
protected uint m_BankID;
public BankHandle(string name)
{
bankName = name;
}
public int RefCount { get; private set; }
/// Loads a bank. This version blocks until the bank is loaded. See AK::SoundEngine::LoadBank for more information.
public virtual AKRESULT DoLoadBank()
{
return AkSoundEngine.LoadBank(bankName, out m_BankID);
}
public void LoadBank()
{
#if UNITY_EDITOR
if (!AkSoundEngineController.Instance.IsSoundEngineLoaded)
return;
#endif
if (RefCount == 0 && !BanksToUnload.Remove(this))
{
var res = DoLoadBank();
LogLoadResult(res);
}
IncRef();
}
/// Unloads a bank.
public virtual void UnloadBank()
{
AkSoundEngine.UnloadBank(m_BankID, System.IntPtr.Zero, null, null);
lock (m_BankHandles)
m_BankHandles.Remove(bankName);
}
public void IncRef()
{
if (RefCount == 0)
BanksToUnload.Remove(this);
RefCount++;
}
public void DecRef()
{
RefCount--;
if (RefCount == 0)
BanksToUnload.Add(this);
}
protected void LogLoadResult(AKRESULT result)
{
if (result != AKRESULT.AK_Success && AkSoundEngine.IsInitialized())
UnityEngine.Debug.LogWarning("WwiseUnity: Bank " + bankName + " failed to load (" + result + ")");
}
}
private class AsyncBankHandle : BankHandle
{
private readonly AkCallbackManager.BankCallback bankCallback;
public AsyncBankHandle(string name, AkCallbackManager.BankCallback callback) : base(name)
{
bankCallback = callback;
}
private static void GlobalBankCallback(uint in_bankID, System.IntPtr in_pInMemoryBankPtr, AKRESULT in_eLoadResult, object in_Cookie)
{
var handle = (AsyncBankHandle)in_Cookie;
var callback = handle.bankCallback;
if (in_eLoadResult != AKRESULT.AK_Success)
{
handle.LogLoadResult(in_eLoadResult);
if (in_eLoadResult != AKRESULT.AK_BankAlreadyLoaded)
lock (m_BankHandles)
m_BankHandles.Remove(handle.bankName);
}
if (callback != null)
callback(in_bankID, in_pInMemoryBankPtr, in_eLoadResult, null);
}
/// Loads a bank. This version returns right away and loads in background. See AK::SoundEngine::LoadBank for more information
public override AKRESULT DoLoadBank()
{
return AkSoundEngine.LoadBank(bankName, GlobalBankCallback, this, out m_BankID);
}
}
private class DecodableBankHandle : BankHandle
{
private readonly bool decodeBank = true;
private readonly string decodedBankPath;
private readonly bool saveDecodedBank;
public DecodableBankHandle(string name, bool save) : base(name)
{
saveDecodedBank = save;
var bankFileName = bankName + ".bnk";
// test language-specific decoded file path
var language = AkSoundEngine.GetCurrentLanguage();
var decodedBankFullPath = AkBasePathGetter.DecodedBankFullPath;
decodedBankPath = System.IO.Path.Combine(decodedBankFullPath, language);
var decodedBankFilePath = System.IO.Path.Combine(decodedBankPath, bankFileName);
var decodedFileExists = System.IO.File.Exists(decodedBankFilePath);
if (!decodedFileExists)
{
// test non-language-specific decoded file path
decodedBankPath = decodedBankFullPath;
decodedBankFilePath = System.IO.Path.Combine(decodedBankPath, bankFileName);
decodedFileExists = System.IO.File.Exists(decodedBankFilePath);
}
if (decodedFileExists)
{
try
{
var decodedFileTime = System.IO.File.GetLastWriteTime(decodedBankFilePath);
var encodedBankFilePath = System.IO.Path.Combine(AkBasePathGetter.SoundBankBasePath, bankFileName);
var encodedFileTime = System.IO.File.GetLastWriteTime(encodedBankFilePath);
decodeBank = decodedFileTime <= encodedFileTime;
}
catch
{
// Assume the decoded bank exists, but is not accessible. Re-decode it anyway, so we do nothing.
}
}
}
/// Loads a bank. This version blocks until the bank is loaded. See AK::SoundEngine::LoadBank for more information.
public override AKRESULT DoLoadBank()
{
if (decodeBank)
return AkSoundEngine.LoadAndDecodeBank(bankName, saveDecodedBank, out m_BankID);
if (string.IsNullOrEmpty(decodedBankPath))
return AkSoundEngine.LoadBank(bankName, out m_BankID);
var res = AkSoundEngine.SetBasePath(decodedBankPath);
if (res == AKRESULT.AK_Success)
{
res = AkSoundEngine.LoadBank(bankName, out m_BankID);
AkSoundEngine.SetBasePath(AkBasePathGetter.SoundBankBasePath);
}
return res;
}
/// Unloads a bank.
public override void UnloadBank()
{
if (decodeBank && !saveDecodedBank)
AkSoundEngine.PrepareBank(AkPreparationType.Preparation_Unload, m_BankID);
else
base.UnloadBank();
}
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1e627da541f5c2441a49746cbfeb6251
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,252 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2012 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// <summary>
/// This class is responsible for determining the path where sound banks are located. When using custom platforms, this
/// class needs to be extended.
/// </summary>
public partial class AkBasePathGetter
{
/// <summary>
/// User hook called to retrieve the custom platform name used to determine the base path. Do not modify platformName
/// to use default platform names.
/// </summary>
/// <param name="platformName">The custom platform name. Leave unaffected if the default location is acceptable.</param>
static partial void GetCustomPlatformName(ref string platformName);
/// <summary>
/// Determines the platform name which is also the sub-folder within the base path where sound banks are located for
/// this platform.
/// </summary>
/// <returns>The platform name.</returns>
public static string GetPlatformName()
{
var platformSubDir = string.Empty;
GetCustomPlatformName(ref platformSubDir);
if (!string.IsNullOrEmpty(platformSubDir))
return platformSubDir;
return DefaultPlatformName;
}
}
public partial class AkBasePathGetter
{
public static readonly string DefaultBasePath = System.IO.Path.Combine("Audio", "GeneratedSoundBanks");
private static bool LogWarnings_Internal = true;
public static bool LogWarnings
{
get { return LogWarnings_Internal; }
set { LogWarnings_Internal = value; }
}
/// <summary>
/// Returns the absolute path to the platform specific sound banks.
/// </summary>
/// <returns>The absolute path to the platform specific sound banks.</returns>
public static string GetPlatformBasePath()
{
var platformName = GetPlatformName();
#if UNITY_EDITOR
var platformBasePathEditor = GetPlatformBasePathEditor(platformName);
if (!string.IsNullOrEmpty(platformBasePathEditor))
return platformBasePathEditor;
var fullBasePath = AkWwiseEditorSettings.Instance.SoundbankPath;
#else
var fullBasePath = string.Empty;
#endif
if (string.IsNullOrEmpty(fullBasePath))
fullBasePath = AkWwiseInitializationSettings.ActivePlatformSettings.SoundbankPath;
#if UNITY_EDITOR || !UNITY_ANDROID
fullBasePath = System.IO.Path.Combine(UnityEngine.Application.streamingAssetsPath, fullBasePath);
#endif
#if UNITY_SWITCH
if (fullBasePath.StartsWith("/"))
fullBasePath = fullBasePath.Substring(1);
#endif
// Combine base path with platform sub-folder
var platformBasePath = System.IO.Path.Combine(fullBasePath, platformName);
AkUtilities.FixSlashes(ref platformBasePath);
return platformBasePath;
}
#if UNITY_EDITOR
public static bool GetSoundBankPaths(string platformName, out string sourcePlatformBasePath, out string destinationPlatformBasePath)
{
sourcePlatformBasePath = GetPlatformBasePathEditor(platformName);
if (string.IsNullOrEmpty(sourcePlatformBasePath))
{
if (LogWarnings)
UnityEngine.Debug.LogErrorFormat("WwiseUnity: Could not find source folder for <{0}> platform. Did you remember to generate your banks?", platformName);
destinationPlatformBasePath = string.Empty;
return false;
}
destinationPlatformBasePath = System.IO.Path.Combine(GetFullSoundBankPathEditor(), platformName);
if (string.IsNullOrEmpty(destinationPlatformBasePath))
{
if (LogWarnings)
UnityEngine.Debug.LogErrorFormat("WwiseUnity: Could not find destination folder for <{0}> platform", platformName);
return false;
}
return true;
}
/// <summary>
/// Returns the absolute path to the folder above the platform specific sound banks sub-folders.
/// </summary>
/// <returns>The absolute sound bank base path.</returns>
public static string GetFullSoundBankPathEditor()
{
string fullBasePath = System.IO.Path.Combine(UnityEngine.Application.streamingAssetsPath, AkWwiseEditorSettings.Instance.SoundbankPath);
AkUtilities.FixSlashes(ref fullBasePath);
return fullBasePath;
}
/// <summary>
/// Determines the platform base path for use within the Editor.
/// </summary>
/// <param name="platformName">The platform name.</param>
/// <returns>The full path to the sound banks for use within the Editor.</returns>
private static string GetPlatformBasePathEditor(string platformName)
{
var Settings = AkWwiseEditorSettings.Instance;
var WwiseProjectFullPath = AkUtilities.GetFullPath(UnityEngine.Application.dataPath, Settings.WwiseProjectPath);
var SoundBankDest = AkUtilities.GetWwiseSoundBankDestinationFolder(platformName, WwiseProjectFullPath);
try
{
if (System.IO.Path.GetPathRoot(SoundBankDest) == "")
{
// Path is relative, make it full
SoundBankDest = AkUtilities.GetFullPath(System.IO.Path.GetDirectoryName(WwiseProjectFullPath), SoundBankDest);
}
}
catch
{
SoundBankDest = string.Empty;
}
if (LogWarnings)
{
if (string.IsNullOrEmpty(SoundBankDest))
{
UnityEngine.Debug.LogWarning("WwiseUnity: The platform SoundBank subfolder within the Wwise project could not be found.");
return null;
}
try
{
// Verify if there are banks in there
var di = new System.IO.DirectoryInfo(SoundBankDest);
var foundBanks = di.GetFiles("*.bnk", System.IO.SearchOption.AllDirectories);
if (foundBanks.Length == 0)
{
return null;
}
if (!SoundBankDest.Contains(platformName))
{
if (LogWarnings)
UnityEngine.Debug.LogWarning("WwiseUnity: The platform SoundBank subfolder does not match your platform name. You will need to create a custom platform name getter for your game. See section \"Using Wwise Custom Platforms in Unity\" of the Wwise Unity integration documentation for more information");
}
return SoundBankDest;
}
catch
{
return null;
}
}
else
{
return SoundBankDest;
}
}
#endif
public static void EvaluateGamePaths()
{
#if UNITY_SWITCH && !UNITY_EDITOR
// Calling Application.persistentDataPath crashes Switch
string tempPersistentDataPath = null;
#else
string tempPersistentDataPath = UnityEngine.Application.persistentDataPath;
#endif
PersistentDataPath = tempPersistentDataPath;
var persistentDataSubfolder = AkWwiseInitializationSettings.ActivePlatformSettings.SoundBankPersistentDataPath;
string tempSoundBankBasePath = null;
if (!string.IsNullOrEmpty(tempPersistentDataPath) && !string.IsNullOrEmpty(persistentDataSubfolder))
{
tempSoundBankBasePath = System.IO.Path.GetFullPath(System.IO.Path.Combine(tempPersistentDataPath, persistentDataSubfolder));
if (LogWarnings)
UnityEngine.Debug.LogFormat("WwiseUnity: Using persistentDataPath. SoundBanks base path set to <{0}>.", tempSoundBankBasePath);
}
else
{
tempSoundBankBasePath = GetPlatformBasePath();
#if !UNITY_EDITOR && (UNITY_ANDROID || PLATFORM_LUMIN)
// Can't use File.Exists on Android, assume banks are there
var InitBnkFound = true;
#else
var InitBnkFound = System.IO.File.Exists(System.IO.Path.Combine(tempSoundBankBasePath, "Init.bnk"));
#endif
if (string.IsNullOrEmpty(tempSoundBankBasePath) || !InitBnkFound)
{
if (LogWarnings)
{
#if UNITY_EDITOR
var format = "WwiseUnity: Could not locate the SoundBanks in {0}. Did you make sure to generate them?";
#else
var format = "WwiseUnity: Could not locate the SoundBanks in {0}. Did you make sure to copy them to the StreamingAssets folder?";
#endif
UnityEngine.Debug.LogErrorFormat(format, tempSoundBankBasePath);
}
}
}
SoundBankBasePath = tempSoundBankBasePath;
string tempDecodedBankFullPath = null;
#if !UNITY_SWITCH || UNITY_EDITOR
#if (UNITY_ANDROID || PLATFORM_LUMIN || UNITY_IOS) && !UNITY_EDITOR
// This is for platforms that only have a specific file location for persistent data.
tempDecodedBankFullPath = System.IO.Path.Combine(tempPersistentDataPath, DecodedBankFolder);
#else
tempDecodedBankFullPath = System.IO.Path.Combine(tempSoundBankBasePath, DecodedBankFolder);
#endif
#endif
DecodedBankFullPath = tempDecodedBankFullPath;
}
public static string SoundBankBasePath { get; private set; }
public static string PersistentDataPath { get; private set; }
private const string DecodedBankFolder = "DecodedBanks";
public static string DecodedBankFullPath { get; private set; }
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9ea2121d226d14f4690e94515989d318
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,439 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2012 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// <summary>
/// This class manages the callback queue. All callbacks from the native Wwise SDK go through this queue.
/// The queue needs to be driven by regular calls to PostCallbacks(). This is currently done in AkInitializer.cs, in
/// LateUpdate().
/// </summary>
public static class AkCallbackManager
{
/// <summary>
/// Event callback used when posting events.
/// </summary>
public delegate void EventCallback(object in_cookie, AkCallbackType in_type, AkCallbackInfo in_info);
/// <summary>
/// Monitoring callback called when Wwise reports errors.
/// </summary>
public delegate void MonitoringCallback(AkMonitorErrorCode in_errorCode, AkMonitorErrorLevel in_errorLevel,
uint in_playingID, ulong in_gameObjID, string in_msg);
/// <summary>
/// Bank callback called upon bank load and unload and when errors occur.
/// </summary>
public delegate void BankCallback(uint in_bankID, System.IntPtr in_InMemoryBankPtr, AKRESULT in_eLoadResult, object in_Cookie);
private static bool IsLoggingEnabled { get; set; }
private static readonly AkEventCallbackInfo AkEventCallbackInfo = new AkEventCallbackInfo(System.IntPtr.Zero, false);
private static readonly AkDynamicSequenceItemCallbackInfo AkDynamicSequenceItemCallbackInfo =
new AkDynamicSequenceItemCallbackInfo(System.IntPtr.Zero, false);
private static readonly AkMIDIEventCallbackInfo AkMIDIEventCallbackInfo =
new AkMIDIEventCallbackInfo(System.IntPtr.Zero, false);
private static readonly AkMarkerCallbackInfo
AkMarkerCallbackInfo = new AkMarkerCallbackInfo(System.IntPtr.Zero, false);
private static readonly AkDurationCallbackInfo AkDurationCallbackInfo =
new AkDurationCallbackInfo(System.IntPtr.Zero, false);
private static readonly AkMusicSyncCallbackInfo AkMusicSyncCallbackInfo =
new AkMusicSyncCallbackInfo(System.IntPtr.Zero, false);
private static readonly AkMusicPlaylistCallbackInfo AkMusicPlaylistCallbackInfo =
new AkMusicPlaylistCallbackInfo(System.IntPtr.Zero, false);
#if UNITY_IOS && !UNITY_EDITOR
private static AkAudioInterruptionCallbackInfo AkAudioInterruptionCallbackInfo =
new AkAudioInterruptionCallbackInfo(System.IntPtr.Zero, false);
#endif // #if UNITY_IOS && ! UNITY_EDITOR
private static readonly AkAudioSourceChangeCallbackInfo AkAudioSourceChangeCallbackInfo =
new AkAudioSourceChangeCallbackInfo(System.IntPtr.Zero, false);
private static readonly AkMonitoringCallbackInfo AkMonitoringCallbackInfo =
new AkMonitoringCallbackInfo(System.IntPtr.Zero, false);
private static readonly AkBankCallbackInfo AkBankCallbackInfo = new AkBankCallbackInfo(System.IntPtr.Zero, false);
/// <summary>
/// This class holds the data associated with an event callback.
/// </summary>
public class EventCallbackPackage
{
public bool m_bNotifyEndOfEvent;
public EventCallback m_Callback;
public object m_Cookie;
public uint m_playingID;
public static EventCallbackPackage Create(EventCallback in_cb, object in_cookie, ref uint io_Flags)
{
if (io_Flags == 0 || in_cb == null)
{
io_Flags = 0;
return null;
}
var evt = new EventCallbackPackage();
evt.m_Callback = in_cb;
evt.m_Cookie = in_cookie;
evt.m_bNotifyEndOfEvent = (io_Flags & (uint) AkCallbackType.AK_EndOfEvent) != 0;
io_Flags = io_Flags | (uint) AkCallbackType.AK_EndOfEvent;
m_mapEventCallbacks[evt.GetHashCode()] = evt;
m_LastAddedEventPackage = evt;
return evt;
}
}
/// <summary>
/// This class holds the data associated with a bank load or unload callback.
/// </summary>
public class BankCallbackPackage
{
public BankCallback m_Callback;
public object m_Cookie;
public BankCallbackPackage(BankCallback in_cb, object in_cookie)
{
m_Callback = in_cb;
m_Cookie = in_cookie;
m_mapBankCallbacks[GetHashCode()] = this;
}
}
private static readonly System.Collections.Generic.Dictionary<int, EventCallbackPackage> m_mapEventCallbacks =
new System.Collections.Generic.Dictionary<int, EventCallbackPackage>();
private static readonly System.Collections.Generic.Dictionary<int, BankCallbackPackage> m_mapBankCallbacks =
new System.Collections.Generic.Dictionary<int, BankCallbackPackage>();
private static EventCallbackPackage m_LastAddedEventPackage;
public static void RemoveEventCallback(uint in_playingID)
{
var cookiesToRemove = new System.Collections.Generic.List<int>();
foreach (var pair in m_mapEventCallbacks)
{
if (pair.Value.m_playingID == in_playingID)
{
cookiesToRemove.Add(pair.Key);
break;
}
}
var Count = cookiesToRemove.Count;
for (var ii = 0; ii < Count; ++ii)
m_mapEventCallbacks.Remove(cookiesToRemove[ii]);
AkSoundEnginePINVOKE.CSharp_CancelEventCallback(in_playingID);
}
public static void RemoveEventCallbackCookie(object in_cookie)
{
var cookiesToRemove = new System.Collections.Generic.List<int>();
foreach (var pair in m_mapEventCallbacks)
{
if (pair.Value.m_Cookie == in_cookie)
cookiesToRemove.Add(pair.Key);
}
var Count = cookiesToRemove.Count;
for (var ii = 0; ii < Count; ++ii)
{
var toRemove = cookiesToRemove[ii];
m_mapEventCallbacks.Remove(toRemove);
AkSoundEnginePINVOKE.CSharp_CancelEventCallbackCookie((System.IntPtr) toRemove);
}
}
public static void RemoveBankCallback(object in_cookie)
{
var cookiesToRemove = new System.Collections.Generic.List<int>();
foreach (var pair in m_mapBankCallbacks)
{
if (pair.Value.m_Cookie == in_cookie)
cookiesToRemove.Add(pair.Key);
}
var Count = cookiesToRemove.Count;
for (var ii = 0; ii < Count; ++ii)
{
var toRemove = cookiesToRemove[ii];
m_mapBankCallbacks.Remove(toRemove);
AkSoundEnginePINVOKE.CSharp_CancelBankCallbackCookie((System.IntPtr) toRemove);
}
}
public static void SetLastAddedPlayingID(uint in_playingID)
{
if (m_LastAddedEventPackage != null && m_LastAddedEventPackage.m_playingID == 0)
m_LastAddedEventPackage.m_playingID = in_playingID;
}
private static System.IntPtr m_pNotifMem = System.IntPtr.Zero;
private static MonitoringCallback m_MonitoringCB;
#if UNITY_IOS && !UNITY_EDITOR
public delegate AKRESULT AudioInterruptionCallback(bool in_bEnterInterruption, object in_Cookie);
// App implements its own callback.
private static AudioInterruptionCallbackPackage ms_interruptCallbackPkg = null;
public class AudioInterruptionCallbackPackage
{
public object m_Cookie;
public AudioInterruptionCallback m_Callback;
}
#endif // #if UNITY_IOS && ! UNITY_EDITOR
public delegate AKRESULT BGMCallback(bool in_bOtherAudioPlaying, object in_Cookie);
// App implements its own callback.
private static BGMCallbackPackage ms_sourceChangeCallbackPkg;
public class BGMCallbackPackage
{
public BGMCallback m_Callback;
public object m_Cookie;
}
public class InitializationSettings
{
public static int DefaultBufferSize = 4 * 1024;
public static bool DefaultIsLoggingEnabled = true;
public int BufferSize = DefaultBufferSize;
public bool IsLoggingEnabled = DefaultIsLoggingEnabled;
}
public static AKRESULT Init(InitializationSettings settings)
{
IsLoggingEnabled = settings.IsLoggingEnabled;
m_pNotifMem = settings.BufferSize > 0 ? System.Runtime.InteropServices.Marshal.AllocHGlobal(settings.BufferSize) : System.IntPtr.Zero;
#if UNITY_EDITOR
AkCallbackSerializer.SetLocalOutput((uint) AkMonitorErrorLevel.ErrorLevel_All);
#endif
return AkCallbackSerializer.Init(m_pNotifMem, (uint)settings.BufferSize);
}
public static void Term()
{
if (m_pNotifMem != System.IntPtr.Zero)
{
AkCallbackSerializer.Term();
System.Runtime.InteropServices.Marshal.FreeHGlobal(m_pNotifMem);
m_pNotifMem = System.IntPtr.Zero;
}
}
/// Call this to set a function to call whenever Wwise prints a message (warnings or errors).
public static void SetMonitoringCallback(AkMonitorErrorLevel in_Level, MonitoringCallback in_CB)
{
AkCallbackSerializer.SetLocalOutput(in_CB != null ? (uint) in_Level : 0);
m_MonitoringCB = in_CB;
}
#if UNITY_IOS && !UNITY_EDITOR
/// Call this function to set a iOS callback interruption function. By default this callback is not defined.
public static void SetInterruptionCallback(AudioInterruptionCallback in_CB, object in_cookie)
{
ms_interruptCallbackPkg = new AudioInterruptionCallbackPackage { m_Callback = in_CB, m_Cookie = in_cookie };
}
#endif // #if UNITY_IOS && ! UNITY_EDITOR
/// Call this to set a background music callback function. By default this callback is not defined.
public static void SetBGMCallback(BGMCallback in_CB, object in_cookie)
{
ms_sourceChangeCallbackPkg = new BGMCallbackPackage { m_Callback = in_CB, m_Cookie = in_cookie };
}
/// This function dispatches all the accumulated callbacks from the native sound engine.
/// It must be called regularly. By default this is called in AkInitializer.cs.
public static int PostCallbacks()
{
if (m_pNotifMem == System.IntPtr.Zero)
return 0;
try
{
var numCallbacks = 0;
for (var pNext = AkCallbackSerializer.Lock();
pNext != System.IntPtr.Zero;
pNext = AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_pNext_get(pNext), ++numCallbacks)
{
var pPackage = AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_pPackage_get(pNext);
var eType = (AkCallbackType) AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_eType_get(pNext);
var pData = AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_GetData(pNext);
switch (eType)
{
case AkCallbackType.AK_AudioInterruption:
#if UNITY_IOS && !UNITY_EDITOR
if (ms_interruptCallbackPkg != null && ms_interruptCallbackPkg.m_Callback != null)
{
AkAudioInterruptionCallbackInfo.setCPtr(pData);
ms_interruptCallbackPkg.m_Callback(AkAudioInterruptionCallbackInfo.bEnterInterruption, ms_interruptCallbackPkg.m_Cookie);
}
#endif // #if UNITY_IOS && ! UNITY_EDITOR
break;
case AkCallbackType.AK_AudioSourceChange:
if (ms_sourceChangeCallbackPkg != null && ms_sourceChangeCallbackPkg.m_Callback != null)
{
AkAudioSourceChangeCallbackInfo.setCPtr(pData);
ms_sourceChangeCallbackPkg.m_Callback(AkAudioSourceChangeCallbackInfo.bOtherAudioPlaying,
ms_sourceChangeCallbackPkg.m_Cookie);
}
break;
case AkCallbackType.AK_Monitoring:
if (m_MonitoringCB != null)
{
AkMonitoringCallbackInfo.setCPtr(pData);
m_MonitoringCB(AkMonitoringCallbackInfo.errorCode, AkMonitoringCallbackInfo.errorLevel,
AkMonitoringCallbackInfo.playingID, AkMonitoringCallbackInfo.gameObjID, AkMonitoringCallbackInfo.message);
}
#if UNITY_EDITOR
else if (IsLoggingEnabled)
{
AkMonitoringCallbackInfo.setCPtr(pData);
var msg = "Wwise: " + AkMonitoringCallbackInfo.message;
if (AkMonitoringCallbackInfo.gameObjID != AkSoundEngine.AK_INVALID_GAME_OBJECT)
{
var obj =
UnityEditor.EditorUtility.InstanceIDToObject((int) AkMonitoringCallbackInfo.gameObjID) as
UnityEngine.GameObject;
if (obj != null)
msg += " (GameObject: " + obj + ")";
msg += " (Instance ID: " + AkMonitoringCallbackInfo.gameObjID + ")";
}
if (AkMonitoringCallbackInfo.errorLevel == AkMonitorErrorLevel.ErrorLevel_Error)
UnityEngine.Debug.LogError(msg);
else
UnityEngine.Debug.Log(msg);
}
#endif
break;
case AkCallbackType.AK_Bank:
BankCallbackPackage bankPkg = null;
if (!m_mapBankCallbacks.TryGetValue((int) pPackage, out bankPkg))
{
UnityEngine.Debug.LogError("WwiseUnity: BankCallbackPackage not found for <" + pPackage + ">.");
return numCallbacks;
}
else
{
m_mapBankCallbacks.Remove((int) pPackage);
if (bankPkg != null && bankPkg.m_Callback != null)
{
AkBankCallbackInfo.setCPtr(pData);
bankPkg.m_Callback(AkBankCallbackInfo.bankID, AkBankCallbackInfo.inMemoryBankPtr, AkBankCallbackInfo.loadResult, bankPkg.m_Cookie);
}
}
break;
default:
EventCallbackPackage eventPkg = null;
if (!m_mapEventCallbacks.TryGetValue((int) pPackage, out eventPkg))
{
UnityEngine.Debug.LogError("WwiseUnity: EventCallbackPackage not found for <" + pPackage + ">.");
return numCallbacks;
}
else
{
AkCallbackInfo info = null;
switch (eType)
{
case AkCallbackType.AK_EndOfEvent:
m_mapEventCallbacks.Remove(eventPkg.GetHashCode());
if (eventPkg.m_bNotifyEndOfEvent)
{
AkEventCallbackInfo.setCPtr(pData);
info = AkEventCallbackInfo;
}
break;
case AkCallbackType.AK_MusicPlayStarted:
AkEventCallbackInfo.setCPtr(pData);
info = AkEventCallbackInfo;
break;
case AkCallbackType.AK_EndOfDynamicSequenceItem:
AkDynamicSequenceItemCallbackInfo.setCPtr(pData);
info = AkDynamicSequenceItemCallbackInfo;
break;
case AkCallbackType.AK_MIDIEvent:
AkMIDIEventCallbackInfo.setCPtr(pData);
info = AkMIDIEventCallbackInfo;
break;
case AkCallbackType.AK_Marker:
AkMarkerCallbackInfo.setCPtr(pData);
info = AkMarkerCallbackInfo;
break;
case AkCallbackType.AK_Duration:
AkDurationCallbackInfo.setCPtr(pData);
info = AkDurationCallbackInfo;
break;
case AkCallbackType.AK_MusicSyncUserCue:
case AkCallbackType.AK_MusicSyncBar:
case AkCallbackType.AK_MusicSyncBeat:
case AkCallbackType.AK_MusicSyncEntry:
case AkCallbackType.AK_MusicSyncExit:
case AkCallbackType.AK_MusicSyncGrid:
case AkCallbackType.AK_MusicSyncPoint:
AkMusicSyncCallbackInfo.setCPtr(pData);
info = AkMusicSyncCallbackInfo;
break;
case AkCallbackType.AK_MusicPlaylistSelect:
AkMusicPlaylistCallbackInfo.setCPtr(pData);
info = AkMusicPlaylistCallbackInfo;
break;
default:
UnityEngine.Debug.LogError("WwiseUnity: PostCallbacks aborted due to error: Undefined callback type <" +
eType + "> found. Callback object possibly corrupted.");
return numCallbacks;
}
if (info != null)
eventPkg.m_Callback(eventPkg.m_Cookie, eType, info);
}
break;
}
}
return numCallbacks;
}
finally
{
AkCallbackSerializer.Unlock();
}
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 57be8ec87a89d504ebd26055ce593f6a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,630 @@
public class AkBasePlatformSettings : UnityEngine.ScriptableObject
{
public virtual AkInitializationSettings AkInitializationSettings
{
get { return new AkInitializationSettings(); }
}
public virtual AkSpatialAudioInitSettings AkSpatialAudioInitSettings
{
get { return new AkSpatialAudioInitSettings(); }
}
public virtual AkCallbackManager.InitializationSettings CallbackManagerInitializationSettings
{
get { return new AkCallbackManager.InitializationSettings(); }
}
public virtual string SoundBankPersistentDataPath
{
get { return null; }
}
public virtual string InitialLanguage
{
get { return "English(US)"; }
}
public virtual bool RenderDuringFocusLoss
{
get { return false; }
}
public virtual string SoundbankPath
{
get { return AkBasePathGetter.DefaultBasePath; }
}
public virtual AkCommunicationSettings AkCommunicationSettings
{
get { return new AkCommunicationSettings(); }
}
public virtual bool UseAsyncOpen
{
get { return false; }
}
}
[System.Serializable]
public class AkCommonOutputSettings
{
[UnityEngine.Tooltip("The name of a custom audio device to be used. Custom audio devices are defined in the Audio Device Shareset section of the Wwise project. Leave this empty to output normally through the default audio device.")]
public string m_AudioDeviceShareset = string.Empty;
[UnityEngine.Tooltip("Device specific identifier, when multiple devices of the same type are possible. If only one device is possible, leave to 0.")]
public uint m_DeviceID = AkSoundEngine.AK_INVALID_UNIQUE_ID;
public enum PanningRule
{
Speakers = 0,
Headphones = 1
}
[UnityEngine.Tooltip("Rule for 3D panning of signals routed to a stereo bus. In \"Speakers\" mode, the angle of the front loudspeakers is used. In \"Headphones\" mode, the speaker angles are superseded with constant power panning between two virtual microphones spaced 180 degrees apart.")]
public PanningRule m_PanningRule = PanningRule.Speakers;
[System.Serializable]
public class ChannelConfiguration
{
public enum ChannelConfigType
{
Anonymous = 0x0,
Standard = 0x1,
Ambisonic = 0x2
}
[UnityEngine.Tooltip("A code that completes the identification of channels by uChannelMask. Anonymous: Channel mask == 0 and channels; Standard: Channels must be identified with standard defines in AkSpeakerConfigs; Ambisonic: Channel mask == 0 and channels follow standard ambisonic order.")]
public ChannelConfigType m_ChannelConfigType = ChannelConfigType.Anonymous;
public enum ChannelMask
{
NONE = 0x0,
/// Standard speakers (channel mask):
FRONT_LEFT = 0x1, ///< Front left speaker bit mask
FRONT_RIGHT = 0x2, ///< Front right speaker bit mask
FRONT_CENTER = 0x4, ///< Front center speaker bit mask
LOW_FREQUENCY = 0x8, ///< Low-frequency speaker bit mask
BACK_LEFT = 0x10, ///< Rear left speaker bit mask
BACK_RIGHT = 0x20, ///< Rear right speaker bit mask
BACK_CENTER = 0x100, ///< Rear center speaker ("surround speaker") bit mask
SIDE_LEFT = 0x200, ///< Side left speaker bit mask
SIDE_RIGHT = 0x400, ///< Side right speaker bit mask
/// "Height" speakers.
TOP = 0x800, ///< Top speaker bit mask
HEIGHT_FRONT_LEFT = 0x1000, ///< Front left speaker bit mask
HEIGHT_FRONT_CENTER = 0x2000, ///< Front center speaker bit mask
HEIGHT_FRONT_RIGHT = 0x4000, ///< Front right speaker bit mask
HEIGHT_BACK_LEFT = 0x8000, ///< Rear left speaker bit mask
HEIGHT_BACK_CENTER = 0x10000, ///< Rear center speaker bit mask
HEIGHT_BACK_RIGHT = 0x20000, ///< Rear right speaker bit mask
//
// Supported speaker setups. Those are the ones that can be used in the Wwise Sound Engine audio pipeline.
//
SETUP_MONO = FRONT_CENTER, ///< 1.0 setup channel mask
SETUP_0POINT1 = LOW_FREQUENCY, ///< 0.1 setup channel mask
SETUP_1POINT1 = (FRONT_CENTER | LOW_FREQUENCY), ///< 1.1 setup channel mask
SETUP_STEREO = (FRONT_LEFT | FRONT_RIGHT), ///< 2.0 setup channel mask
SETUP_2POINT1 = (SETUP_STEREO | LOW_FREQUENCY), ///< 2.1 setup channel mask
SETUP_3STEREO = (SETUP_STEREO | FRONT_CENTER), ///< 3.0 setup channel mask
SETUP_3POINT1 = (SETUP_3STEREO | LOW_FREQUENCY), ///< 3.1 setup channel mask
SETUP_4 = (SETUP_STEREO | SIDE_LEFT | SIDE_RIGHT), ///< 4.0 setup channel mask
SETUP_4POINT1 = (SETUP_4 | LOW_FREQUENCY), ///< 4.1 setup channel mask
SETUP_5 = (SETUP_4 | FRONT_CENTER), ///< 5.0 setup channel mask
SETUP_5POINT1 = (SETUP_5 | LOW_FREQUENCY), ///< 5.1 setup channel mask
SETUP_6 = (SETUP_4 | BACK_LEFT | BACK_RIGHT), ///< 6.0 setup channel mask
SETUP_6POINT1 = (SETUP_6 | LOW_FREQUENCY), ///< 6.1 setup channel mask
SETUP_7 = (SETUP_6 | FRONT_CENTER), ///< 7.0 setup channel mask
SETUP_7POINT1 = (SETUP_7 | LOW_FREQUENCY), ///< 7.1 setup channel mask
SETUP_SURROUND = (SETUP_STEREO | BACK_CENTER), ///< Legacy surround setup channel mask
// Note. DPL2 does not really have 4 channels, but it is used by plugins to differentiate from stereo setup.
SETUP_DPL2 = (SETUP_4), ///< Legacy DPL2 setup channel mask
SETUP_HEIGHT_4 = (HEIGHT_FRONT_LEFT | HEIGHT_FRONT_RIGHT | HEIGHT_BACK_LEFT | HEIGHT_BACK_RIGHT), ///< 4 speaker height layer.
SETUP_HEIGHT_5 = (SETUP_HEIGHT_4 | HEIGHT_FRONT_CENTER), ///< 5 speaker height layer.
SETUP_HEIGHT_ALL = (SETUP_HEIGHT_5 | HEIGHT_BACK_CENTER), ///< All height speaker layer.
// Auro speaker setups
SETUP_AURO_222 = (SETUP_4 | HEIGHT_FRONT_LEFT | HEIGHT_FRONT_RIGHT), ///< Auro-222 setup channel mask
SETUP_AURO_8 = (SETUP_AURO_222 | HEIGHT_BACK_LEFT | HEIGHT_BACK_RIGHT), ///< Auro-8 setup channel mask
SETUP_AURO_9 = (SETUP_AURO_8 | FRONT_CENTER), ///< Auro-9.0 setup channel mask
SETUP_AURO_9POINT1 = (SETUP_AURO_9 | LOW_FREQUENCY), ///< Auro-9.1 setup channel mask
SETUP_AURO_10 = (SETUP_AURO_9 | TOP), ///< Auro-10.0 setup channel mask
SETUP_AURO_10POINT1 = (SETUP_AURO_10 | LOW_FREQUENCY), ///< Auro-10.1 setup channel mask
SETUP_AURO_11 = (SETUP_AURO_10 | HEIGHT_FRONT_CENTER), ///< Auro-11.0 setup channel mask
SETUP_AURO_11POINT1 = (SETUP_AURO_11 | LOW_FREQUENCY), ///< Auro-11.1 setup channel mask
SETUP_AURO_11_740 = (SETUP_7 | SETUP_HEIGHT_4), ///< Auro-11.0 (7+4) setup channel mask
SETUP_AURO_11POINT1_740 = (SETUP_AURO_11_740 | LOW_FREQUENCY), ///< Auro-11.1 (7+4) setup channel mask
SETUP_AURO_13_751 = (SETUP_7 | SETUP_HEIGHT_5 | TOP), ///< Auro-13.0 setup channel mask
SETUP_AURO_13POINT1_751 = (SETUP_AURO_13_751 | LOW_FREQUENCY), ///< Auro-13.1 setup channel mask
// Dolby speaker setups: in Dolby nomenclature, [#plane].[lfe].[#height]
SETUP_DOLBY_5_0_2 = (SETUP_5 | HEIGHT_FRONT_LEFT | HEIGHT_FRONT_RIGHT), ///< Dolby 5.0.2 setup channel mask
SETUP_DOLBY_5_1_2 = (SETUP_DOLBY_5_0_2 | LOW_FREQUENCY), ///< Dolby 5.1.2 setup channel mask
SETUP_DOLBY_6_0_2 = (SETUP_6 | HEIGHT_FRONT_LEFT | HEIGHT_FRONT_RIGHT), ///< Dolby 6.0.2 setup channel mask
SETUP_DOLBY_6_1_2 = (SETUP_DOLBY_6_0_2 | LOW_FREQUENCY), ///< Dolby 6.1.2 setup channel mask
SETUP_DOLBY_6_0_4 = (SETUP_DOLBY_6_0_2 | HEIGHT_BACK_LEFT | HEIGHT_BACK_RIGHT), ///< Dolby 6.0.4 setup channel mask
SETUP_DOLBY_6_1_4 = (SETUP_DOLBY_6_0_4 | LOW_FREQUENCY), ///< Dolby 6.1.4 setup channel mask
SETUP_DOLBY_7_0_2 = (SETUP_7 | HEIGHT_FRONT_LEFT | HEIGHT_FRONT_RIGHT), ///< Dolby 7.0.2 setup channel mask
SETUP_DOLBY_7_1_2 = (SETUP_DOLBY_7_0_2 | LOW_FREQUENCY), ///< Dolby 7.1.2 setup channel mask
SETUP_DOLBY_7_0_4 = (SETUP_DOLBY_7_0_2 | HEIGHT_BACK_LEFT | HEIGHT_BACK_RIGHT), ///< Dolby 7.0.4 setup channel mask
SETUP_DOLBY_7_1_4 = (SETUP_DOLBY_7_0_4 | LOW_FREQUENCY), ///< Dolby 7.1.4 setup channel mask
SETUP_ALL_SPEAKERS = (SETUP_7POINT1 | BACK_CENTER | SETUP_HEIGHT_ALL | TOP), ///< All speakers.
};
[UnityEngine.Tooltip("A bit field, whose channel identifiers depend on AkChannelConfigType (up to 20).")]
[AkEnumFlag(typeof(ChannelMask))]
public ChannelMask m_ChannelMask = ChannelMask.NONE;
[UnityEngine.Tooltip("The number of channels, identified (deduced from channel mask) or anonymous (set directly).")]
public uint m_NumberOfChannels = 0;
public void CopyTo(AkChannelConfig config)
{
switch (m_ChannelConfigType)
{
case ChannelConfigType.Anonymous:
config.SetAnonymous(m_NumberOfChannels);
break;
case ChannelConfigType.Standard:
config.SetStandard((uint)m_ChannelMask);
break;
case ChannelConfigType.Ambisonic:
config.SetAmbisonic(m_NumberOfChannels);
break;
}
}
}
[UnityEngine.Tooltip("Channel configuration for this output. Hardware might not support the selected configuration.")]
public ChannelConfiguration m_ChannelConfig = new ChannelConfiguration();
public void CopyTo(AkOutputSettings settings)
{
settings.audioDeviceShareset = string.IsNullOrEmpty(m_AudioDeviceShareset) ? AkSoundEngine.AK_INVALID_UNIQUE_ID : AkUtilities.ShortIDGenerator.Compute(m_AudioDeviceShareset);
settings.idDevice = m_DeviceID;
settings.ePanningRule = (AkPanningRule)m_PanningRule;
m_ChannelConfig.CopyTo(settings.channelConfig);
}
}
[System.Serializable]
public partial class AkCommonUserSettings
{
[UnityEngine.Tooltip("Path for the SoundBanks. This must contain one sub folder per platform, with the same as in the Wwise project.")]
public string m_BasePath = AkBasePathGetter.DefaultBasePath;
[UnityEngine.Tooltip("Language sub-folder used at startup.")]
public string m_StartupLanguage = "English(US)";
[UnityEngine.Tooltip("Enable Wwise engine logging. This is used to turn on/off the logging of the Wwise engine.")]
public bool m_EngineLogging = AkCallbackManager.InitializationSettings.DefaultIsLoggingEnabled;
[UnityEngine.Tooltip("Maximum number of automation paths for positioning sounds.")]
public uint m_MaximumNumberOfPositioningPaths = 255;
[UnityEngine.Tooltip("Size of the command queue.")]
public uint m_CommandQueueSize = 256 * 1024;
[UnityEngine.Tooltip("Number of samples per audio frame (256, 512, 1024, or 2048).")]
public uint m_SamplesPerFrame = 1024;
[UnityEngine.Tooltip("Main output device settings.")]
public AkCommonOutputSettings m_MainOutputSettings;
protected static string GetPluginPath()
{
#if UNITY_EDITOR_WIN
return System.IO.Path.Combine(UnityEngine.Application.dataPath, @"Wwise\Deployment\Plugins\Windows\x86_64\DSP");
#elif UNITY_EDITOR_OSX
return System.IO.Path.Combine(UnityEngine.Application.dataPath, @"Wwise/Deployment/Plugins/Mac/DSP");
#elif UNITY_STANDALONE_WIN
string potentialPath = System.IO.Path.Combine(UnityEngine.Application.dataPath, "Plugins" + System.IO.Path.DirectorySeparatorChar);
string architectureName = "x86";
#if UNITY_64
architectureName += "_64";
#endif
if(System.IO.File.Exists(System.IO.Path.Combine(potentialPath, "AkSoundEngine.dll")))
{
return potentialPath;
}
else if(System.IO.File.Exists(System.IO.Path.Combine(potentialPath, architectureName, "AkSoundEngine.dll")))
{
return System.IO.Path.Combine(potentialPath, architectureName);
}
else
{
UnityEngine.Debug.Log("Cannot find Wwise plugin path");
return null;
}
#elif UNITY_ANDROID || UNITY_WSA
return null;
#elif PLATFORM_LUMIN
var dataPath = UnityEngine.Application.dataPath;
var find = "Data";
var index = dataPath.LastIndexOf(find);
return index == -1 ? dataPath : dataPath.Remove(index, find.Length).Insert(index, "bin");
#elif UNITY_STADIA
return System.IO.Path.Combine(UnityEngine.Application.dataPath, ".." + System.IO.Path.DirectorySeparatorChar);
#else
return System.IO.Path.Combine(UnityEngine.Application.dataPath, "Plugins" + System.IO.Path.DirectorySeparatorChar);
#endif
}
public virtual void CopyTo(AkInitSettings settings)
{
settings.uMaxNumPaths = m_MaximumNumberOfPositioningPaths;
settings.uCommandQueueSize = m_CommandQueueSize;
settings.uNumSamplesPerFrame = m_SamplesPerFrame;
m_MainOutputSettings.CopyTo(settings.settingsMainOutput);
settings.szPluginDLLPath = GetPluginPath();
UnityEngine.Debug.Log("WwiseUnity: Setting Plugin DLL path to: " + (settings.szPluginDLLPath == null ? "NULL" : settings.szPluginDLLPath));
}
[UnityEngine.Tooltip("Multiplication factor for all streaming look-ahead heuristic values.")]
[UnityEngine.Range(0, 1)]
public float m_StreamingLookAheadRatio = 1.0f;
public void CopyTo(AkMusicSettings settings)
{
settings.fStreamingLookAheadRatio = m_StreamingLookAheadRatio;
}
public void CopyTo(AkStreamMgrSettings settings)
{
}
public virtual void CopyTo(AkDeviceSettings settings) { }
[UnityEngine.Tooltip("Sampling Rate. Default is 48000 Hz. Use 24000hz for low quality. Any positive reasonable sample rate is supported; however, be careful setting a custom value. Using an odd or really low sample rate may cause the sound engine to malfunction.")]
public uint m_SampleRate = 48000;
[UnityEngine.Tooltip("Number of refill buffers in voice buffer. Set to 2 for double-buffered, defaults to 4.")]
public ushort m_NumberOfRefillsInVoice = 4;
partial void SetSampleRate(AkPlatformInitSettings settings);
public virtual void CopyTo(AkPlatformInitSettings settings)
{
SetSampleRate(settings);
settings.uNumRefillsInVoice = m_NumberOfRefillsInVoice;
}
[System.Serializable]
public class SpatialAudioSettings
{
[UnityEngine.Tooltip("Maximum number of portals that sound can propagate through.")]
[UnityEngine.Range(0, AkSoundEngine.AK_MAX_SOUND_PROPAGATION_DEPTH)]
public uint m_MaxSoundPropagationDepth = AkSoundEngine.AK_MAX_SOUND_PROPAGATION_DEPTH;
public enum DiffractionFlags
{
UseBuiltInParam = 1 << 0,
UseObstruction = 1 << 1,
CalcEmitterVirtualPosition = 1 << 3,
}
[UnityEngine.Tooltip("Determines whether diffraction values for sound passing through portals will be calculated, and how to apply those calculations to Wwise parameters.")]
[AkEnumFlag(typeof(DiffractionFlags))]
public DiffractionFlags m_DiffractionFlags = (DiffractionFlags)~0;
[UnityEngine.Tooltip("Distance (in game units) that an emitter or listener has to move to trigger a recalculation of reflections/diffraction. Larger values can reduce the CPU load at the cost of reduced accuracy.")]
public float m_MovementThreshold = 1.0f;
[UnityEngine.Tooltip("The number of primary rays used in stochastic ray casting.")]
/// The number of primary rays used in stochastic ray casting.
public uint m_NumberOfPrimaryRays = 100;
[UnityEngine.Range(0, 4)]
[UnityEngine.Tooltip("The maximum number of reflections that will be processed for a sound path before it reaches the listener.")]
[UnityEngine.Serialization.FormerlySerializedAs("m_ReflectionsOrder")]
/// The maximum number of reflections that will be processed for a sound path before it reaches the listener.
/// Valid range: 1-4.
public uint m_MaxReflectionOrder = 1;
[UnityEngine.Tooltip("Length of the rays that are cast inside Spatial Audio. Effectively caps the maximum length of an individual segment in a reflection or diffraction path.")]
/// Length of the rays that are cast inside Spatial Audio. Effectively caps the maximum length of an individual segment in a reflection or diffraction path.
public float m_MaxPathLength = 10000.0f;
[UnityEngine.Tooltip("Enable computation of diffraction along reflection paths.")]
[UnityEngine.Serialization.FormerlySerializedAs("m_EnableDiffraction")]
/// Enable computation of diffraction along reflection paths.
public bool m_EnableDiffractionOnReflections = true;
[UnityEngine.Tooltip("Enable direct path diffraction. Diffraction must be enabled for a source in the authoring tool positioning tab.")]
/// Enable direct path diffraction.
public bool m_EnableDirectPathDiffraction = true;
[UnityEngine.Tooltip("Enable modeling of transmission of sound through walls.")]
/// Enable modeling of transmission of sound through walls.
public bool m_EnableTransmission = true;
}
[UnityEngine.Tooltip("Spatial audio common settings.")]
public SpatialAudioSettings m_SpatialAudioSettings;
public virtual void CopyTo(AkSpatialAudioInitSettings settings)
{
settings.uMaxSoundPropagationDepth = m_SpatialAudioSettings.m_MaxSoundPropagationDepth;
settings.uDiffractionFlags = (uint)m_SpatialAudioSettings.m_DiffractionFlags;
settings.fMovementThreshold = m_SpatialAudioSettings.m_MovementThreshold;
settings.uNumberOfPrimaryRays = m_SpatialAudioSettings.m_NumberOfPrimaryRays;
settings.uMaxReflectionOrder = m_SpatialAudioSettings.m_MaxReflectionOrder;
settings.fMaxPathLength = m_SpatialAudioSettings.m_MaxPathLength;
settings.bEnableDiffractionOnReflection = m_SpatialAudioSettings.m_EnableDiffractionOnReflections;
settings.bEnableDirectPathDiffraction = m_SpatialAudioSettings.m_EnableDirectPathDiffraction;
settings.bEnableTransmission = m_SpatialAudioSettings.m_EnableTransmission;
}
public virtual void CopyTo(AkUnityPlatformSpecificSettings settings) { }
public virtual void Validate()
{
if (m_SpatialAudioSettings.m_MovementThreshold < 0.0f)
{
m_SpatialAudioSettings.m_MovementThreshold = 0.0f;
}
if (m_SpatialAudioSettings.m_MaxPathLength < 0.0f)
{
m_SpatialAudioSettings.m_MaxPathLength = 0.0f;
}
}
}
[System.Serializable]
public class AkCommonAdvancedSettings
{
[UnityEngine.Tooltip("Size of memory pool for I/O (for automatic streams). It is passed directly to AK::MemoryMgr::CreatePool(), after having been rounded down to a multiple of uGranularity.")]
public uint m_IOMemorySize = 2 * 1024 * 1024;
[UnityEngine.Tooltip("Targeted automatic stream buffer length (ms). When a stream reaches that buffering, it stops being scheduled for I/O except if the scheduler is idle.")]
public float m_TargetAutoStreamBufferLengthMs = 380.0f;
[UnityEngine.Tooltip("If true the device attempts to reuse IO buffers that have already been streamed from disk. This is particularly useful when streaming small looping sounds. The drawback is a small CPU hit when allocating memory, and a slightly larger memory footprint in the StreamManager pool.")]
public bool m_UseStreamCache = false;
[UnityEngine.Tooltip("Maximum number of bytes that can be \"pinned\" using AK::SoundEngine::PinEventInStreamCache() or AK::IAkStreamMgr::PinFileInCache()")]
public uint m_MaximumPinnedBytesInCache = unchecked((uint)(-1));
public virtual void CopyTo(AkDeviceSettings settings)
{
settings.uIOMemorySize = m_IOMemorySize;
settings.fTargetAutoStmBufferLength = m_TargetAutoStreamBufferLengthMs;
settings.bUseStreamCache = m_UseStreamCache;
settings.uMaxCachePinnedBytes = m_MaximumPinnedBytesInCache;
}
[UnityEngine.Tooltip("Set to true to enable AK::SoundEngine::PrepareGameSync usage.")]
public bool m_EnableGameSyncPreparation = false;
[UnityEngine.Tooltip("Number of quanta ahead when continuous containers should instantiate a new voice before which next sounds should start playing. This look-ahead time allows I/O to occur, and is especially useful to reduce the latency of continuous containers with trigger rate or sample-accurate transitions.")]
public uint m_ContinuousPlaybackLookAhead = 1;
[UnityEngine.Tooltip("Size of the monitoring queue pool. This parameter is not used in Release build.")]
public uint m_MonitorQueuePoolSize = 64 * 1024;
[UnityEngine.Tooltip("Amount of time to wait for hardware devices to trigger an audio interrupt. If there is no interrupt after that time, the sound engine will revert to silent mode and continue operating until the hardware finally comes back.")]
public uint m_MaximumHardwareTimeoutMs = 1000;
[UnityEngine.Tooltip("Debug setting: Enable checks for out-of-range (and NAN) floats in the processing code. Do not enable in any normal usage, this setting uses a lot of CPU. Will print error messages in the log if invalid values are found at various point in the pipeline. Contact AK Support with the new error messages for more information.")]
public bool m_DebugOutOfRangeCheckEnabled = false;
[UnityEngine.Tooltip("Debug setting: Only used when bDebugOutOfRangeCheckEnabled is true. This defines the maximum values samples can have. Normal audio must be contained within +1/-1. This limit should be set higher to allow temporary or short excursions out of range. Default is 16.")]
public float m_DebugOutOfRangeLimit = 16.0f;
public virtual void CopyTo(AkInitSettings settings)
{
settings.bEnableGameSyncPreparation = m_EnableGameSyncPreparation;
settings.uContinuousPlaybackLookAhead = m_ContinuousPlaybackLookAhead;
settings.uMonitorQueuePoolSize = m_MonitorQueuePoolSize;
settings.uMaxHardwareTimeoutMs = m_MaximumHardwareTimeoutMs;
settings.bDebugOutOfRangeCheckEnabled = m_DebugOutOfRangeCheckEnabled;
settings.fDebugOutOfRangeLimit = m_DebugOutOfRangeLimit;
}
public virtual void CopyTo(AkPlatformInitSettings settings) { }
[System.Serializable]
public class SpatialAudioSettings
{
[UnityEngine.Tooltip("Multiplier that is applied to the distance attenuation of diffracted sounds (sounds that are in the 'shadow region') to simulate the phenomenon where by diffracted sound waves decay faster than incident sound waves.")]
[UnityEngine.Range(1.0f, 3.0f)]
public float m_DiffractionShadowAttenuationFactor = 1.0f;
[UnityEngine.Tooltip("Interpolation angle, in degrees, over which the \"Diffraction Shadow Attenuation Factor\" is applied.")]
[UnityEngine.Range(0.1f, 180.0f)]
public float m_DiffractionShadowDegrees = 30.0f;
}
[UnityEngine.Tooltip("Spatial audio advanced settings.")]
public SpatialAudioSettings m_SpatialAudioSettings;
public virtual void CopyTo(AkSpatialAudioInitSettings settings)
{
settings.fDiffractionShadowAttenFactor = m_SpatialAudioSettings.m_DiffractionShadowAttenuationFactor;
settings.fDiffractionShadowDegrees = m_SpatialAudioSettings.m_DiffractionShadowDegrees;
}
public virtual void CopyTo(AkUnityPlatformSpecificSettings settings) { }
[UnityEngine.Tooltip("The state of the \"in_bRenderAnyway\" argument passed to the AkSoundEngine.Suspend() function when the \"OnApplicationFocus\" Unity callback is received with \"false\" as its argument.")]
public bool m_RenderDuringFocusLoss;
[UnityEngine.Tooltip("Sets the sub-folder underneath UnityEngine.Application.persistentDataPath that will be used as the SoundBank base path. This is useful when the Init.bnk needs to be downloaded. Setting this to an empty string uses the typical SoundBank base path resolution. Setting this to \".\" uses UnityEngine.Application.persistentDataPath.")]
public string m_SoundBankPersistentDataPath;
[UnityEngine.Tooltip("Use Async Open in the low-level IO hook.")]
public bool m_UseAsyncOpen = false;
public virtual void Validate()
{
if (m_SpatialAudioSettings.m_DiffractionShadowAttenuationFactor <= 0.0f)
{
UnityEngine.Debug.LogWarning("WwiseUnity: m_SpatialAudioSettings.m_DiffractionShadowAttenuationFactor must be greater than zero. Value was reset to the default (2.0)");
m_SpatialAudioSettings.m_DiffractionShadowAttenuationFactor = 1.0f;
}
if (m_SpatialAudioSettings.m_DiffractionShadowDegrees <= 0.0f)
{
UnityEngine.Debug.LogWarning("WwiseUnity: m_SpatialAudioSettings.m_DiffractionShadowDegrees must be greater than zero. Value was reset to the default (30.0)");
m_SpatialAudioSettings.m_DiffractionShadowDegrees = 30.0f;
}
}
}
[System.Serializable]
public class AkCommonCommSettings
{
[UnityEngine.Tooltip("Size of the communication pool.")]
public uint m_PoolSize = 256 * 1024;
public static ushort DefaultDiscoveryBroadcastPort = 24024;
[UnityEngine.Tooltip("The port where the authoring application broadcasts \"Game Discovery\" requests to discover games running on the network. Default value: 24024. (Cannot be set to 0)")]
public ushort m_DiscoveryBroadcastPort = DefaultDiscoveryBroadcastPort;
[UnityEngine.Tooltip("The \"command\" channel port. Set to 0 to request a dynamic/ephemeral port.")]
public ushort m_CommandPort;
[UnityEngine.Tooltip("The \"notification\" channel port. Set to 0 to request a dynamic/ephemeral port.")]
public ushort m_NotificationPort;
[UnityEngine.Tooltip("Indicates whether the communication system should be initialized. Some consoles have critical requirements for initialization of their communications system. Set to false only if your game already uses sockets before sound engine initialization.")]
public bool m_InitializeSystemComms = true;
[UnityEngine.Tooltip("The name used to identify this game within the authoring application. Leave empty to use \"UnityEngine.Application.productName\".")]
public string m_NetworkName;
[UnityEngine.Tooltip("HTCS communication can only be used with a Nintendo Switch Development Build")]
public AkCommunicationSettings.AkCommSystem m_commSystem = AkCommunicationSettings.AkCommSystem.AkCommSystem_Socket;
public virtual void CopyTo(AkCommunicationSettings settings)
{
settings.uPoolSize = m_PoolSize;
settings.uDiscoveryBroadcastPort = m_DiscoveryBroadcastPort;
settings.uCommandPort = m_CommandPort;
settings.uNotificationPort = m_NotificationPort;
settings.bInitSystemLib = m_InitializeSystemComms;
settings.commSystem = m_commSystem;
string networkName = m_NetworkName;
if (string.IsNullOrEmpty(networkName))
networkName = UnityEngine.Application.productName;
#if UNITY_EDITOR
networkName += " (Editor)";
#endif
settings.szAppNetworkName = networkName;
}
public virtual void Validate() { }
}
public abstract class AkCommonPlatformSettings : AkBasePlatformSettings
{
protected abstract AkCommonUserSettings GetUserSettings();
protected abstract AkCommonAdvancedSettings GetAdvancedSettings();
protected abstract AkCommonCommSettings GetCommsSettings();
public override AkInitializationSettings AkInitializationSettings
{
get
{
var settings = base.AkInitializationSettings;
var userSettings = GetUserSettings();
userSettings.CopyTo(settings.deviceSettings);
userSettings.CopyTo(settings.streamMgrSettings);
userSettings.CopyTo(settings.initSettings);
userSettings.CopyTo(settings.platformSettings);
userSettings.CopyTo(settings.musicSettings);
userSettings.CopyTo(settings.unityPlatformSpecificSettings);
var advancedSettings = GetAdvancedSettings();
advancedSettings.CopyTo(settings.deviceSettings);
advancedSettings.CopyTo(settings.initSettings);
advancedSettings.CopyTo(settings.platformSettings);
advancedSettings.CopyTo(settings.unityPlatformSpecificSettings);
settings.useAsyncOpen = advancedSettings.m_UseAsyncOpen;
return settings;
}
}
public override AkSpatialAudioInitSettings AkSpatialAudioInitSettings
{
get
{
var settings = base.AkSpatialAudioInitSettings;
GetUserSettings().CopyTo(settings);
GetAdvancedSettings().CopyTo(settings);
return settings;
}
}
public override AkCallbackManager.InitializationSettings CallbackManagerInitializationSettings
{
get
{
return new AkCallbackManager.InitializationSettings { IsLoggingEnabled = GetUserSettings().m_EngineLogging };
}
}
public override string InitialLanguage
{
get { return GetUserSettings().m_StartupLanguage; }
}
public override string SoundBankPersistentDataPath
{
get { return GetAdvancedSettings().m_SoundBankPersistentDataPath; }
}
public override bool RenderDuringFocusLoss
{
get { return GetAdvancedSettings().m_RenderDuringFocusLoss; }
}
public override string SoundbankPath
{
get { return GetUserSettings().m_BasePath; }
}
public override bool UseAsyncOpen
{
get { return GetAdvancedSettings().m_UseAsyncOpen; }
}
public override AkCommunicationSettings AkCommunicationSettings
{
get
{
var settings = base.AkCommunicationSettings;
GetCommsSettings().CopyTo(settings);
return settings;
}
}
#region parameter validation
#if UNITY_EDITOR
void OnValidate()
{
GetUserSettings().Validate();
GetAdvancedSettings().Validate();
GetCommsSettings().Validate();
}
#endif
#endregion
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: def3896dc7e1e2740997389b0157b447
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,24 @@
[System.AttributeUsage(System.AttributeTargets.Field, Inherited = true)]
public class AkEnumFlagAttribute : UnityEngine.PropertyAttribute
{
public System.Type Type;
public AkEnumFlagAttribute(System.Type type)
{
Type = type;
}
#if UNITY_EDITOR
[UnityEditor.CustomPropertyDrawer(typeof(AkEnumFlagAttribute))]
public class PropertyDrawer : UnityEditor.PropertyDrawer
{
public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
{
UnityEditor.EditorGUI.BeginProperty(position, label, property);
var flagAttribute = (AkEnumFlagAttribute)attribute;
property.longValue = UnityEditor.EditorGUI.EnumFlagsField(position, new UnityEngine.GUIContent(label.text, AkUtilities.GetTooltip(property)), (System.Enum)System.Enum.ToObject(flagAttribute.Type, property.longValue)).GetHashCode();
UnityEditor.EditorGUI.EndProperty();
}
}
#endif
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e8fb86fce0896964ea74043208ef2552
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,67 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2017 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
public class AkLogger
{
// @todo sjl: Have SWIG specify the delegate's signature (possibly in AkSoundEngine) so that we can automatically determine the appropriate string marshaling.
[System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
public delegate void ErrorLoggerInteropDelegate(
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]
string message);
private static AkLogger ms_Instance = new AkLogger();
private ErrorLoggerInteropDelegate errorLoggerDelegate = WwiseInternalLogError;
private AkLogger()
{
if (ms_Instance == null)
{
ms_Instance = this;
AkSoundEngine.SetErrorLogger(errorLoggerDelegate);
}
}
public static AkLogger Instance { get { return ms_Instance; } }
~AkLogger()
{
if (ms_Instance == this)
{
ms_Instance = null;
errorLoggerDelegate = null;
AkSoundEngine.SetErrorLogger();
}
}
public void Init()
{
// used to force instantiation of this singleton
}
[AOT.MonoPInvokeCallback(typeof(ErrorLoggerInteropDelegate))]
public static void WwiseInternalLogError(string message)
{
UnityEngine.Debug.LogErrorFormat("Wwise: {0}", message);
}
public static void Message(string message)
{
UnityEngine.Debug.LogFormat("WwiseUnity: {0}", message);
}
public static void Warning(string message)
{
UnityEngine.Debug.LogWarningFormat("WwiseUnity: {0}", message);
}
public static void Error(string message)
{
UnityEngine.Debug.LogErrorFormat("WwiseUnity: {0}", message);
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0df9150c992261642a97258fcce19236
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,84 @@
#if !(UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2019 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief This manager tracks the AkRoomAwareObjects and the AkRooms in which they enter and exit.
/// @details At the end of the frame, the AkRoomAwareObject is set in the highest priority AkRoom in Spatial Audio.
public static class AkRoomAwareManager
{
private static readonly System.Collections.Generic.HashSet<AkRoomAwareObject> m_RoomAwareObjects =
new System.Collections.Generic.HashSet<AkRoomAwareObject>();
private static readonly System.Collections.Generic.HashSet<AkRoomAwareObject> m_RoomAwareObjectToUpdate =
new System.Collections.Generic.HashSet<AkRoomAwareObject>();
public static void RegisterRoomAwareObject(AkRoomAwareObject roomAwareObject)
{
m_RoomAwareObjects.Add(roomAwareObject);
RegisterRoomAwareObjectForUpdate(roomAwareObject);
}
public static void UnregisterRoomAwareObject(AkRoomAwareObject roomAwareObject)
{
m_RoomAwareObjects.Remove(roomAwareObject);
m_RoomAwareObjectToUpdate.Remove(roomAwareObject);
}
public static void RegisterRoomAwareObjectForUpdate(AkRoomAwareObject roomAwareObject)
{
m_RoomAwareObjectToUpdate.Add(roomAwareObject);
}
public static void ObjectEnteredRoom(UnityEngine.Collider collider, AkRoom room)
{
if (!collider)
return;
ObjectEnteredRoom(AkRoomAwareObject.GetAkRoomAwareObjectFromCollider(collider), room);
}
public static void ObjectEnteredRoom(AkRoomAwareObject roomAwareObject, AkRoom room)
{
if (!roomAwareObject || !room)
return;
var enteredRoom = room.TryEnter(roomAwareObject);
if (enteredRoom)
{
roomAwareObject.EnteredRoom(room);
RegisterRoomAwareObjectForUpdate(roomAwareObject);
}
}
public static void ObjectExitedRoom(UnityEngine.Collider collider, AkRoom room)
{
if (!collider)
return;
ObjectExitedRoom(AkRoomAwareObject.GetAkRoomAwareObjectFromCollider(collider), room);
}
public static void ObjectExitedRoom(AkRoomAwareObject roomAwareObject, AkRoom room)
{
if (!roomAwareObject || !room)
return;
room.Exit(roomAwareObject);
roomAwareObject.ExitedRoom(room);
RegisterRoomAwareObjectForUpdate(roomAwareObject);
}
public static void UpdateRoomAwareObjects()
{
foreach (var roomAwareObject in m_RoomAwareObjectToUpdate)
{
if (m_RoomAwareObjects.Contains(roomAwareObject))
roomAwareObject.SetGameObjectInHighestPriorityActiveAndEnabledRoom();
}
m_RoomAwareObjectToUpdate.Clear();
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d3c52d743bfd79542bb7ecb39d0f02d6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,138 @@
#if !(UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2019 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief This manager tracks AkRoomPortals and the rooms that they connect (front and back room).
/// @details At the end of the frame, the AkRoomPortals which rooms might have changed are updated and sent to Spatial Audio.
public class AkRoomManager
{
private readonly System.Collections.Generic.List<AkRoomPortal> m_Portals =
new System.Collections.Generic.List<AkRoomPortal>();
private readonly System.Collections.Generic.List<AkRoomPortal> m_PortalsToUpdate =
new System.Collections.Generic.List<AkRoomPortal>();
private readonly System.Collections.Generic.List<AkSurfaceReflector> m_Reflectors =
new System.Collections.Generic.List<AkSurfaceReflector>();
private readonly System.Collections.Generic.List<AkSurfaceReflector> m_ReflectorsToUpdate =
new System.Collections.Generic.List<AkSurfaceReflector>();
private static AkRoomManager m_Instance;
public static void Init()
{
if (m_Instance == null)
m_Instance = new AkRoomManager();
}
public static void Terminate()
{
if (m_Instance != null)
m_Instance = null;
}
public static void RegisterPortal(AkRoomPortal portal)
{
if (m_Instance != null)
{
if (!m_Instance.m_Portals.Contains(portal))
{
m_Instance.m_Portals.Add(portal);
}
if (!m_Instance.m_PortalsToUpdate.Contains(portal))
{
m_Instance.m_PortalsToUpdate.Add(portal);
}
}
}
public static void UnregisterPortal(AkRoomPortal portal)
{
if (m_Instance != null)
{
m_Instance.m_Portals.Remove(portal);
m_Instance.m_PortalsToUpdate.Remove(portal);
}
}
public static void RegisterReflector(AkSurfaceReflector reflector)
{
if (m_Instance != null)
{
if (!m_Instance.m_Reflectors.Contains(reflector))
{
m_Instance.m_Reflectors.Add(reflector);
}
if (!m_Instance.m_ReflectorsToUpdate.Contains(reflector))
{
m_Instance.m_ReflectorsToUpdate.Add(reflector);
}
}
}
public static void UnregisterReflector(AkSurfaceReflector reflector)
{
if (m_Instance != null)
{
m_Instance.m_Reflectors.Remove(reflector);
m_Instance.m_ReflectorsToUpdate.Remove(reflector);
}
}
public static void RegisterPortalUpdate(AkRoomPortal portal)
{
if (m_Instance != null)
{
if (m_Instance.m_Portals.Contains(portal) && !m_Instance.m_PortalsToUpdate.Contains(portal))
{
m_Instance.m_PortalsToUpdate.Add(portal);
}
}
}
public static void RegisterRoomUpdate(AkRoom room)
{
if (m_Instance != null)
{
for (var i = 0; i < m_Instance.m_Portals.Count; ++i)
{
var portal = m_Instance.m_Portals[i];
if (!m_Instance.m_PortalsToUpdate.Contains(portal) &&
(room == portal.frontRoom || room == portal.backRoom || portal.Overlaps(room)))
{
m_Instance.m_PortalsToUpdate.Add(portal);
}
}
for (var i = 0; i < m_Instance.m_Reflectors.Count; ++i)
{
var reflector = m_Instance.m_Reflectors[i];
if (!m_Instance.m_ReflectorsToUpdate.Contains(reflector) && (reflector.AssociatedRoom == room))
{
m_Instance.m_ReflectorsToUpdate.Add(reflector);
}
}
}
}
public static void Update()
{
if (m_Instance != null)
{
for (var i = 0; i < m_Instance.m_PortalsToUpdate.Count; ++i)
{
m_Instance.m_PortalsToUpdate[i].UpdateRoomPortal();
}
m_Instance.m_PortalsToUpdate.Clear();
for (var i = 0; i < m_Instance.m_ReflectorsToUpdate.Count; ++i)
{
m_Instance.m_ReflectorsToUpdate[i].UpdateGeometry();
}
m_Instance.m_ReflectorsToUpdate.Clear();
}
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 51eafe2d43333b44fa24f74f1e8b1e97
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,21 @@
public class AkShowOnlyAttribute : UnityEngine.PropertyAttribute
{
#if UNITY_EDITOR
[UnityEditor.CustomPropertyDrawer(typeof(AkShowOnlyAttribute))]
public class PropertyDrawer : UnityEditor.PropertyDrawer
{
public override float GetPropertyHeight(UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
{
return UnityEditor.EditorGUI.GetPropertyHeight(property, label, true);
}
public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label)
{
var saveEnabled = UnityEngine.GUI.enabled;
UnityEngine.GUI.enabled = false;
UnityEditor.EditorGUI.PropertyField(position, property, label, true);
UnityEngine.GUI.enabled = saveEnabled;
}
}
#endif // #if UNITY_EDITOR
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 028d4a7de983f334aab9ce80b7d2af5d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,199 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2017 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief Contains C# functions exposed from the Wwise C++ API.
///
/// The AkSoundEngine class contains functions converted to C# from the following C++ namespaces:
/// - AK::Monitor
/// - AK::MusicEngine
/// - AK::SoundEngine
/// - AK::SoundEngine::DynamicDialogue
/// - AK::SoundEngine::Query
/// - AK::SpatialAudio
public partial class AkSoundEngine
{
#region String Marshalling
/// <summary>
/// Converts "char*" C-strings to C# strings.
/// </summary>
/// <param name="ptr">"char*" memory pointer passed to C# as an IntPtr.</param>
/// <returns>Converted string.</returns>
public static string StringFromIntPtrString(System.IntPtr ptr)
{
return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ptr);
}
/// <summary>
/// Converts "wchar_t*" C-strings to C# strings.
/// </summary>
/// <param name="ptr">"wchar_t*" memory pointer passed to C# as an IntPtr.</param>
/// <returns>Converted string.</returns>
public static string StringFromIntPtrWString(System.IntPtr ptr)
{
return System.Runtime.InteropServices.Marshal.PtrToStringUni(ptr);
}
#endregion
#region GameObject Hash Function
/// <summary>
/// The type for hash functions used to convert a Unity Game Object into an integer.
/// </summary>
/// <param name="gameObject">The Unity Game Object.</param>
/// <returns>The AkGameObjectID used by the sound engine.</returns>
public delegate ulong GameObjectHashFunction(UnityEngine.GameObject gameObject);
private static ulong InternalGameObjectHash(UnityEngine.GameObject gameObject)
{
return gameObject == null ? AK_INVALID_GAME_OBJECT : (ulong) gameObject.GetInstanceID();
}
/// <summary>
/// The user assignable hash function used to convert a Unity Game Object into an AkGameObjectID used by the sound
/// engine. Used by GetAkGameObjectID().
/// </summary>
public static GameObjectHashFunction GameObjectHash
{
set { gameObjectHash = value == null ? InternalGameObjectHash : value; }
}
private static GameObjectHashFunction gameObjectHash = InternalGameObjectHash;
/// <summary>
/// The hash function used to convert a Unity Game Object into an AkGameObjectID used by the sound engine.
/// </summary>
public static ulong GetAkGameObjectID(UnityEngine.GameObject gameObject)
{
return gameObjectHash(gameObject);
}
#endregion
#region Registration Functions
/// <summary>
/// Registers a Unity Game Object with an ID obtained from GetAkGameObjectID().
/// </summary>
/// <param name="gameObject">The Unity Game Object.</param>
/// <returns></returns>
public static AKRESULT RegisterGameObj(UnityEngine.GameObject gameObject)
{
var id = GetAkGameObjectID(gameObject);
var res = (AKRESULT) AkSoundEnginePINVOKE.CSharp_RegisterGameObjInternal(id);
PostRegisterGameObjUserHook(res, gameObject, id);
return res;
}
/// <summary>
/// Registers a Unity Game Object with an ID obtained from GetAkGameObjectID().
/// </summary>
/// <param name="gameObject">The Unity Game Object.</param>
/// <param name="name">The name that is visible in the Wwise Profiler.</param>
/// <returns></returns>
public static AKRESULT RegisterGameObj(UnityEngine.GameObject gameObject, string name)
{
var id = GetAkGameObjectID(gameObject);
var res = (AKRESULT) AkSoundEnginePINVOKE.CSharp_RegisterGameObjInternal_WithName(id, name);
PostRegisterGameObjUserHook(res, gameObject, id);
return res;
}
/// <summary>
/// Unregisters a Unity Game Object with an ID obtained from GetAkGameObjectID().
/// </summary>
/// <param name="gameObject">The Unity Game Object.</param>
/// <returns></returns>
public static AKRESULT UnregisterGameObj(UnityEngine.GameObject gameObject)
{
var id = GetAkGameObjectID(gameObject);
var res = (AKRESULT) AkSoundEnginePINVOKE.CSharp_UnregisterGameObjInternal(id);
PostUnregisterGameObjUserHook(res, gameObject, id);
return res;
}
#endregion
#region Helper Functions
public static string WwiseVersion
{
get
{
var majorMinor = GetMajorMinorVersion();
var subminorBuild = GetSubminorBuildVersion();
var major = majorMinor >> 16;
var minor = majorMinor & 0xFFFF;
var subMinor = subminorBuild >> 16;
var build = subminorBuild & 0xFFFF;
return string.Format("{0}.{1}.{2} Build {3}", major, minor, subMinor, build);
}
}
public static AKRESULT SetObjectPosition(UnityEngine.GameObject gameObject, UnityEngine.Transform transform)
{
var id = GetAkGameObjectID(gameObject);
return (AKRESULT)AkSoundEnginePINVOKE.CSharp_SetObjectPosition(id, transform.position, transform.forward, transform.up);
}
public static AKRESULT SetObjectPosition(UnityEngine.GameObject gameObject, float posX, float posY, float posZ,
float frontX, float frontY, float frontZ, float topX, float topY, float topZ)
{
var id = GetAkGameObjectID(gameObject);
var position = new UnityEngine.Vector3(posX, posY, posZ);
var forward = new UnityEngine.Vector3(frontX, frontY, frontZ);
var up = new UnityEngine.Vector3(topX, topY, topZ);
return (AKRESULT)AkSoundEnginePINVOKE.CSharp_SetObjectPosition(id, position, forward, up);
}
#endregion
#region User Hooks
public static void PreGameObjectAPICall(UnityEngine.GameObject gameObject, ulong id)
{
PreGameObjectAPICallUserHook(gameObject, id);
}
/// <summary>
/// User hook called within all Wwise integration functions that receive GameObjects and do not perform
/// (un)registration. This is called
/// before values are sent to the native plugin code. An example use could be to register game objects that were not
/// previously registered.
/// </summary>
/// <param name="gameObject">The GameObject being processed.</param>
/// <param name="id">The ulong returned from GameObjectHash that represents this GameObject in Wwise.</param>
static partial void PreGameObjectAPICallUserHook(UnityEngine.GameObject gameObject, ulong id);
/// <summary>
/// User hook called after RegisterGameObj(). An example use could be to add the id and gameObject to a dictionary upon
/// AK_Success.
/// </summary>
/// <param name="result">The result from calling RegisterGameObj() on gameObject.</param>
/// <param name="gameObject">The GameObject that RegisterGameObj() was called on.</param>
/// <param name="id">The ulong returned from GameObjectHash that represents this GameObject in Wwise.</param>
static partial void PostRegisterGameObjUserHook(AKRESULT result, UnityEngine.GameObject gameObject, ulong id);
/// <summary>
/// User hook called after UnregisterGameObj(). An example use could be to remove the id and gameObject from a
/// dictionary upon AK_Success.
/// </summary>
/// <param name="result">The result from calling UnregisterGameObj() on gameObject.</param>
/// <param name="gameObject">The GameObject that UnregisterGameObj() was called on.</param>
/// <param name="id">The ulong returned from GameObjectHash that represents this GameObject in Wwise.</param>
static partial void PostUnregisterGameObjUserHook(AKRESULT result, UnityEngine.GameObject gameObject, ulong id);
#endregion
#region Deprecation Strings
public const string Deprecation_2018_1_2 = "This functionality is deprecated as of Wwise v2018.1.2 and will be removed in a future release.";
public const string Deprecation_2018_1_6 = "This functionality is deprecated as of Wwise v2018.1.6 and will be removed in a future release.";
public const string Deprecation_2019_2_0 = "This functionality is deprecated as of Wwise v2019.2.0 and will be removed in a future release.";
public const string Deprecation_2019_2_2 = "This functionality is deprecated as of Wwise v2019.2.2 and will be removed in a future release.";
#endregion
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dfdee7d1e9b90064fb64e5c1ff28af99
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,808 @@
#if !(UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
#if UNITY_EDITOR
public enum AkWwiseMenuOrder
{
ConvertIDs = 200
}
public enum AkWwiseWindowOrder
{
WwiseSettings = 305,
WwiseInitializationSettings = 306,
WwisePicker = 2300
}
public enum AkWwiseHelpOrder
{
WwiseHelpOrder = 200
}
public partial class AkUtilities
{
#region Migration
/// <summary>
/// These values represent the maximum value of the "Unity Integration Version" number in the Version.txt file that will migrated.
/// For example, in Wwise v2019.1.0, "Unity Integration Version" is 18 which means that all migrations up until this version are required.
/// </summary>
public enum MigrationStep
{
AkGameObjListenerMask_v2016_1_0 = 9,
AkGameObjPositionOffsetData_v2016_2_0 = 10,
AkAudioListener_v2017_1_0 = 14,
InitializationSettings_v2018_1_0 = 15,
WwiseTypes_v2018_1_6 = 16,
AkEventCallback_v2018_1_6 = 16,
AkAmbient_v2019_1_0 = 17,
NewScriptableObjectFolder_v2019_2_0 = 18,
/// <summary>
/// The value that is currently in the Version.txt file.
/// </summary>
Current
}
public static bool IsMigrationRequired(MigrationStep step)
{
return MigrationStartIndex <= (int)step;
}
public static bool IsMigrating
{
get { return MigrationStartIndex < MigrationStopIndex; }
}
public static void BeginMigration(int startIndex)
{
if (startIndex < MigrationStopIndex)
MigrationStartIndex = startIndex;
}
public static void EndMigration()
{
MigrationStartIndex = MigrationStopIndex;
}
public const int MigrationStopIndex = (int)MigrationStep.Current;
public static int MigrationStartIndex
{
private set { migrationStartIndex = value; }
get { return migrationStartIndex; }
}
private static int migrationStartIndex = MigrationStopIndex;
#endregion
private const string DragAndDropId = "AkDragDropId";
public static WwiseObjectReference DragAndDropObjectReference
{
set { UnityEditor.DragAndDrop.SetGenericData(DragAndDropId, value); }
get { return UnityEditor.DragAndDrop.GetGenericData(DragAndDropId) as WwiseObjectReference; }
}
private static readonly System.Collections.Generic.Dictionary<string, string> s_ProjectBankPaths =
new System.Collections.Generic.Dictionary<string, string>();
private static System.DateTime s_LastBankPathUpdate = System.DateTime.MinValue;
private static readonly System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>>
s_BaseToCustomPF = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>>();
public static bool IsWwiseProjectAvailable { set; get; }
public static bool IsSoundbankGenerationAvailable()
{
return GetWwiseCLI() != null;
}
/// Executes a command-line. Blocks the calling thread until the new process has completed. Returns the logged stdout in one big string.
public static string ExecuteCommandLine(string command, string arguments)
{
var process = new System.Diagnostics.Process();
process.StartInfo.FileName = command;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.Arguments = arguments;
process.Start();
// Synchronously read the standard output of the spawned process.
var reader = process.StandardOutput;
var output = reader.ReadToEnd();
// Waiting for the process to exit directly in the UI thread. Similar cases are working that way too.
// TODO: Is it better to provide a timeout avoid any issues of forever blocking the UI thread? If so, what is
// a relevant timeout value for SoundBank generation?
process.WaitForExit();
process.Close();
return output;
}
private static string GetWwiseCLI()
{
string result = null;
var settings = AkWwiseEditorSettings.Instance;
#if UNITY_EDITOR_WIN
if (!string.IsNullOrEmpty(settings.WwiseInstallationPathWindows))
{
result = System.IO.Path.Combine(settings.WwiseInstallationPathWindows, @"Authoring\x64\Release\bin\WwiseCLI.exe");
if (!System.IO.File.Exists(result))
result = System.IO.Path.Combine(settings.WwiseInstallationPathWindows, @"Authoring\Win32\Release\bin\WwiseCLI.exe");
}
#elif UNITY_EDITOR_OSX
if (!string.IsNullOrEmpty(settings.WwiseInstallationPathMac))
result = System.IO.Path.Combine(settings.WwiseInstallationPathMac, "Contents/Tools/WwiseCLI.sh");
#endif
if (result != null && System.IO.File.Exists(result))
return result;
return null;
}
// Generate all the SoundBanks for all the supported platforms in the Wwise project. This effectively calls Wwise for the project
// that is configured in the UnityWwise integration.
public static void GenerateSoundbanks(System.Collections.Generic.List<string> platforms = null)
{
var wwiseProjectFullPath = AkWwiseEditorSettings.WwiseProjectAbsolutePath;
if (IsSoundbankOverrideEnabled(wwiseProjectFullPath))
{
UnityEngine.Debug.LogWarning(
"The SoundBank generation process ignores the SoundBank Settings' Overrides currently enabled in the User settings. The project's SoundBank settings will be used.");
}
var wwiseCli = GetWwiseCLI();
if (wwiseCli == null)
{
UnityEngine.Debug.LogError("Couldn't locate WwiseCLI, unable to generate SoundBanks.");
return;
}
#if UNITY_EDITOR_WIN
var command = wwiseCli;
var arguments = "";
#elif UNITY_EDITOR_OSX
var command = "/bin/sh";
var arguments = "\"" + wwiseCli + "\"";
#else
var command = "";
var arguments = "";
#endif
arguments += " \"" + wwiseProjectFullPath + "\"";
if (platforms != null)
{
foreach (var platform in platforms)
{
if (!string.IsNullOrEmpty(platform))
arguments += " -Platform " + platform;
}
}
arguments += " -GenerateSoundBanks";
var output = ExecuteCommandLine(command, arguments);
if (output.Contains("Process completed successfully."))
{
UnityEngine.Debug.LogFormat("WwiseUnity: SoundBanks generation successful:\n{0}", output);
}
else if (output.Contains("Process completed with warning"))
{
UnityEngine.Debug.LogWarningFormat("WwiseUnity: SoundBanks generation has warning(s):\n{0}", output);
}
else
{
UnityEngine.Debug.LogErrorFormat("WwiseUnity: SoundBanks generation error:\n{0}", output);
}
UnityEditor.AssetDatabase.Refresh();
}
/// Reads the user settings (not the project settings) to check if there is an override currently defined for the SoundBank generation folders.
public static bool IsSoundbankOverrideEnabled(string wwiseProjectPath)
{
var userConfigFile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(wwiseProjectPath),
System.IO.Path.GetFileNameWithoutExtension(wwiseProjectPath) + "." + System.Environment.UserName + ".wsettings");
if (!System.IO.File.Exists(userConfigFile))
return false;
var userConfigDoc = new System.Xml.XmlDocument();
userConfigDoc.Load(userConfigFile);
var userConfigNavigator = userConfigDoc.CreateNavigator();
var userConfigNode = userConfigNavigator.SelectSingleNode(
System.Xml.XPath.XPathExpression.Compile("//Property[@Name='SoundBankPathUserOverride' and @Value = 'True']"));
return userConfigNode != null;
}
public static System.Collections.Generic.IDictionary<string, System.Collections.Generic.List<string>> PlatformMapping
{
get { return s_BaseToCustomPF; }
}
public static System.Collections.Generic.IDictionary<string, string> GetAllBankPaths()
{
UpdateSoundbanksDestinationFolders(AkWwiseEditorSettings.WwiseProjectAbsolutePath);
return s_ProjectBankPaths;
}
public delegate void GetEventDurationsFunc(uint eventID, ref float maximum, ref float minimum);
public static GetEventDurationsFunc GetEventDurations = (uint eventID, ref float maximum, ref float minimum) => { maximum = minimum = -1.0f; };
private static void UpdateSoundbanksDestinationFolders(string WwiseProjectPath)
{
try
{
if (WwiseProjectPath.Length == 0)
return;
if (!System.IO.File.Exists(WwiseProjectPath))
return;
var t = System.IO.File.GetLastWriteTime(WwiseProjectPath);
if (t <= s_LastBankPathUpdate)
return;
s_LastBankPathUpdate = t;
s_ProjectBankPaths.Clear();
var doc = new System.Xml.XmlDocument();
doc.Load(WwiseProjectPath);
var Navigator = doc.CreateNavigator();
// Gather the mapping of Custom platform to Base platform
var itpf = Navigator.Select("//Platform");
s_BaseToCustomPF.Clear();
foreach (System.Xml.XPath.XPathNavigator node in itpf)
{
System.Collections.Generic.List<string> customList = null;
var basePF = node.GetAttribute("ReferencePlatform", "");
if (!s_BaseToCustomPF.TryGetValue(basePF, out customList))
{
customList = new System.Collections.Generic.List<string>();
s_BaseToCustomPF[basePF] = customList;
}
customList.Add(node.GetAttribute("Name", ""));
}
// Navigate the wproj file (XML format) to where generated SoundBank paths are stored
var it = Navigator.Select("//Property[@Name='SoundBankPaths']/ValueList/Value");
foreach (System.Xml.XPath.XPathNavigator node in it)
{
var path = node.Value;
FixSlashes(ref path);
var pf = node.GetAttribute("Platform", "");
s_ProjectBankPaths[pf] = path;
}
}
catch (System.Exception ex)
{
UnityEngine.Debug.LogError("WwiseUnity: Error while reading project " + WwiseProjectPath + ". Exception: " + ex.Message);
}
}
// Parses the .wproj to find out where SoundBanks are generated for the given path.
public static string GetWwiseSoundBankDestinationFolder(string Platform, string WwiseProjectPath)
{
try
{
UpdateSoundbanksDestinationFolders(WwiseProjectPath);
return s_ProjectBankPaths[Platform];
}
catch
{
return "";
}
}
// Set SoundBank-related bool settings in the wproj file.
public static bool EnableBoolSoundbankSettingInWproj(string SettingName, string WwiseProjectPath)
{
try
{
if (WwiseProjectPath.Length == 0)
return true;
var doc = new System.Xml.XmlDocument { PreserveWhitespace = true };
doc.Load(WwiseProjectPath);
var Navigator = doc.CreateNavigator();
// Navigate the wproj file (XML format) to where our setting should be
var pathInXml = string.Format("/WwiseDocument/ProjectInfo/Project/PropertyList/Property[@Name='{0}']", SettingName);
var expression = System.Xml.XPath.XPathExpression.Compile(pathInXml);
var node = Navigator.SelectSingleNode(expression);
if (node == null)
{
// Setting isn't in the wproj, add it
// Navigate to the SoundBankHeaderFilePath property (it is always there)
expression =
System.Xml.XPath.XPathExpression.Compile(
"/WwiseDocument/ProjectInfo/Project/PropertyList/Property[@Name='SoundBankHeaderFilePath']");
node = Navigator.SelectSingleNode(expression);
if (node == null)
{
// SoundBankHeaderFilePath not in wproj, invalid wproj file
UnityEngine.Debug.LogError(
"WwiseUnity: Could not find SoundBankHeaderFilePath property in Wwise project file. File is invalid.");
return false;
}
// Add the setting right above SoundBankHeaderFilePath
var propertyToInsert = string.Format("<Property Name=\"{0}\" Type=\"bool\" Value=\"True\"/>", SettingName);
node.InsertBefore(propertyToInsert);
}
else if (node.GetAttribute("Value", "") == "False")
{
// Value is present, we simply have to modify it.
if (!node.MoveToAttribute("Value", ""))
return false;
// Modify the value to true
node.SetValue("True");
}
else
{
// Parameter already set, nothing to do!
return true;
}
doc.Save(WwiseProjectPath);
return true;
}
catch
{
return false;
}
}
public static bool SetSoundbankHeaderFilePath(string WwiseProjectPath, string SoundbankPath)
{
try
{
if (WwiseProjectPath.Length == 0)
return true;
var doc = new System.Xml.XmlDocument { PreserveWhitespace = true };
doc.Load(WwiseProjectPath);
var Navigator = doc.CreateNavigator();
// Navigate to where the header file path is saved. The node has to be there, or else the wproj is invalid.
var expression =
System.Xml.XPath.XPathExpression.Compile(
"/WwiseDocument/ProjectInfo/Project/PropertyList/Property[@Name='SoundBankHeaderFilePath']");
var node = Navigator.SelectSingleNode(expression);
if (node == null)
{
UnityEngine.Debug.LogError(
"Could not find SoundBankHeaderFilePath property in Wwise project file. File is invalid.");
return false;
}
// Change the "Value" attribute
if (!node.MoveToAttribute("Value", ""))
return false;
node.SetValue(SoundbankPath);
doc.Save(WwiseProjectPath);
return true;
}
catch
{
return false;
}
}
// Make two paths relative to each other
public static string MakeRelativePath(string fromPath, string toPath)
{
// MONO BUG: https://github.com/mono/mono/pull/471
// In the editor, Application.dataPath returns <Project Folder>/Assets. There is a bug in
// mono for method Uri.GetRelativeUri where if the path ends in a folder, it will
// ignore the last part of the path. Thus, we need to add fake depth to get the "real"
// relative path.
fromPath += "/fake_depth";
try
{
if (string.IsNullOrEmpty(fromPath))
return toPath;
if (string.IsNullOrEmpty(toPath))
return "";
var fromUri = new System.Uri(fromPath);
var toUri = new System.Uri(toPath);
if (fromUri.Scheme != toUri.Scheme)
return toPath;
var relativeUri = fromUri.MakeRelativeUri(toUri);
var relativePath = System.Uri.UnescapeDataString(relativeUri.ToString());
return relativePath;
}
catch
{
return toPath;
}
}
// Reconcile a base path and a relative path to give a full path without any ".."
public static string GetFullPath(string BasePath, string RelativePath)
{
if (string.IsNullOrEmpty(BasePath))
return "";
var wrongSeparatorChar = System.IO.Path.DirectorySeparatorChar == '/' ? '\\' : '/';
if (string.IsNullOrEmpty(RelativePath))
return BasePath.Replace(wrongSeparatorChar, System.IO.Path.DirectorySeparatorChar);
if (System.IO.Path.GetPathRoot(RelativePath) != "")
return RelativePath.Replace(wrongSeparatorChar, System.IO.Path.DirectorySeparatorChar);
return System.IO.Path.GetFullPath(System.IO.Path.Combine(BasePath, RelativePath));
}
public static bool DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs)
{
var dir = new System.IO.DirectoryInfo(sourceDirName);
if (!dir.Exists)
{
UnityEngine.Debug.LogError("WwiseUnity: Source directory doesn't exist");
return false;
}
if (!System.IO.Directory.Exists(destDirName))
System.IO.Directory.CreateDirectory(destDirName);
var files = dir.GetFiles();
foreach (var file in files)
{
var destFilePath = System.IO.Path.Combine(destDirName, file.Name);
if (System.IO.File.Exists(destFilePath))
UnityEngine.Debug.LogWarningFormat("WwiseUnity: Destination file path will be overwritten: {0}", destFilePath);
file.CopyTo(destFilePath, true);
}
if (!copySubDirs)
return true;
var dirs = dir.GetDirectories();
foreach (var subdir in dirs)
{
var destSubDirName = System.IO.Path.Combine(destDirName, subdir.Name);
DirectoryCopy(subdir.FullName, destSubDirName, copySubDirs);
}
return true;
}
public static bool CreateFolder(string folderToCreate)
{
var created = false;
var folder = string.Empty;
var folders = folderToCreate.Split(System.IO.Path.AltDirectorySeparatorChar, System.IO.Path.DirectorySeparatorChar);
for (int i = 0; i < folders.Length; ++i)
{
var parentFolder = folder;
folder = string.IsNullOrEmpty(parentFolder) ? folders[i] : System.IO.Path.Combine(parentFolder, folders[i]);
if (UnityEditor.AssetDatabase.IsValidFolder(folder))
{
continue;
}
var error = UnityEditor.AssetDatabase.CreateFolder(parentFolder, folders[i]);
if (string.IsNullOrEmpty(error))
{
created = true;
continue;
}
return false;
}
if (created)
UnityEditor.AssetDatabase.SaveAssets();
return true;
}
/// <summary>
/// Renames or moves a folder using UnityEditor.Database API.
/// </summary>
/// <param name="oldPath"></param>
/// <param name="newPath"></param>
/// <returns>Returns true if the operation was successful.</returns>
public static bool MoveFolder(string oldPath, string newPath)
{
oldPath = oldPath.Replace(System.IO.Path.AltDirectorySeparatorChar, System.IO.Path.DirectorySeparatorChar);
newPath = newPath.Replace(System.IO.Path.AltDirectorySeparatorChar, System.IO.Path.DirectorySeparatorChar);
if (oldPath.Equals(newPath, System.StringComparison.OrdinalIgnoreCase))
return false;
var error = string.Empty;
var newParentFolder = System.IO.Path.GetDirectoryName(newPath);
if (System.IO.Path.GetDirectoryName(oldPath) == newParentFolder)
{
error = UnityEditor.AssetDatabase.RenameAsset(oldPath, newPath.Substring(newParentFolder.Length + 1));
if (string.IsNullOrEmpty(error))
return true;
UnityEngine.Debug.LogErrorFormat("WwiseUnity: Error while attempting to rename folder <{0}> to <{1}>: {2}", oldPath, newPath, error);
return false;
}
if (!CreateFolder(newParentFolder))
return false;
error = UnityEditor.AssetDatabase.MoveAsset(oldPath, newPath);
if (string.IsNullOrEmpty(error))
return true;
UnityEngine.Debug.LogWarningFormat("WwiseUnity: Error while attempting to move folder <{0}> to <{1}>: {2}", oldPath, newPath, error);
return false;
}
///This function returns the absolute position and the width and height of the last drawn GuiLayout(or EditorGuiLayout) element in the inspector window.
///This function must be called in the OnInspectorGUI function
///
///The inspector must be in repaint mode in order to get the correct position
///Example => if(Event.current.type == EventType.Repaint) Rect pos = AkUtilities.GetLastRectAbsolute();
public static UnityEngine.Rect GetLastRectAbsolute(UnityEngine.Rect relativePos)
{
var lastRectAbsolute = relativePos;
lastRectAbsolute.x += UnityEditor.EditorWindow.focusedWindow.position.x;
lastRectAbsolute.y += UnityEditor.EditorWindow.focusedWindow.position.y;
try
{
var inspectorType = UnityEditor.EditorWindow.focusedWindow.GetType();
var currentInspectorFieldInfo = inspectorType.GetField("s_CurrentInspectorWindow",
System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
var scrollPosInfo = inspectorType.GetField("m_ScrollPosition",
System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var scrollPos = (UnityEngine.Vector2)scrollPosInfo.GetValue(currentInspectorFieldInfo.GetValue(null));
lastRectAbsolute.x -= scrollPos.x;
lastRectAbsolute.y -= scrollPos.y;
}
catch
{
}
return lastRectAbsolute;
}
public static void RepaintInspector()
{
var windows = UnityEngine.Resources.FindObjectsOfTypeAll<UnityEditor.EditorWindow>();
foreach (var win in windows)
if (win.titleContent.text == "Inspector")
win.Repaint();
}
public static void AddAkAudioListenerToMainCamera(bool logWarning = false)
{
UnityEngine.Camera camera = UnityEngine.Camera.main;
// Workaround for some versions of Unity not setting properly the MainCamera tag
// on the first scene of a new project
if (camera == null)
{
var cameraArray = UnityEngine.Object.FindObjectsOfType<UnityEngine.Camera>();
if (cameraArray.Length > 0)
{
foreach (var entry in cameraArray)
{
if (entry.name == "Main Camera")
{
camera = entry;
break;
}
}
}
if (camera == null)
{
return;
}
}
if (camera.GetComponentInChildren<AkAudioListener>())
{
return;
}
var oldListener = camera.gameObject.GetComponent<UnityEngine.AudioListener>();
if (oldListener != null)
{
UnityEditor.Undo.DestroyObjectImmediate(oldListener);
}
var akAudioListener = UnityEditor.Undo.AddComponent<AkAudioListener>(camera.gameObject);
if (!akAudioListener)
{
return;
}
var akGameObj = akAudioListener.GetComponentInChildren<AkGameObj>();
if (akGameObj)
{
akGameObj.isEnvironmentAware = false;
}
if (logWarning)
{
UnityEngine.Debug.LogWarning("Automatically added AkAudioListener to Main Camera. Go to \"Edit > Wwise Settings...\" to disable this functionality.");
}
}
#region Tooltip Workaround
private static System.Reflection.FieldInfo GetFieldInfoFromProperty(UnityEditor.SerializedProperty property)
{
var serializedProperty = property.serializedObject.FindProperty("m_Script");
if (serializedProperty == null)
return null;
var monoScript = serializedProperty.objectReferenceValue as UnityEditor.MonoScript;
if (monoScript == null)
return null;
var scriptTypeFromProperty = monoScript.GetClass();
if (scriptTypeFromProperty == null)
return null;
return GetFieldInfoFromPropertyPath(scriptTypeFromProperty, property.propertyPath);
}
private static System.Reflection.FieldInfo GetFieldInfoFromPropertyPath(System.Type host, string path)
{
System.Reflection.FieldInfo fieldInfo = null;
var type = host;
var array = path.Split('.');
for (int i = 0; i < array.Length; ++i)
{
string text = array[i];
if (i < array.Length - 1 && text == "Array" && array[i + 1].StartsWith("data["))
{
if (type.IsArray)
type = type.GetElementType();
else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(System.Collections.Generic.List<>))
type = type.GetGenericArguments()[0];
i++;
}
else
{
var type2 = type;
while (type2 != null)
{
fieldInfo = type2.GetField(text, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic);
if (fieldInfo != null)
{
type = fieldInfo.FieldType;
break;
}
type2 = type2.BaseType;
if (type2 == null)
return null;
}
}
}
return fieldInfo;
}
private static string GetTooltip(System.Reflection.FieldInfo field, bool inherit)
{
var attributes = field.GetCustomAttributes(typeof(UnityEngine.TooltipAttribute), inherit) as UnityEngine.TooltipAttribute[];
if (attributes != null && attributes.Length > 0)
return attributes[0].tooltip;
return string.Empty;
}
public static string GetTooltip(UnityEditor.SerializedProperty property)
{
return GetTooltip(GetFieldInfoFromProperty(property), true);
}
#endregion
}
#endif // UNITY_EDITOR
public partial class AkUtilities
{
public static void FixSlashes(ref string path, char separatorChar, char badChar, bool addTrailingSlash)
{
if (string.IsNullOrEmpty(path))
return;
path = path.Trim().Replace(badChar, separatorChar).TrimStart('\\');
// Append a trailing slash to play nicely with Wwise
if (addTrailingSlash && !path.EndsWith(separatorChar.ToString()))
path += separatorChar;
}
public static void FixSlashes(ref string path)
{
#if UNITY_WSA
var separatorChar = '\\';
#else
var separatorChar = System.IO.Path.DirectorySeparatorChar;
#endif // UNITY_WSA
var badChar = separatorChar == '\\' ? '/' : '\\';
FixSlashes(ref path, separatorChar, badChar, true);
}
/// <summary>
/// This is based on FNVHash as used by the DataManager
/// to assign short IDs to objects. Be sure to keep them both in sync
/// when making changes!
/// </summary>
public class ShortIDGenerator
{
private const uint s_prime32 = 16777619;
private const uint s_offsetBasis32 = 2166136261;
private static byte s_hashSize;
private static uint s_mask;
static ShortIDGenerator()
{
HashSize = 32;
}
public static byte HashSize
{
get { return s_hashSize; }
set
{
s_hashSize = value;
s_mask = (uint) ((1 << s_hashSize) - 1);
}
}
public static uint Compute(string in_name)
{
var buffer = System.Text.Encoding.UTF8.GetBytes(in_name.ToLower());
// Start with the basis value
var hval = s_offsetBasis32;
for (var i = 0; i < buffer.Length; i++)
{
// multiply by the 32 bit FNV magic prime mod 2^32
hval *= s_prime32;
// xor the bottom with the current octet
hval ^= buffer[i];
}
if (s_hashSize == 32)
return hval;
// XOR-Fold to the required number of bits
return (hval >> s_hashSize) ^ (hval & s_mask);
}
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6a2f034196b4f6c448adf573e7cb04ea
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,15 @@
[System.Obsolete(AkSoundEngine.Deprecation_2019_2_0)]
public class AkVector
{
private UnityEngine.Vector3 Vector = UnityEngine.Vector3.zero;
public void Zero() { Vector.Set(0, 0, 0); }
public float X { set { Vector.x = value; } get { return Vector.x; } }
public float Y { set { Vector.y = value; } get { return Vector.y; } }
public float Z { set { Vector.z = value; } get { return Vector.z; } }
public static implicit operator UnityEngine.Vector3(AkVector vector) { return vector.Vector; }
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ca5c79a8a33172640a400e6926f1ae65
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,38 @@
[System.Obsolete(AkSoundEngine.Deprecation_2019_2_0)]
public class AkVertex
{
private UnityEngine.Vector3 Vector = UnityEngine.Vector3.zero;
public void Zero() { Vector.Set(0, 0, 0); }
public float X { set { Vector.x = value; } get { return Vector.x; } }
public float Y { set { Vector.y = value; } get { return Vector.y; } }
public float Z { set { Vector.z = value; } get { return Vector.z; } }
public static implicit operator UnityEngine.Vector3(AkVertex vector) { return vector.Vector; }
public AkVertex() { }
public AkVertex(float x, float y, float z) { Vector.Set(x, y, z); }
public void Clear() { Vector.Set(0, 0, 0); }
public static int GetSizeOf() { return sizeof(float) * 3; }
public void Clone(AkVertex other) { Vector = other.Vector; }
}
[System.Obsolete(AkSoundEngine.Deprecation_2019_2_0)]
/// AkVertexArray is now deprecated. Users should instead use UnityEngine.Vector3[].
public class AkVertexArray : AkBaseArray<AkVertex>
{
public AkVertexArray(int count) : base(count) {}
protected override int StructureSize { get { return AkVertex.GetSizeOf(); } }
protected override AkVertex CreateNewReferenceFromIntPtr(System.IntPtr address) { return null; }
protected override void CloneIntoReferenceFromIntPtr(System.IntPtr address, AkVertex other) {}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 092e1fff5f8571f4bb9cdde1c390c31c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,351 @@
#if !(UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
#if UNITY_EDITOR
[System.Serializable]
public class WwiseSettings
{
public const string Filename = "WwiseSettings.xml";
public static string Path
{
get { return System.IO.Path.Combine(UnityEngine.Application.dataPath, Filename); }
}
public static bool Exists { get { return System.IO.File.Exists(Path); } }
public bool CopySoundBanksAsPreBuildStep = true;
public bool CreatedPicker = false;
public bool CreateWwiseGlobal = true;
public bool CreateWwiseListener = true;
public bool GenerateSoundBanksAsPreBuildStep = false;
public bool ShowMissingRigidBodyWarning = true;
public bool ShowSpatialAudioWarningMsg = true;
public string SoundbankPath;
public string WwiseInstallationPathMac;
public string WwiseInstallationPathWindows;
public string WwiseProjectPath;
[System.Xml.Serialization.XmlIgnore]
public string WwiseInstallationPath
{
#if UNITY_EDITOR_OSX
get { return WwiseInstallationPathMac; }
set { WwiseInstallationPathMac = value; }
#else
get { return WwiseInstallationPathWindows; }
set { WwiseInstallationPathWindows = value; }
#endif
}
internal static WwiseSettings LoadSettings()
{
var settings = new WwiseSettings();
try
{
var path = Path;
if (System.IO.File.Exists(path))
{
var xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(WwiseSettings));
using (var xmlFileStream = new System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.Read))
settings = xmlSerializer.Deserialize(xmlFileStream) as WwiseSettings;
}
else
{
var projectDir = System.IO.Path.GetDirectoryName(UnityEngine.Application.dataPath);
var foundWwiseProjects = System.IO.Directory.GetFiles(projectDir, "*.wproj", System.IO.SearchOption.AllDirectories);
if (foundWwiseProjects.Length > 0)
settings.WwiseProjectPath = AkUtilities.MakeRelativePath(UnityEngine.Application.dataPath, foundWwiseProjects[0]);
else
settings.WwiseProjectPath = string.Empty;
settings.SoundbankPath = AkBasePathGetter.DefaultBasePath;
}
}
catch
{
}
return settings;
}
public void SaveSettings()
{
try
{
var xmlDoc = new System.Xml.XmlDocument();
var xmlSerializer = new System.Xml.Serialization.XmlSerializer(GetType());
using (var xmlStream = new System.IO.MemoryStream())
{
var streamWriter = new System.IO.StreamWriter(xmlStream, System.Text.Encoding.UTF8);
xmlSerializer.Serialize(streamWriter, this);
xmlStream.Position = 0;
xmlDoc.Load(xmlStream);
xmlDoc.Save(Path);
}
}
catch
{
UnityEngine.Debug.LogErrorFormat("WwiseUnity: Unable to save settings to file <{0}>. Please ensure that this file path can be written to.", Path);
}
}
}
public class AkWwiseEditorSettings
{
private static WwiseSettings s_Instance;
public static WwiseSettings Instance
{
get
{
if (s_Instance == null)
s_Instance = WwiseSettings.LoadSettings();
return s_Instance;
}
}
public static void Reload()
{
s_Instance = WwiseSettings.LoadSettings();
}
public static string WwiseProjectAbsolutePath
{
get { return AkUtilities.GetFullPath(UnityEngine.Application.dataPath, Instance.WwiseProjectPath); }
}
public static string WwiseScriptableObjectRelativePath
{
get { return System.IO.Path.Combine(System.IO.Path.Combine("Assets", "Wwise"), "ScriptableObjects"); }
}
#region GUI
#if UNITY_2018_3_OR_NEWER
class SettingsProvider : UnityEditor.SettingsProvider
#else
class EditorWindow : UnityEditor.EditorWindow
#endif
{
class Styles
{
public static string WwiseProject = "Wwise Project";
public static UnityEngine.GUIContent WwiseProjectPath = new UnityEngine.GUIContent("Wwise Project Path*", "Location of the Wwise project associated with this game. It is recommended to put it in the Unity Project root folder, outside the Assets folder.");
public static string WwiseApplicationPath = "Wwise Application Path";
public static UnityEngine.GUIContent WwiseInstallationPath = new UnityEngine.GUIContent("Wwise Application Path", "Location of the Wwise application. This is required to generate the SoundBanks in Unity.");
public static string AssetManagement = "Asset Management";
public static UnityEngine.GUIContent SoundbankPath = new UnityEngine.GUIContent("SoundBanks Path*", "Location of the SoundBanks relative to (and within) the StreamingAssets folder.");
public static UnityEngine.GUIContent CopySoundBanksAsPreBuildStep = new UnityEngine.GUIContent("Copy SoundBanks at pre-Build step", "Copies the SoundBanks in the appropriate location for building and deployment. It is recommended to leave this box checked.");
public static UnityEngine.GUIContent GenerateSoundBanksAsPreBuildStep = new UnityEngine.GUIContent("Generate SoundBanks at pre-Build step", "Generates the SoundBanks before copying them during pre-Build step. It is recommended to leave this box unchecked if SoundBanks are generated on a specific build machine.");
public static string GlobalSettings = "Global Settings";
public static UnityEngine.GUIContent CreateWwiseGlobal = new UnityEngine.GUIContent("Create WwiseGlobal GameObject", "The WwiseGlobal object is a GameObject that contains the Initializing and Terminating scripts for the Wwise Sound Engine. In the Editor workflow, it is added to every scene, so that it can be properly previewed in the Editor. In the game, only one instance is created, in the first scene, and it is persisted throughout the game. It is recommended to leave this box checked.");
public static UnityEngine.GUIContent CreateWwiseListener = new UnityEngine.GUIContent("Add Listener to Main Camera", "In order for positioning to work, the AkAudioListener script needs to be attached to the main camera in every scene. If you wish for your listener to be attached to another GameObject, uncheck this box");
public static string InEditorWarnings = "In Editor Warnings";
public static UnityEngine.GUIContent ShowMissingRigidBodyWarning = new UnityEngine.GUIContent("Show warning for missing RigidBody", "Interactions between AkGameObj and AkEnvironment or AkRoom require a Rigidbody component on the object or the environment/room. It is recommended to leave this box checked.");
public static UnityEngine.GUIContent ShowSpatialAudioWarningMsg = new UnityEngine.GUIContent("Show warning for missing Collider", "Interactions between AkRoomAwareObject and AkRoom require a Collider component on the object. It is recommended to leave this box checked.");
public static string MandatorySettings = "* Mandatory settings";
private static UnityEngine.GUIStyle version;
public static UnityEngine.GUIStyle Version
{
get
{
if (version != null)
return version;
version = new UnityEngine.GUIStyle(UnityEditor.EditorStyles.whiteLargeLabel);
if (!UnityEngine.Application.HasProLicense())
{
version.active.textColor =
version.focused.textColor =
version.hover.textColor =
version.normal.textColor = UnityEngine.Color.black;
}
return version;
}
}
private static UnityEngine.GUIStyle textField;
public static UnityEngine.GUIStyle TextField
{
get
{
if (textField == null)
textField = new UnityEngine.GUIStyle("textfield");
return textField;
}
}
}
private static bool Ellipsis()
{
return UnityEngine.GUILayout.Button("...", UnityEngine.GUILayout.Width(30));
}
#if UNITY_2018_3_OR_NEWER
private SettingsProvider(string path) : base(path, UnityEditor.SettingsScope.Project) { }
[UnityEditor.SettingsProvider]
public static UnityEditor.SettingsProvider CreateMyCustomSettingsProvider()
{
return new SettingsProvider("Project/Wwise Editor") { keywords = GetSearchKeywordsFromGUIContentProperties<Styles>() };
}
public override void OnGUI(string searchContext)
#else
[UnityEditor.MenuItem("Edit/Wwise Settings...", false, (int)AkWwiseWindowOrder.WwiseSettings)]
public static void Init()
{
// Get existing open window or if none, make a new one:
var window = GetWindow(typeof(EditorWindow));
window.position = new UnityEngine.Rect(100, 100, 850, 360);
window.titleContent = new UnityEngine.GUIContent("Wwise Settings");
}
private void OnGUI()
#endif
{
bool changed = false;
var labelWidth = UnityEditor.EditorGUIUtility.labelWidth;
UnityEditor.EditorGUIUtility.labelWidth += 100;
var settings = Instance;
UnityEngine.GUILayout.Label(string.Format("Wwise v{0} Settings.", AkSoundEngine.WwiseVersion), Styles.Version);
UnityEngine.GUILayout.Label(Styles.WwiseProject, UnityEditor.EditorStyles.boldLabel);
using (new UnityEngine.GUILayout.HorizontalScope("box"))
{
UnityEditor.EditorGUILayout.PrefixLabel(Styles.WwiseProjectPath);
UnityEditor.EditorGUILayout.SelectableLabel(settings.WwiseProjectPath, Styles.TextField, UnityEngine.GUILayout.Height(17));
if (Ellipsis())
{
var OpenInPath = System.IO.Path.GetDirectoryName(AkUtilities.GetFullPath(UnityEngine.Application.dataPath, settings.WwiseProjectPath));
var WwiseProjectPathNew = UnityEditor.EditorUtility.OpenFilePanel("Select your Wwise Project", OpenInPath, "wproj");
if (WwiseProjectPathNew.Length != 0)
{
if (WwiseProjectPathNew.EndsWith(".wproj") == false)
{
UnityEditor.EditorUtility.DisplayDialog("Error", "Please select a valid .wproj file", "Ok");
}
else
{
settings.WwiseProjectPath = AkUtilities.MakeRelativePath(UnityEngine.Application.dataPath, WwiseProjectPathNew);
changed = true;
}
}
}
}
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
UnityEngine.GUILayout.Label(Styles.WwiseApplicationPath, UnityEditor.EditorStyles.boldLabel);
using (new UnityEngine.GUILayout.HorizontalScope("box"))
{
UnityEditor.EditorGUILayout.PrefixLabel(Styles.WwiseInstallationPath);
UnityEditor.EditorGUILayout.SelectableLabel(settings.WwiseInstallationPath, Styles.TextField, UnityEngine.GUILayout.Height(17));
if (Ellipsis())
{
#if UNITY_EDITOR_OSX
var path = UnityEditor.EditorUtility.OpenFilePanel("Select your Wwise application.", "/Applications/", "");
#else
var path = UnityEditor.EditorUtility.OpenFolderPanel("Select your Wwise application.", System.Environment.GetEnvironmentVariable("ProgramFiles(x86)"), "");
#endif
if (path.Length != 0)
{
settings.WwiseInstallationPath = System.IO.Path.GetFullPath(path);
changed = true;
}
}
}
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
UnityEngine.GUILayout.Label(Styles.AssetManagement, UnityEditor.EditorStyles.boldLabel);
using (new UnityEngine.GUILayout.VerticalScope("box"))
{
using (new UnityEngine.GUILayout.HorizontalScope())
{
UnityEditor.EditorGUILayout.PrefixLabel(Styles.SoundbankPath);
UnityEditor.EditorGUILayout.SelectableLabel(settings.SoundbankPath, Styles.TextField, UnityEngine.GUILayout.Height(17));
if (Ellipsis())
{
var FullPath = AkUtilities.GetFullPath(UnityEngine.Application.streamingAssetsPath, settings.SoundbankPath);
var OpenInPath = System.IO.Path.GetDirectoryName(FullPath);
var path = UnityEditor.EditorUtility.OpenFolderPanel("Select your SoundBanks destination folder", OpenInPath, FullPath.Substring(OpenInPath.Length + 1));
if (path.Length != 0)
{
var stremingAssetsIndex = UnityEngine.Application.dataPath.Split('/').Length;
var folders = path.Split('/');
if (folders.Length - 1 < stremingAssetsIndex || !string.Equals(folders[stremingAssetsIndex], "StreamingAssets", System.StringComparison.OrdinalIgnoreCase))
{
UnityEditor.EditorUtility.DisplayDialog("Error", "The SoundBank destination folder must be located within the Unity project 'StreamingAssets' folder.", "Ok");
}
else
{
var previousPath = settings.SoundbankPath;
var newPath = AkUtilities.MakeRelativePath(UnityEngine.Application.streamingAssetsPath, path);
if (previousPath != newPath)
{
settings.SoundbankPath = newPath;
changed = true;
}
}
}
}
}
UnityEditor.EditorGUI.BeginChangeCheck();
settings.CopySoundBanksAsPreBuildStep = UnityEditor.EditorGUILayout.Toggle(Styles.CopySoundBanksAsPreBuildStep, settings.CopySoundBanksAsPreBuildStep);
UnityEngine.GUI.enabled = settings.CopySoundBanksAsPreBuildStep;
settings.GenerateSoundBanksAsPreBuildStep = UnityEditor.EditorGUILayout.Toggle(Styles.GenerateSoundBanksAsPreBuildStep, settings.GenerateSoundBanksAsPreBuildStep);
UnityEngine.GUI.enabled = true;
if (UnityEditor.EditorGUI.EndChangeCheck())
changed = true;
}
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
UnityEngine.GUILayout.Label(Styles.GlobalSettings, UnityEditor.EditorStyles.boldLabel);
UnityEditor.EditorGUI.BeginChangeCheck();
using (new UnityEngine.GUILayout.VerticalScope("box"))
{
settings.CreateWwiseGlobal = UnityEditor.EditorGUILayout.Toggle(Styles.CreateWwiseGlobal, settings.CreateWwiseGlobal);
settings.CreateWwiseListener = UnityEditor.EditorGUILayout.Toggle(Styles.CreateWwiseListener, settings.CreateWwiseListener);
}
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
UnityEngine.GUILayout.Label(Styles.InEditorWarnings, UnityEditor.EditorStyles.boldLabel);
using (new UnityEngine.GUILayout.VerticalScope("box"))
{
settings.ShowMissingRigidBodyWarning = UnityEditor.EditorGUILayout.Toggle(Styles.ShowMissingRigidBodyWarning, settings.ShowMissingRigidBodyWarning);
settings.ShowSpatialAudioWarningMsg = UnityEditor.EditorGUILayout.Toggle(Styles.ShowSpatialAudioWarningMsg, settings.ShowSpatialAudioWarningMsg);
}
if (UnityEditor.EditorGUI.EndChangeCheck())
changed = true;
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
UnityEngine.GUILayout.Label(Styles.MandatorySettings);
UnityEditor.EditorGUIUtility.labelWidth = labelWidth;
if (changed)
settings.SaveSettings();
}
}
#endregion
}
#endif // UNITY_EDITOR
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f2c427c6a2b36e44d9d76dcea17ed3a6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a82173ad83f26b94287e79474c64c613
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,99 @@
#if UNITY_EDITOR
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2014 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
using System.Threading;
public class AkWwiseXMLWatcher
{
private static readonly AkWwiseXMLWatcher instance = new AkWwiseXMLWatcher();
public static AkWwiseXMLWatcher Instance { get { return instance; } }
private System.IO.FileSystemWatcher XmlWatcher;
private bool ExceptionOccurred;
private bool fireEvent;
public event System.Action XMLUpdated;
public System.Func<bool> PopulateXML;
private string basePath;
private AkWwiseXMLWatcher()
{
if (UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode && !UnityEditor.EditorApplication.isPlaying)
{
return;
}
StartWatcher();
}
public void StartWatcher()
{
basePath = AkBasePathGetter.GetPlatformBasePath();
new Thread(CreateWatcher).Start();
UnityEditor.EditorApplication.update += OnEditorUpdate;
}
public void CreateWatcher()
{
try
{
if (XmlWatcher != null)
{
XmlWatcher.Dispose();
}
XmlWatcher = new System.IO.FileSystemWatcher(basePath) {Filter = "*.xml", IncludeSubdirectories = true, };
// Event handlers that are watching for specific event
XmlWatcher.Created += RaisePopulateFlag;
XmlWatcher.Changed += RaisePopulateFlag;
XmlWatcher.NotifyFilter = System.IO.NotifyFilters.LastWrite;
XmlWatcher.EnableRaisingEvents = true;
ExceptionOccurred = false;
}
catch
{
ExceptionOccurred = true;
}
}
private void OnEditorUpdate()
{
var logWarnings = AkBasePathGetter.LogWarnings;
AkBasePathGetter.LogWarnings = false;
basePath = AkBasePathGetter.GetPlatformBasePath();
AkBasePathGetter.LogWarnings = logWarnings;
if (ExceptionOccurred || basePath != XmlWatcher?.Path)
new Thread(CreateWatcher).Start();
if (!fireEvent)
return;
fireEvent = false;
var populate = PopulateXML;
if (populate == null || !populate())
return;
var callback = XMLUpdated;
if (callback != null)
{
callback();
}
AkBankManager.ReloadAllBanks();
}
private void RaisePopulateFlag(object sender, System.IO.FileSystemEventArgs e)
{
fireEvent = true;
}
}
#endif

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 16b50cec38ff5c04f9272f5dd9065bcd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3eabe256e07fd08409d2783bd87ebdba
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,34 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2012 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
public class AkAcousticSurfaceArray : AkBaseArray<AkAcousticSurface>
{
public AkAcousticSurfaceArray(int count) : base(count)
{
}
protected override int StructureSize
{
get { return AkSoundEnginePINVOKE.CSharp_AkAcousticSurface_GetSizeOf(); }
}
protected override void DefaultConstructAtIntPtr(System.IntPtr address)
{
AkSoundEnginePINVOKE.CSharp_AkAcousticSurface_Clear(address);
}
protected override AkAcousticSurface CreateNewReferenceFromIntPtr(System.IntPtr address)
{
return new AkAcousticSurface(address, false);
}
protected override void CloneIntoReferenceFromIntPtr(System.IntPtr address, AkAcousticSurface other)
{
AkSoundEnginePINVOKE.CSharp_AkAcousticSurface_Clone(address, AkAcousticSurface.getCPtr(other));
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a78ad22743298314cb4f9124cece8d7d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,137 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2012 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
public class AkAuxSendArray : System.IDisposable
{
private const int MAX_COUNT = AkEnvironment.MAX_NB_ENVIRONMENTS;
private readonly int SIZE_OF_AKAUXSENDVALUE = AkSoundEnginePINVOKE.CSharp_AkAuxSendValue_GetSizeOf();
private System.IntPtr m_Buffer;
private int m_Count;
public AkAuxSendArray()
{
m_Buffer = System.Runtime.InteropServices.Marshal.AllocHGlobal(MAX_COUNT * SIZE_OF_AKAUXSENDVALUE);
m_Count = 0;
}
public AkAuxSendValue this[int index]
{
get
{
if (index >= m_Count)
throw new System.IndexOutOfRangeException("Out of range access in AkAuxSendArray");
return new AkAuxSendValue(GetObjectPtr(index), false);
}
}
public bool isFull
{
get { return m_Count >= MAX_COUNT || m_Buffer == System.IntPtr.Zero; }
}
public void Dispose()
{
if (m_Buffer != System.IntPtr.Zero)
{
System.Runtime.InteropServices.Marshal.FreeHGlobal(m_Buffer);
m_Buffer = System.IntPtr.Zero;
m_Count = 0;
}
}
~AkAuxSendArray()
{
Dispose();
}
public void Reset()
{
m_Count = 0;
}
public bool Add(UnityEngine.GameObject in_listenerGameObj, uint in_AuxBusID, float in_fValue)
{
if (isFull)
return false;
AkSoundEnginePINVOKE.CSharp_AkAuxSendValue_Set(GetObjectPtr(m_Count),
AkSoundEngine.GetAkGameObjectID(in_listenerGameObj), in_AuxBusID, in_fValue);
m_Count++;
return true;
}
public bool Add(uint in_AuxBusID, float in_fValue)
{
if (isFull)
return false;
AkSoundEnginePINVOKE.CSharp_AkAuxSendValue_Set(GetObjectPtr(m_Count), AkSoundEngine.AK_INVALID_GAME_OBJECT,
in_AuxBusID, in_fValue);
m_Count++;
return true;
}
public bool Contains(UnityEngine.GameObject in_listenerGameObj, uint in_AuxBusID)
{
if (m_Buffer == System.IntPtr.Zero)
return false;
for (var i = 0; i < m_Count; i++)
{
if (AkSoundEnginePINVOKE.CSharp_AkAuxSendValue_IsSame(GetObjectPtr(i),
AkSoundEngine.GetAkGameObjectID(in_listenerGameObj), in_AuxBusID))
return true;
}
return false;
}
public bool Contains(uint in_AuxBusID)
{
if (m_Buffer == System.IntPtr.Zero)
return false;
for (var i = 0; i < m_Count; i++)
{
if (AkSoundEnginePINVOKE.CSharp_AkAuxSendValue_IsSame(GetObjectPtr(i), AkSoundEngine.AK_INVALID_GAME_OBJECT, in_AuxBusID))
return true;
}
return false;
}
public AKRESULT SetValues(UnityEngine.GameObject gameObject)
{
return (AKRESULT) AkSoundEnginePINVOKE.CSharp_SetGameObjectAuxSendValues(AkSoundEngine.GetAkGameObjectID(gameObject), m_Buffer, (uint) m_Count);
}
public AKRESULT GetValues(UnityEngine.GameObject gameObject)
{
uint count = MAX_COUNT;
var res = (AKRESULT) AkSoundEnginePINVOKE.CSharp_GetGameObjectAuxSendValues(AkSoundEngine.GetAkGameObjectID(gameObject), m_Buffer, ref count);
m_Count = (int) count;
return res;
}
public System.IntPtr GetBuffer()
{
return m_Buffer;
}
public int Count()
{
return m_Count;
}
private System.IntPtr GetObjectPtr(int index)
{
return (System.IntPtr) (m_Buffer.ToInt64() + SIZE_OF_AKAUXSENDVALUE * index);
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3d3e766880bd0c54ca592daa80206013
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,77 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2012 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
public abstract class AkBaseArray<T> : System.IDisposable
{
public AkBaseArray(int capacity)
{
m_Buffer = System.Runtime.InteropServices.Marshal.AllocHGlobal(capacity * StructureSize);
if (m_Buffer != System.IntPtr.Zero)
{
Capacity = capacity;
for (var index = 0; index < capacity; ++index)
DefaultConstructAtIntPtr(GetObjectPtr(index));
}
}
public void Dispose()
{
if (m_Buffer != System.IntPtr.Zero)
{
for (var index = 0; index < Capacity; ++index)
ReleaseAllocatedMemoryFromReferenceAtIntPtr(GetObjectPtr(index));
System.Runtime.InteropServices.Marshal.FreeHGlobal(m_Buffer);
m_Buffer = System.IntPtr.Zero;
Capacity = 0;
}
}
~AkBaseArray() { Dispose(); }
public int Capacity { get; private set; }
public virtual int Count() { return Capacity; }
protected abstract int StructureSize { get; }
/// <summary>
/// This method is called for each element of the array when the array is constructed. It should be used to clear the memory associated with an element so that it will be seen as if it had been default constructed.
/// </summary>
/// <param name="address">The address of the element</param>
protected virtual void DefaultConstructAtIntPtr(System.IntPtr address) { }
/// <summary>
/// This method is called for each element of the array when the array is disposed. It should be used to delete memory allocated by elements.
/// </summary>
/// <param name="address">The address of the element</param>
protected virtual void ReleaseAllocatedMemoryFromReferenceAtIntPtr(System.IntPtr address) { }
protected abstract T CreateNewReferenceFromIntPtr(System.IntPtr address);
protected abstract void CloneIntoReferenceFromIntPtr(System.IntPtr address, T other);
public T this[int index]
{
get { return CreateNewReferenceFromIntPtr(GetObjectPtr(index)); }
set { CloneIntoReferenceFromIntPtr(GetObjectPtr(index), value); }
}
public System.IntPtr GetBuffer() { return m_Buffer; }
private System.IntPtr m_Buffer;
protected System.IntPtr GetObjectPtr(int index)
{
if (index >= Capacity)
throw new System.IndexOutOfRangeException("Out of range access in " + GetType().Name);
return (System.IntPtr)(m_Buffer.ToInt64() + StructureSize * index);
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a1e092f59a070584f9661e187233192d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,86 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2012 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
public class AkChannelEmitterArray : System.IDisposable
{
public System.IntPtr m_Buffer;
private System.IntPtr m_Current;
private uint m_MaxCount;
public AkChannelEmitterArray(uint in_Count)
{
// Three vectors of 3 floats, plus a mask
m_Buffer = System.Runtime.InteropServices.Marshal.AllocHGlobal((int) in_Count * (sizeof(float) * 9 + sizeof(uint)));
m_Current = m_Buffer;
m_MaxCount = in_Count;
Count = 0;
}
public uint Count { get; private set; }
public void Dispose()
{
if (m_Buffer != System.IntPtr.Zero)
{
System.Runtime.InteropServices.Marshal.FreeHGlobal(m_Buffer);
m_Buffer = System.IntPtr.Zero;
m_MaxCount = 0;
}
}
~AkChannelEmitterArray()
{
Dispose();
}
public void Reset()
{
m_Current = m_Buffer;
Count = 0;
}
public void Add(UnityEngine.Vector3 in_Pos, UnityEngine.Vector3 in_Forward, UnityEngine.Vector3 in_Top,
uint in_ChannelMask)
{
if (Count >= m_MaxCount)
throw new System.IndexOutOfRangeException("Out of range access in AkChannelEmitterArray");
//Marshal doesn't do floats. So copy the bytes themselves. Grrr.
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Forward.x), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Forward.y), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Forward.z), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Top.x), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Top.y), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Top.z), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Pos.x), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Pos.y), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Pos.z), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current, (int) in_ChannelMask);
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(uint));
Count++;
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 19c0f3d1cde4f884b8938e2e6e006327
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,34 @@
#if !(UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2019 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
public class AkDeviceDescriptionArray : AkBaseArray<AkDeviceDescription>
{
public AkDeviceDescriptionArray(int count) : base(count)
{
}
protected override int StructureSize
{
get { return AkSoundEnginePINVOKE.CSharp_AkDeviceDescription_GetSizeOf(); }
}
protected override void DefaultConstructAtIntPtr(System.IntPtr address)
{
AkSoundEnginePINVOKE.CSharp_AkDeviceDescription_Clear(address);
}
protected override AkDeviceDescription CreateNewReferenceFromIntPtr(System.IntPtr address)
{
return new AkDeviceDescription(address, false);
}
protected override void CloneIntoReferenceFromIntPtr(System.IntPtr address, AkDeviceDescription other)
{
AkSoundEnginePINVOKE.CSharp_AkDeviceDescription_Clone(address, AkDeviceDescription.getCPtr(other));
}
}
#endif

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1727ae0e45f8ab644a08048fa14e1e3f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,29 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2012 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
public class AkDiffractionPathInfoArray : AkBaseArray<AkDiffractionPathInfo>
{
public AkDiffractionPathInfoArray(int count) : base(count)
{
}
protected override int StructureSize
{
get { return AkSoundEnginePINVOKE.CSharp_AkDiffractionPathInfo_GetSizeOf(); }
}
protected override AkDiffractionPathInfo CreateNewReferenceFromIntPtr(System.IntPtr address)
{
return new AkDiffractionPathInfo(address, false);
}
protected override void CloneIntoReferenceFromIntPtr(System.IntPtr address, AkDiffractionPathInfo other)
{
AkSoundEnginePINVOKE.CSharp_AkDiffractionPathInfo_Clone(address, AkDiffractionPathInfo.getCPtr(other));
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 983c486ff8e310e4ba335b963a8cb0fc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,39 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2019 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
public class AkExternalSourceInfoArray : AkBaseArray<AkExternalSourceInfo>
{
public AkExternalSourceInfoArray(int count) : base(count)
{
}
protected override int StructureSize
{
get { return AkSoundEnginePINVOKE.CSharp_AkExternalSourceInfo_GetSizeOf(); }
}
protected override void DefaultConstructAtIntPtr(System.IntPtr address)
{
AkSoundEnginePINVOKE.CSharp_AkExternalSourceInfo_Clear(address);
}
protected override void ReleaseAllocatedMemoryFromReferenceAtIntPtr(System.IntPtr address)
{
AkSoundEnginePINVOKE.CSharp_AkExternalSourceInfo_szFile_set(address, null);
}
protected override AkExternalSourceInfo CreateNewReferenceFromIntPtr(System.IntPtr address)
{
return new AkExternalSourceInfo(address, false);
}
protected override void CloneIntoReferenceFromIntPtr(System.IntPtr address, AkExternalSourceInfo other)
{
AkSoundEnginePINVOKE.CSharp_AkExternalSourceInfo_Clone(address, AkExternalSourceInfo.getCPtr(other));
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 27dc13bd1d98ffe48b4fc297a96dff15
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,77 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2012 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
public class AkMIDIPostArray
{
private readonly int m_Count;
private readonly int SIZE_OF = AkSoundEnginePINVOKE.CSharp_AkMIDIPost_GetSizeOf();
private System.IntPtr m_Buffer = System.IntPtr.Zero;
public AkMIDIPostArray(int size)
{
m_Count = size;
m_Buffer = System.Runtime.InteropServices.Marshal.AllocHGlobal(m_Count * SIZE_OF);
}
public AkMIDIPost this[int index]
{
get
{
if (index >= m_Count)
throw new System.IndexOutOfRangeException("Out of range access in AkMIDIPostArray");
return new AkMIDIPost(GetObjectPtr(index), false);
}
set
{
if (index >= m_Count)
throw new System.IndexOutOfRangeException("Out of range access in AkMIDIPostArray");
AkSoundEnginePINVOKE.CSharp_AkMIDIPost_Clone(GetObjectPtr(index), AkMIDIPost.getCPtr(value));
}
}
~AkMIDIPostArray()
{
System.Runtime.InteropServices.Marshal.FreeHGlobal(m_Buffer);
m_Buffer = System.IntPtr.Zero;
}
public void PostOnEvent(uint in_eventID, UnityEngine.GameObject gameObject)
{
var gameObjectID = AkSoundEngine.GetAkGameObjectID(gameObject);
AkSoundEngine.PreGameObjectAPICall(gameObject, gameObjectID);
AkSoundEnginePINVOKE.CSharp_AkMIDIPost_PostOnEvent(m_Buffer, in_eventID, gameObjectID, (uint) m_Count);
}
public void PostOnEvent(uint in_eventID, UnityEngine.GameObject gameObject, int count)
{
if (count >= m_Count)
throw new System.IndexOutOfRangeException("Out of range access in AkMIDIPostArray");
var gameObjectID = AkSoundEngine.GetAkGameObjectID(gameObject);
AkSoundEngine.PreGameObjectAPICall(gameObject, gameObjectID);
AkSoundEnginePINVOKE.CSharp_AkMIDIPost_PostOnEvent(m_Buffer, in_eventID, gameObjectID, (uint) count);
}
public System.IntPtr GetBuffer()
{
return m_Buffer;
}
public int Count()
{
return m_Count;
}
private System.IntPtr GetObjectPtr(int index)
{
return (System.IntPtr) (m_Buffer.ToInt64() + SIZE_OF * index);
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 706958941ff3a2c4397a316c31b9daa2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,34 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2019 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
public class AkObjectInfoArray : AkBaseArray<AkObjectInfo>
{
public AkObjectInfoArray(int count) : base(count)
{
}
protected override int StructureSize
{
get { return AkSoundEnginePINVOKE.CSharp_AkObjectInfo_GetSizeOf(); }
}
protected override void DefaultConstructAtIntPtr(System.IntPtr address)
{
AkSoundEnginePINVOKE.CSharp_AkObjectInfo_Clear(address);
}
protected override AkObjectInfo CreateNewReferenceFromIntPtr(System.IntPtr address)
{
return new AkObjectInfo(address, false);
}
protected override void CloneIntoReferenceFromIntPtr(System.IntPtr address, AkObjectInfo other)
{
AkSoundEnginePINVOKE.CSharp_AkObjectInfo_Clone(address, AkObjectInfo.getCPtr(other));
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7a8e634c9ee8d914b9931774db23c9f3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,34 @@
#if !(UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2019 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
public class AkObstructionOcclusionValuesArray : AkBaseArray<AkObstructionOcclusionValues>
{
public AkObstructionOcclusionValuesArray(int count) : base(count)
{
}
protected override int StructureSize
{
get { return AkSoundEnginePINVOKE.CSharp_AkObstructionOcclusionValues_GetSizeOf(); }
}
protected override void DefaultConstructAtIntPtr(System.IntPtr address)
{
AkSoundEnginePINVOKE.CSharp_AkObstructionOcclusionValues_Clear(address);
}
protected override AkObstructionOcclusionValues CreateNewReferenceFromIntPtr(System.IntPtr address)
{
return new AkObstructionOcclusionValues(address, false);
}
protected override void CloneIntoReferenceFromIntPtr(System.IntPtr address, AkObstructionOcclusionValues other)
{
AkSoundEnginePINVOKE.CSharp_AkObstructionOcclusionValues_Clone(address, AkObstructionOcclusionValues.getCPtr(other));
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d17160a19f95c1c469beb659d778f558
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,82 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2012 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
public class AkPositionArray : System.IDisposable
{
public System.IntPtr m_Buffer;
private System.IntPtr m_Current;
private uint m_MaxCount;
public AkPositionArray(uint in_Count)
{
m_Buffer = System.Runtime.InteropServices.Marshal.AllocHGlobal((int) in_Count * sizeof(float) * 9);
m_Current = m_Buffer;
m_MaxCount = in_Count;
Count = 0;
}
public uint Count { get; private set; }
public void Dispose()
{
if (m_Buffer != System.IntPtr.Zero)
{
System.Runtime.InteropServices.Marshal.FreeHGlobal(m_Buffer);
m_Buffer = System.IntPtr.Zero;
m_MaxCount = 0;
}
}
~AkPositionArray()
{
Dispose();
}
public void Reset()
{
m_Current = m_Buffer;
Count = 0;
}
public void Add(UnityEngine.Vector3 in_Pos, UnityEngine.Vector3 in_Forward, UnityEngine.Vector3 in_Top)
{
if (Count >= m_MaxCount)
throw new System.IndexOutOfRangeException("Out of range access in AkPositionArray");
//Marshal doesn't do floats. So copy the bytes themselves. Grrr.
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Forward.x), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Forward.y), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Forward.z), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Top.x), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Top.y), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Top.z), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Pos.x), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Pos.y), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
System.Runtime.InteropServices.Marshal.WriteInt32(m_Current,
System.BitConverter.ToInt32(System.BitConverter.GetBytes(in_Pos.z), 0));
m_Current = (System.IntPtr) (m_Current.ToInt64() + sizeof(float));
Count++;
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8b6caafc2e039dc4594fb2dd58ecdd3f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,29 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2012 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
public class AkReflectionPathInfoArray : AkBaseArray<AkReflectionPathInfo>
{
public AkReflectionPathInfoArray(int count) : base(count)
{
}
protected override int StructureSize
{
get { return AkSoundEnginePINVOKE.CSharp_AkReflectionPathInfo_GetSizeOf(); }
}
protected override AkReflectionPathInfo CreateNewReferenceFromIntPtr(System.IntPtr address)
{
return new AkReflectionPathInfo(address, false);
}
protected override void CloneIntoReferenceFromIntPtr(System.IntPtr address, AkReflectionPathInfo other)
{
AkSoundEnginePINVOKE.CSharp_AkReflectionPathInfo_Clone(address, AkReflectionPathInfo.getCPtr(other));
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6b276d7a41816a443a972fa851779ec8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,34 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2019 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
public class AkSourceSettingsArray : AkBaseArray<AkSourceSettings>
{
public AkSourceSettingsArray(int count) : base(count)
{
}
protected override int StructureSize
{
get { return AkSoundEnginePINVOKE.CSharp_AkSourceSettings_GetSizeOf(); }
}
protected override void DefaultConstructAtIntPtr(System.IntPtr address)
{
AkSoundEnginePINVOKE.CSharp_AkSourceSettings_Clear(address);
}
protected override AkSourceSettings CreateNewReferenceFromIntPtr(System.IntPtr address)
{
return new AkSourceSettings(address, false);
}
protected override void CloneIntoReferenceFromIntPtr(System.IntPtr address, AkSourceSettings other)
{
AkSoundEnginePINVOKE.CSharp_AkSourceSettings_Clone(address, AkSourceSettings.getCPtr(other));
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d4b0a3a288067574780c39ef4162dfce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,34 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2012 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
public class AkTriangleArray : AkBaseArray<AkTriangle>
{
public AkTriangleArray(int count) : base(count)
{
}
protected override int StructureSize
{
get { return AkSoundEnginePINVOKE.CSharp_AkTriangle_GetSizeOf(); }
}
protected override void DefaultConstructAtIntPtr(System.IntPtr address)
{
AkSoundEnginePINVOKE.CSharp_AkTriangle_Clear(address);
}
protected override AkTriangle CreateNewReferenceFromIntPtr(System.IntPtr address)
{
return new AkTriangle(address, false);
}
protected override void CloneIntoReferenceFromIntPtr(System.IntPtr address, AkTriangle other)
{
AkSoundEnginePINVOKE.CSharp_AkTriangle_Clone(address, AkTriangle.getCPtr(other));
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9c9b0059eacece54aa96e30d7eb53d82
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c189a1d547caca846b58fdf546b232f4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,613 @@
#if !(UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
#if !AK_DISABLE_TIMELINE
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2020 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief Defines the behavior of a \ref AkTimelineEventPlayable within a \ref AkTimelineEventTrack.
/// \sa
/// - \ref AkTimelineEventTrack
/// - \ref AkTimelineEventPlayable
public class AkTimelineEventPlayableBehavior : UnityEngine.Playables.PlayableBehaviour
{
private float currentDuration = -1f;
private float currentDurationProportion = 1f;
private bool eventIsPlaying;
private bool fadeinTriggered;
private bool fadeoutTriggered;
private float previousEventStartTime;
private const uint CallbackFlags = (uint)(AkCallbackType.AK_EndOfEvent | AkCallbackType.AK_Duration);
private void CallbackHandler(object in_cookie, AkCallbackType in_type, AkCallbackInfo in_info)
{
if (in_type == AkCallbackType.AK_EndOfEvent)
{
eventIsPlaying = fadeinTriggered = fadeoutTriggered = false;
}
else if (in_type == AkCallbackType.AK_Duration)
{
var estimatedDuration = (in_info as AkDurationCallbackInfo).fEstimatedDuration;
currentDuration = estimatedDuration * currentDurationProportion / 1000f;
}
}
#if UNITY_EDITOR
private static bool CanPostEvents
{
get { return UnityEditor.SessionState.GetBool("AkTimelineEventPlayableBehavior.CanPostEvents", true); }
set { UnityEditor.SessionState.SetBool("AkTimelineEventPlayableBehavior.CanPostEvents", value); }
}
[UnityEditor.InitializeOnLoadMethod]
private static void DetermineCanPostEvents()
{
UnityEditor.Compilation.CompilationPipeline.assemblyCompilationFinished += (string text, UnityEditor.Compilation.CompilerMessage[] messages) =>
{
if (!UnityEditor.EditorApplication.isPlaying)
CanPostEvents = false;
};
UnityEditor.EditorApplication.playModeStateChanged += (UnityEditor.PlayModeStateChange playMode) =>
{
if (playMode == UnityEditor.PlayModeStateChange.ExitingEditMode)
CanPostEvents = true;
};
}
#endif
[System.Flags]
private enum Actions
{
None = 0,
Playback = 1 << 0,
Retrigger = 1 << 1,
DelayedStop = 1 << 2,
Seek = 1 << 3,
FadeIn = 1 << 4,
FadeOut = 1 << 5
}
private Actions requiredActions;
private const int scrubPlaybackLengthMs = 100;
public AK.Wwise.Event akEvent;
public float eventDurationMax;
public float eventDurationMin;
public float blendInDuration;
public float blendOutDuration;
public float easeInDuration;
public float easeOutDuration;
public AkCurveInterpolation blendInCurve;
public AkCurveInterpolation blendOutCurve;
public UnityEngine.GameObject eventObject;
public bool retriggerEvent;
private bool wasScrubbingAndRequiresRetrigger;
public bool StopEventAtClipEnd;
private bool IsScrubbing(UnityEngine.Playables.FrameData info)
{
#if !UNITY_2018_2_OR_NEWER
// We disable scrubbing in edit mode, due to an issue with how FrameData.EvaluationType is handled in edit mode.
// This is a known issue and Unity are aware of it: https://fogbugz.unity3d.com/default.asp?953109_kitf7pso0vmjm0m0
if (!UnityEngine.Application.isPlaying)
return false;
#endif
return info.evaluationType == UnityEngine.Playables.FrameData.EvaluationType.Evaluate;
}
public override void PrepareFrame(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info)
{
base.PrepareFrame(playable, info);
if (akEvent == null)
return;
var shouldPlay = ShouldPlay(playable);
if (IsScrubbing(info) && shouldPlay)
{
requiredActions |= Actions.Seek;
if (!eventIsPlaying)
{
requiredActions |= Actions.Playback | Actions.DelayedStop;
CheckForFadeInFadeOut(playable);
}
}
else if (!eventIsPlaying && (requiredActions & Actions.Playback) == 0)
{
// The clip is playing but the event hasn't been triggered. We need to start the event and jump to the correct time.
requiredActions |= Actions.Retrigger;
CheckForFadeInFadeOut(playable);
}
else
{
CheckForFadeOut(playable, UnityEngine.Playables.PlayableExtensions.GetTime(playable));
}
}
private const float alph = 0.05f;
public override void OnBehaviourPlay(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info)
{
base.OnBehaviourPlay(playable, info);
if (akEvent == null)
return;
var shouldPlay = ShouldPlay(playable);
if (!shouldPlay)
return;
requiredActions |= Actions.Playback;
if (IsScrubbing(info))
{
wasScrubbingAndRequiresRetrigger = true;
// If we've explicitly set the playhead, only play a small snippet.
requiredActions |= Actions.DelayedStop;
}
else if (GetProportionalTime(playable) > alph)
{
// we need to jump to the correct position in the case where the event is played from some non-start position.
requiredActions |= Actions.Seek;
}
CheckForFadeInFadeOut(playable);
}
public override void OnBehaviourPause(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info)
{
wasScrubbingAndRequiresRetrigger = false;
base.OnBehaviourPause(playable, info);
if (eventObject != null && akEvent != null && StopEventAtClipEnd)
{
StopEvent();
}
}
public override void ProcessFrame(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info, object playerData)
{
base.ProcessFrame(playable, info, playerData);
if (akEvent == null)
return;
var obj = playerData as UnityEngine.GameObject;
if (obj != null)
eventObject = obj;
if (eventObject == null)
return;
if ((requiredActions & Actions.Playback) != 0)
PlayEvent();
if ((requiredActions & Actions.Seek) != 0)
SeekToTime(playable);
if ((retriggerEvent || wasScrubbingAndRequiresRetrigger) && (requiredActions & Actions.Retrigger) != 0)
RetriggerEvent(playable);
if ((requiredActions & Actions.DelayedStop) != 0)
StopEvent(scrubPlaybackLengthMs);
if (!fadeinTriggered && (requiredActions & Actions.FadeIn) != 0)
TriggerFadeIn(playable);
if (!fadeoutTriggered && (requiredActions & Actions.FadeOut) != 0)
TriggerFadeOut(playable);
requiredActions = Actions.None;
}
/** Check the playable time against the Wwise event duration to see if playback should occur.
*/
private bool ShouldPlay(UnityEngine.Playables.Playable playable)
{
var previousTime = UnityEngine.Playables.PlayableExtensions.GetPreviousTime(playable);
var currentTime = UnityEngine.Playables.PlayableExtensions.GetTime(playable);
if (previousTime == 0.0 && System.Math.Abs(currentTime - previousTime) > 1.0)
return false;
if (retriggerEvent)
return true;
// If max and min duration values from metadata are equal, we can assume a deterministic event.
if (eventDurationMax == eventDurationMin && eventDurationMin != -1f)
return currentTime < eventDurationMax;
currentTime -= previousEventStartTime;
var maxDuration = currentDuration == -1f ? (float)UnityEngine.Playables.PlayableExtensions.GetDuration(playable) : currentDuration;
return currentTime < maxDuration;
}
private void CheckForFadeInFadeOut(UnityEngine.Playables.Playable playable)
{
var currentClipTime = UnityEngine.Playables.PlayableExtensions.GetTime(playable);
if (blendInDuration > currentClipTime || easeInDuration > currentClipTime)
requiredActions |= Actions.FadeIn;
CheckForFadeOut(playable, currentClipTime);
}
private void CheckForFadeOut(UnityEngine.Playables.Playable playable, double currentClipTime)
{
var timeLeft = UnityEngine.Playables.PlayableExtensions.GetDuration(playable) - currentClipTime;
if (blendOutDuration >= timeLeft || easeOutDuration >= timeLeft)
requiredActions |= Actions.FadeOut;
}
private void TriggerFadeIn(UnityEngine.Playables.Playable playable)
{
var currentClipTime = UnityEngine.Playables.PlayableExtensions.GetTime(playable);
var fadeDuration = UnityEngine.Mathf.Max(easeInDuration, blendInDuration) - currentClipTime;
if (fadeDuration > 0)
{
fadeinTriggered = true;
akEvent.ExecuteAction(eventObject, AkActionOnEventType.AkActionOnEventType_Pause, 0, blendOutCurve);
akEvent.ExecuteAction(eventObject, AkActionOnEventType.AkActionOnEventType_Resume, (int)(fadeDuration * 1000), blendInCurve);
}
}
private void TriggerFadeOut(UnityEngine.Playables.Playable playable)
{
fadeoutTriggered = true;
var fadeDuration = UnityEngine.Playables.PlayableExtensions.GetDuration(playable) - UnityEngine.Playables.PlayableExtensions.GetTime(playable);
akEvent.ExecuteAction(eventObject, AkActionOnEventType.AkActionOnEventType_Stop, (int)(fadeDuration * 1000), blendOutCurve);
}
private void StopEvent(int transition = 0)
{
if (!eventIsPlaying)
return;
akEvent.Stop(eventObject, transition);
#if UNITY_EDITOR
if (!UnityEditor.EditorApplication.isPlaying)
eventIsPlaying = false;
#endif
}
private bool PostEvent()
{
fadeinTriggered = fadeoutTriggered = false;
uint playingID;
#if UNITY_EDITOR
if (!CanPostEvents)
{
playingID = AkSoundEngine.AK_INVALID_PLAYING_ID;
}
else if (!UnityEditor.EditorApplication.isPlaying)
{
playingID = akEvent.Post(eventObject);
}
else
#endif
{
playingID = akEvent.Post(eventObject, CallbackFlags, CallbackHandler, null);
}
eventIsPlaying = playingID != AkSoundEngine.AK_INVALID_PLAYING_ID;
return eventIsPlaying;
}
private void PlayEvent()
{
if (!PostEvent())
return;
currentDurationProportion = 1f;
previousEventStartTime = 0f;
}
private void RetriggerEvent(UnityEngine.Playables.Playable playable)
{
wasScrubbingAndRequiresRetrigger = false;
if (!PostEvent())
return;
currentDurationProportion = 1f - SeekToTime(playable);
previousEventStartTime = (float)UnityEngine.Playables.PlayableExtensions.GetTime(playable);
}
private float GetProportionalTime(UnityEngine.Playables.Playable playable)
{
// If max and min duration values from metadata are equal, we can assume a deterministic event.
if (eventDurationMax == eventDurationMin && eventDurationMin != -1f)
{
// If the timeline clip has length greater than the event duration, we want to loop.
return (float)UnityEngine.Playables.PlayableExtensions.GetTime(playable) % eventDurationMax / eventDurationMax;
}
var currentTime = (float)UnityEngine.Playables.PlayableExtensions.GetTime(playable) - previousEventStartTime;
var maxDuration = currentDuration == -1f ? (float)UnityEngine.Playables.PlayableExtensions.GetDuration(playable) : currentDuration;
// If the timeline clip has length greater than the event duration, we want to loop.
return currentTime % maxDuration / maxDuration;
}
// Seek to the current time, taking looping into account.
private float SeekToTime(UnityEngine.Playables.Playable playable)
{
var proportionalTime = GetProportionalTime(playable);
if (proportionalTime >= 1f) // Avoids Wwise "seeking beyond end of event: audio will stop" error.
return 1f;
#if UNITY_EDITOR
if (!CanPostEvents)
return proportionalTime;
#endif
if (eventIsPlaying)
AkSoundEngine.SeekOnEvent(akEvent.Id, eventObject, proportionalTime);
return proportionalTime;
}
}
/// @brief A playable asset containing a Wwise event that can be placed within a \ref AkTimelineEventTrack in a timeline.
/// @details Use this class to play Wwise events from a timeline and synchronize them to the animation. Events will be emitted from the GameObject that is bound to the AkTimelineEventTrack.
/// \sa
/// - \ref AkTimelineEventTrack
/// - \ref AkTimelineEventPlayableBehavior
public class AkTimelineEventPlayable : UnityEngine.Playables.PlayableAsset, UnityEngine.Timeline.ITimelineClipAsset
{
public AK.Wwise.Event akEvent = new AK.Wwise.Event();
[UnityEngine.SerializeField]
private AkCurveInterpolation blendInCurve = AkCurveInterpolation.AkCurveInterpolation_Linear;
[UnityEngine.SerializeField]
private AkCurveInterpolation blendOutCurve = AkCurveInterpolation.AkCurveInterpolation_Linear;
public float eventDurationMax = -1f;
public float eventDurationMin = -1f;
[System.NonSerialized]
public UnityEngine.Timeline.TimelineClip owningClip;
[UnityEngine.SerializeField]
private bool retriggerEvent = false;
public bool UseWwiseEventDuration = true;
[UnityEngine.SerializeField]
private bool StopEventAtClipEnd = true;
UnityEngine.Timeline.ClipCaps UnityEngine.Timeline.ITimelineClipAsset.clipCaps
{
get { return UnityEngine.Timeline.ClipCaps.Looping | UnityEngine.Timeline.ClipCaps.Blending; }
}
public override UnityEngine.Playables.Playable CreatePlayable(UnityEngine.Playables.PlayableGraph graph, UnityEngine.GameObject owner)
{
var playable = UnityEngine.Playables.ScriptPlayable<AkTimelineEventPlayableBehavior>.Create(graph);
if (akEvent == null)
return playable;
var b = playable.GetBehaviour();
b.akEvent = akEvent;
b.blendInCurve = blendInCurve;
b.blendOutCurve = blendOutCurve;
if (owningClip != null)
{
b.easeInDuration = (float)owningClip.easeInDuration;
b.easeOutDuration = (float)owningClip.easeOutDuration;
b.blendInDuration = (float)owningClip.blendInDuration;
b.blendOutDuration = (float)owningClip.blendOutDuration;
}
else
b.easeInDuration = b.easeOutDuration = b.blendInDuration = b.blendOutDuration = 0;
b.retriggerEvent = retriggerEvent;
b.StopEventAtClipEnd = StopEventAtClipEnd;
b.eventObject = owner;
b.eventDurationMin = eventDurationMin;
b.eventDurationMax = eventDurationMax;
return playable;
}
#if UNITY_EDITOR
[UnityEditor.CustomEditor(typeof(AkTimelineEventPlayable))]
public class Editor : UnityEditor.Editor
{
private AkTimelineEventPlayable m_AkTimelineEventPlayable;
private UnityEditor.SerializedProperty akEvent;
private UnityEditor.SerializedProperty retriggerEvent;
private UnityEditor.SerializedProperty UseWwiseEventDuration;
private UnityEditor.SerializedProperty StopEventAtClipEnd;
private UnityEditor.SerializedProperty blendInCurve;
private UnityEditor.SerializedProperty blendOutCurve;
public void OnEnable()
{
m_AkTimelineEventPlayable = target as AkTimelineEventPlayable;
if (m_AkTimelineEventPlayable == null)
return;
akEvent = serializedObject.FindProperty("akEvent");
retriggerEvent = serializedObject.FindProperty("retriggerEvent");
UseWwiseEventDuration = serializedObject.FindProperty("UseWwiseEventDuration");
StopEventAtClipEnd = serializedObject.FindProperty("StopEventAtClipEnd");
blendInCurve = serializedObject.FindProperty("blendInCurve");
blendOutCurve = serializedObject.FindProperty("blendOutCurve");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
{
UnityEditor.EditorGUILayout.PropertyField(akEvent, new UnityEngine.GUIContent("Event: "));
UnityEditor.EditorGUILayout.PropertyField(blendInCurve);
UnityEditor.EditorGUILayout.PropertyField(blendOutCurve);
}
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
{
UnityEditor.EditorGUILayout.PropertyField(UseWwiseEventDuration, new UnityEngine.GUIContent("Use Wwise Event Duration: ", "The clip duration is set to the duration of the Wwise Event"));
if (!UpdateClipInformation(m_AkTimelineEventPlayable.owningClip, m_AkTimelineEventPlayable.akEvent, serializedObject, UseWwiseEventDuration.boolValue))
{
UnityEditor.EditorGUILayout.HelpBox(string.Format("The duration of the Wwise event \"{0}\" has not been determined. Playback for this event may be inconsistent. " +
"Ensure that the event is associated with a generated SoundBank!", m_AkTimelineEventPlayable.akEvent.Name), UnityEditor.MessageType.Warning);
}
if (!UseWwiseEventDuration.boolValue)
{
var StopEventAtClipEndValue = StopEventAtClipEnd.boolValue;
var retriggerEventValue = retriggerEvent.boolValue;
UnityEditor.EditorGUILayout.PropertyField(StopEventAtClipEnd, new UnityEngine.GUIContent("Stop Event At End Of Clip: "));
UnityEditor.EditorGUILayout.PropertyField(retriggerEvent, new UnityEngine.GUIContent("Loop: ", "When checked, an event will loop until the end of the clip."));
if (retriggerEvent.boolValue && !StopEventAtClipEnd.boolValue)
{
if (!retriggerEventValue)
StopEventAtClipEnd.boolValue = true;
else if (StopEventAtClipEndValue)
retriggerEvent.boolValue = false;
}
}
}
serializedObject.ApplyModifiedProperties();
}
private static void UpdateProgressBar(int index, int count)
{
float progress = (float)index / count;
UnityEditor.EditorUtility.DisplayProgressBar("Wwise Integration", "Fixing clip durations of AkTimelineEventPlayables...", progress);
}
[UnityEditor.InitializeOnLoadMethod]
public static void SetupSoundbankSetting()
{
AkUtilities.EnableBoolSoundbankSettingInWproj("SoundBankGenerateEstimatedDuration", AkWwiseEditorSettings.WwiseProjectAbsolutePath);
UnityEditor.EditorApplication.update += RunOnce;
AkWwiseXMLWatcher.Instance.XMLUpdated += UpdateAllClips;
}
private static void RunOnce()
{
UpdateAllClips();
UnityEditor.EditorApplication.update -= RunOnce;
}
private static void UpdateAllClips()
{
var guids = UnityEditor.AssetDatabase.FindAssets("t:AkTimelineEventPlayable", new[] { "Assets" });
if (guids.Length < 1)
return;
var processedGuids = new System.Collections.Generic.HashSet<string>();
for (var i = 0; i < guids.Length; i++)
{
UpdateProgressBar(i, guids.Length);
var guid = guids[i];
if (processedGuids.Contains(guid))
continue;
processedGuids.Add(guid);
var path = UnityEditor.AssetDatabase.GUIDToAssetPath(guid);
var objects = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(path);
var instanceIds = new System.Collections.Generic.List<int>();
foreach (var obj in objects)
{
if (obj == null)
continue;
var id = obj.GetInstanceID();
if (!instanceIds.Contains(id))
instanceIds.Add(id);
}
for (; instanceIds.Count > 0; instanceIds.RemoveAt(0))
{
var id = instanceIds[0];
objects = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(path);
foreach (var obj in objects)
{
if (obj && obj.GetInstanceID() == id)
{
var playable = obj as AkTimelineEventPlayable;
if (playable)
{
var serializedObject = new UnityEditor.SerializedObject(playable);
var setClipDuration = serializedObject.FindProperty("UseWwiseEventDuration").boolValue;
UpdateClipInformation(playable.owningClip, playable.akEvent, serializedObject, setClipDuration);
serializedObject.ApplyModifiedProperties();
}
break;
}
}
}
}
UnityEditor.EditorUtility.ClearProgressBar();
}
/// <summary>
/// The minimum clip duration. This value is set to 1/60 of a second which generally represents the time of 1 frame.
/// </summary>
private const double MinimumDurationInSeconds = 1.0 / 60;
/// <summary>
/// Updates the associated clip information and the event durations.
/// </summary>
/// <returns>Returns true if the Wwise event is found in the project data.</returns>
private static bool UpdateClipInformation(UnityEngine.Timeline.TimelineClip clip, AK.Wwise.Event akEvent,
UnityEditor.SerializedObject serializedObject, bool setClipDuration)
{
var clipDuration = MinimumDurationInSeconds;
var maxDuration = -1.0f;
var minDuration = -1.0f;
AkUtilities.GetEventDurations(akEvent.Id, ref maxDuration, ref minDuration);
if (maxDuration != -1.0f)
{
serializedObject.FindProperty("eventDurationMin").floatValue = minDuration;
serializedObject.FindProperty("eventDurationMax").floatValue = maxDuration;
if (maxDuration > clipDuration)
clipDuration = maxDuration;
}
if (clip != null)
{
clip.displayName = akEvent.Name;
if (setClipDuration)
clip.duration = clipDuration;
}
return maxDuration != -1.0f;
}
}
#endif //#if UNITY_EDITOR
}
#endif // !AK_DISABLE_TIMELINE
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3223e1ae83677c04db9d173bfe79d7da
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,36 @@
#if !(UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
#if !AK_DISABLE_TIMELINE
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2020 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
[UnityEngine.Timeline.TrackColor(0.855f, 0.8623f, 0.870f)]
[UnityEngine.Timeline.TrackClipType(typeof(AkTimelineEventPlayable))]
[UnityEngine.Timeline.TrackBindingType(typeof(UnityEngine.GameObject))]
/// @brief A track within timeline that holds \ref AkTimelineEventPlayable clips.
/// @details AkTimelineEventTracks are bound to specific GameObjects, which are the default emitters for all of the associated \ref AkTimelineEventPlayable clips.
/// \sa
/// - \ref AkTimelineEventPlayable
/// - \ref AkTimelineEventPlayableBehavior
public class AkTimelineEventTrack : UnityEngine.Timeline.TrackAsset
{
public override UnityEngine.Playables.Playable CreateTrackMixer(UnityEngine.Playables.PlayableGraph graph, UnityEngine.GameObject go, int inputCount)
{
var playable = UnityEngine.Playables.ScriptPlayable<AkTimelineEventPlayableBehavior>.Create(graph);
UnityEngine.Playables.PlayableExtensions.SetInputCount(playable, inputCount);
var clips = GetClips();
foreach (var clip in clips)
{
var eventPlayable = clip.asset as AkTimelineEventPlayable;
eventPlayable.owningClip = clip;
}
return playable;
}
}
#endif // !AK_DISABLE_TIMELINE
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8b823c1a0a235894ba3b7745110ac39a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,113 @@
#if !(UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
#if !AK_DISABLE_TIMELINE
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2020 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
[System.Serializable]
public class AkTimelineRtpcPlayableBehaviour : UnityEngine.Playables.PlayableBehaviour
{
[UnityEngine.SerializeField]
private float value = 0.0f;
public AK.Wwise.RTPC RTPC { set; get; }
public bool setGlobally { set; get; }
public UnityEngine.GameObject gameObject { set; get; }
public override void ProcessFrame(UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData frameData, object playerData)
{
base.ProcessFrame(playable, frameData, playerData);
if (RTPC == null)
return;
var obj = playerData as UnityEngine.GameObject;
if (obj != null)
gameObject = obj;
if (setGlobally)
RTPC.SetGlobalValue(value);
else if (gameObject)
RTPC.SetValue(gameObject, value);
}
}
public class AkTimelineRtpcPlayable : UnityEngine.Playables.PlayableAsset, UnityEngine.Timeline.ITimelineClipAsset
{
public AK.Wwise.RTPC RTPC = new AK.Wwise.RTPC();
public bool setGlobally = false;
public AkTimelineRtpcPlayableBehaviour template = new AkTimelineRtpcPlayableBehaviour();
public void SetupClipDisplay()
{
#if UNITY_EDITOR
if (owningClip != null)
owningClip.displayName = RTPC.Name;
#endif
}
public UnityEngine.Timeline.TimelineClip owningClip { get; set; }
UnityEngine.Timeline.ClipCaps UnityEngine.Timeline.ITimelineClipAsset.clipCaps
{
get { return UnityEngine.Timeline.ClipCaps.Looping & UnityEngine.Timeline.ClipCaps.Extrapolation & UnityEngine.Timeline.ClipCaps.Blending; }
}
public override UnityEngine.Playables.Playable CreatePlayable(UnityEngine.Playables.PlayableGraph graph, UnityEngine.GameObject gameObject)
{
var playable = UnityEngine.Playables.ScriptPlayable<AkTimelineRtpcPlayableBehaviour>.Create(graph, template);
var b = playable.GetBehaviour();
b.RTPC = RTPC;
b.setGlobally = setGlobally;
b.gameObject = gameObject;
return playable;
}
#if UNITY_EDITOR
[UnityEditor.CustomEditor(typeof(AkTimelineRtpcPlayable))]
public class Editor : UnityEditor.Editor
{
private AkTimelineRtpcPlayable playable;
private UnityEditor.SerializedProperty RTPC;
private UnityEditor.SerializedProperty setGlobally;
private UnityEditor.SerializedProperty Behaviour;
public void OnEnable()
{
playable = target as AkTimelineRtpcPlayable;
if (playable)
playable.SetupClipDisplay();
RTPC = serializedObject.FindProperty("RTPC");
setGlobally = serializedObject.FindProperty("setGlobally");
Behaviour = serializedObject.FindProperty("template");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
{
UnityEditor.EditorGUILayout.PropertyField(RTPC, new UnityEngine.GUIContent("RTPC: "));
UnityEditor.EditorGUILayout.PropertyField(setGlobally, new UnityEngine.GUIContent("Set Globally: "));
}
if (Behaviour != null)
UnityEditor.EditorGUILayout.PropertyField(Behaviour, new UnityEngine.GUIContent("Animated Value: "), true);
if (playable)
playable.SetupClipDisplay();
serializedObject.ApplyModifiedProperties();
}
}
#endif //#if UNITY_EDITOR
}
#endif // !AK_DISABLE_TIMELINE
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b332aa80f675bbb45acc67af4b60a233
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,34 @@
#if !(UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
#if !AK_DISABLE_TIMELINE
[UnityEngine.Timeline.TrackColor(0.32f, 0.13f, 0.13f)]
// Specifies the type of Playable Asset this track manages
[UnityEngine.Timeline.TrackClipType(typeof(AkTimelineRtpcPlayable))]
// Use if the track requires a binding to a scene object or asset
[UnityEngine.Timeline.TrackBindingType(typeof(UnityEngine.GameObject))]
public class AkTimelineRtpcTrack : UnityEngine.Timeline.TrackAsset
{
public override UnityEngine.Playables.Playable CreateTrackMixer(UnityEngine.Playables.PlayableGraph graph, UnityEngine.GameObject gameObject, int inputCount)
{
var playable = UnityEngine.Playables.ScriptPlayable<AkTimelineRtpcPlayableBehaviour>.Create(graph, inputCount);
var clips = GetClips();
foreach (var clip in clips)
{
var rtpcPlayable = (clip.asset as AkTimelineRtpcPlayable);
rtpcPlayable.owningClip = clip;
rtpcPlayable.SetupClipDisplay();
}
return playable;
}
public void OnValidate()
{
var clips = GetClips();
foreach (var clip in clips)
(clip.asset as AkTimelineRtpcPlayable).SetupClipDisplay();
}
}
#endif // !AK_DISABLE_TIMELINE
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 145c22505b002a34e806e5ab7406dc23
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b468db3f75dd9e047b504ed7847c7f68
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,11 @@
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief Represents Wwise banks as Unity assets.
public class WwiseAcousticTextureReference : WwiseObjectReference
{
public override WwiseObjectType WwiseObjectType { get { return WwiseObjectType.AcousticTexture; } }
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 06f5301867c001e498bacd60229f97b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,11 @@
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief Represents Wwise aux buses as Unity assets.
public class WwiseAuxBusReference : WwiseObjectReference
{
public override WwiseObjectType WwiseObjectType { get { return WwiseObjectType.AuxBus; } }
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 349962f0079c3a144b1a5c347e639b60
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,11 @@
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief Represents Wwise banks as Unity assets.
public class WwiseBankReference : WwiseObjectReference
{
public override WwiseObjectType WwiseObjectType { get { return WwiseObjectType.Soundbank; } }
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c22c2793049fddb4f9d86aff4ed3758a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,11 @@
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief Represents Wwise events as Unity assets.
public class WwiseEventReference : WwiseObjectReference
{
public override WwiseObjectType WwiseObjectType { get { return WwiseObjectType.Event; } }
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6ef9016339588f1468b0a265018b774b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,328 @@
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief Represents Wwise objects as Unity assets.
public abstract class WwiseObjectReference : UnityEngine.ScriptableObject
{
#region Serialized fields
[AkShowOnly]
[UnityEngine.SerializeField]
private string objectName = string.Empty;
[AkShowOnly]
[UnityEngine.SerializeField]
private uint id = AkSoundEngine.AK_INVALID_UNIQUE_ID;
[AkShowOnly]
[UnityEngine.SerializeField]
private string guid = string.Empty;
#endregion
#region Properties
/// <summary>
/// The Wwise GUID which is represented by the ScriptableObject's asset file name.
/// </summary>
public System.Guid Guid
{
get { return string.IsNullOrEmpty(guid) ? System.Guid.Empty : new System.Guid(guid); }
}
/// <summary>
/// The name of the Wwise object.
/// </summary>
public string ObjectName { get { return objectName; } }
/// <summary>
/// The display name for the Wwise object.
/// </summary>
public virtual string DisplayName { get { return ObjectName; } }
/// <summary>
/// The Wwise ID.
/// </summary>
public uint Id { get { return id; } }
/// <summary>
/// The type of the Wwise object resource (for example: Event, State or Switch).
/// </summary>
public abstract WwiseObjectType WwiseObjectType { get; }
#endregion
#if UNITY_EDITOR
#region Creation and File Management
private static readonly System.Collections.Generic.Dictionary<WwiseObjectType, System.Type> m_WwiseObjectReferenceClasses
= new System.Collections.Generic.Dictionary<WwiseObjectType, System.Type>
{
{ WwiseObjectType.AcousticTexture, typeof(WwiseAcousticTextureReference) },
{ WwiseObjectType.AuxBus, typeof(WwiseAuxBusReference) },
{ WwiseObjectType.Soundbank, typeof(WwiseBankReference) },
{ WwiseObjectType.Event, typeof(WwiseEventReference) },
{ WwiseObjectType.GameParameter, typeof(WwiseRtpcReference) },
{ WwiseObjectType.StateGroup, typeof(WwiseStateGroupReference) },
{ WwiseObjectType.State, typeof(WwiseStateReference) },
{ WwiseObjectType.SwitchGroup, typeof(WwiseSwitchGroupReference) },
{ WwiseObjectType.Switch, typeof(WwiseSwitchReference) },
{ WwiseObjectType.Trigger, typeof(WwiseTriggerReference) },
};
private static WwiseObjectReference Create(WwiseObjectType wwiseObjectType)
{
System.Type type = null;
if (m_WwiseObjectReferenceClasses.TryGetValue(wwiseObjectType, out type))
return (WwiseObjectReference)CreateInstance(type);
return CreateInstance<WwiseObjectReference>();
}
private static WwiseObjectReference FindExistingWwiseObject(WwiseObjectType wwiseObjectType, System.Guid guid, string path)
{
var asset = UnityEditor.AssetDatabase.LoadAssetAtPath<WwiseObjectReference>(path);
if (asset)
return asset;
System.Type type = null;
if (!m_WwiseObjectReferenceClasses.TryGetValue(wwiseObjectType, out type))
return null;
var guids = UnityEditor.AssetDatabase.FindAssets("t:" + type.Name);
foreach (var assetGuid in guids)
{
var assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assetGuid);
asset = UnityEditor.AssetDatabase.LoadAssetAtPath<WwiseObjectReference>(assetPath);
if (asset && asset.WwiseObjectType == wwiseObjectType && asset.Guid == guid)
return asset;
}
return null;
}
private static bool UpdateWwiseObjectData(WwiseObjectReference wwiseObjectReference, string name)
{
var id = AkUtilities.ShortIDGenerator.Compute(name);
if (wwiseObjectReference.objectName == name && wwiseObjectReference.id == id)
return false;
wwiseObjectReference.objectName = name;
wwiseObjectReference.id = id;
return true;
}
public static string GetParentPath(WwiseObjectType wwiseObjectType)
{
return System.IO.Path.Combine(AkWwiseEditorSettings.WwiseScriptableObjectRelativePath, wwiseObjectType.ToString());
}
public static string GetAssetFileName(System.Guid guid)
{
return guid.ToString().ToUpper() + ".asset";
}
public static WwiseObjectReference FindOrCreateWwiseObject(WwiseObjectType wwiseObjectType, string name, System.Guid guid)
{
var parentPath = GetParentPath(wwiseObjectType);
var path = System.IO.Path.Combine(parentPath, GetAssetFileName(guid));
var asset = FindExistingWwiseObject(wwiseObjectType, guid, path);
var assetExists = asset != null;
if (!assetExists)
{
AkUtilities.CreateFolder(parentPath);
asset = Create(wwiseObjectType);
asset.guid = guid.ToString().ToUpper();
}
var changed = UpdateWwiseObjectData(asset, name);
if (!assetExists)
UnityEditor.AssetDatabase.CreateAsset(asset, path);
else if (changed)
UnityEditor.EditorUtility.SetDirty(asset);
return asset;
}
public static void UpdateWwiseObject(WwiseObjectType wwiseObjectType, string name, System.Guid guid)
{
var path = System.IO.Path.Combine(GetParentPath(wwiseObjectType), GetAssetFileName(guid));
var asset = FindExistingWwiseObject(wwiseObjectType, guid, path);
if (asset && UpdateWwiseObjectData(asset, name))
UnityEditor.EditorUtility.SetDirty(asset);
}
public static void DeleteWwiseObject(WwiseObjectType wwiseObjectType, System.Guid guid)
{
var path = System.IO.Path.Combine(GetParentPath(wwiseObjectType), GetAssetFileName(guid));
var guidString = UnityEditor.AssetDatabase.AssetPathToGUID(path);
if (!string.IsNullOrEmpty(guidString))
UnityEditor.AssetDatabase.DeleteAsset(path);
}
#endregion
#region WwiseMigration
private class WwiseObjectData
{
public string objectName;
}
private static System.Collections.Generic.Dictionary<WwiseObjectType, System.Collections.Generic.Dictionary<System.Guid, WwiseObjectData>> WwiseObjectDataMap
= new System.Collections.Generic.Dictionary<WwiseObjectType, System.Collections.Generic.Dictionary<System.Guid, WwiseObjectData>>();
public static void ClearWwiseObjectDataMap()
{
WwiseObjectDataMap.Clear();
}
public static void UpdateWwiseObjectDataMap(WwiseObjectType wwiseObjectType, string name, System.Guid guid)
{
System.Collections.Generic.Dictionary<System.Guid, WwiseObjectData> map = null;
if (!WwiseObjectDataMap.TryGetValue(wwiseObjectType, out map))
{
map = new System.Collections.Generic.Dictionary<System.Guid, WwiseObjectData>();
WwiseObjectDataMap.Add(wwiseObjectType, map);
}
WwiseObjectData data = null;
if (!map.TryGetValue(guid, out data))
{
data = new WwiseObjectData();
map.Add(guid, data);
}
data.objectName = name;
}
public static WwiseObjectReference GetWwiseObjectForMigration(WwiseObjectType wwiseObjectType, byte[] valueGuid, int id)
{
if (valueGuid == null)
{
return null;
}
System.Collections.Generic.Dictionary<System.Guid, WwiseObjectData> map = null;
if (!WwiseObjectDataMap.TryGetValue(wwiseObjectType, out map) || map == null)
{
UnityEngine.Debug.LogWarning("WwiseUnity: Cannot find WwiseObjectReferences of type <WwiseObjectType." + wwiseObjectType + ">.");
return null;
}
var guid = System.Guid.Empty;
WwiseObjectData data = null;
try
{
guid = new System.Guid(valueGuid);
}
catch
{
UnityEngine.Debug.LogWarning("WwiseUnity: Invalid guid for WwiseObjectReference of type <WwiseObjectType." + wwiseObjectType + ">.");
return null;
}
var formattedId = (uint)id;
if (guid != System.Guid.Empty && !map.TryGetValue(guid, out data))
{
UnityEngine.Debug.LogWarning("WwiseUnity: Cannot find guid <" + guid.ToString() + "> for WwiseObjectReference of type <WwiseObjectType." + wwiseObjectType + "> in Wwise Project.");
foreach (var pair in map)
{
if (AkUtilities.ShortIDGenerator.Compute(pair.Value.objectName) == formattedId)
{
guid = pair.Key;
data = pair.Value;
UnityEngine.Debug.LogWarning("WwiseUnity: Found guid <" + guid.ToString() + "> for <" + pair.Value.objectName + ">.");
break;
}
}
}
if (data == null)
{
return null;
}
var objectReference = FindOrCreateWwiseObject(wwiseObjectType, data.objectName, guid);
if (objectReference && objectReference.Id != formattedId)
{
UnityEngine.Debug.LogWarning("WwiseUnity: ID mismatch for WwiseObjectReference of type <WwiseObjectType." + wwiseObjectType + ">. Expected <" + formattedId + ">. Found <" + objectReference.Id + ">.");
}
return objectReference;
}
#endregion
#endif
}
/// @brief Represents Wwise group value objects (such as states and switches) as Unity assets.
public abstract class WwiseGroupValueObjectReference : WwiseObjectReference
{
#region Properties
/// <summary>
/// The group object reference.
/// </summary>
public abstract WwiseObjectReference GroupObjectReference { get; set; }
/// <summary>
/// The type of the Wwise object resource (for example: Event, State or Switch).
/// </summary>
public abstract WwiseObjectType GroupWwiseObjectType { get; }
/// <summary>
/// The display name for the Wwise object.
/// </summary>
public override string DisplayName
{
get
{
#if AK_DISPLAY_GROUP_TYPES_WITH_SINGLE_NAME
return ObjectName;
#else
var groupReference = GroupObjectReference;
if (!groupReference)
return ObjectName;
return groupReference.ObjectName + " / " + ObjectName;
#endif // AK_DISPLAY_GROUP_TYPES_WITH_SINGLE_NAME
}
}
#endregion
#if UNITY_EDITOR
public void SetupGroupObjectReference(string name, System.Guid guid)
{
var objectReference = FindOrCreateWwiseObject(GroupWwiseObjectType, name, guid);
if (objectReference != GroupObjectReference)
{
GroupObjectReference = objectReference;
UnityEditor.EditorUtility.SetDirty(this);
}
}
#region WwiseMigration
public static WwiseGroupValueObjectReference GetWwiseObjectForMigration(WwiseObjectType wwiseObjectType, byte[] valueGuid, int id, byte[] groupGuid, int groupId)
{
var objectReference = GetWwiseObjectForMigration(wwiseObjectType, valueGuid, id);
if (!objectReference)
return null;
var groupValueObjectReference = objectReference as WwiseGroupValueObjectReference;
if (!groupValueObjectReference)
{
UnityEngine.Debug.LogWarning("WwiseUnity: Not setting WwiseObjectReference since it is not a WwiseGroupValueObjectReference.");
return null;
}
var groupObjectReference = GetWwiseObjectForMigration(groupValueObjectReference.GroupWwiseObjectType, groupGuid, groupId);
if (!groupObjectReference)
{
UnityEngine.Debug.LogWarning("WwiseUnity: Not setting WwiseObjectReference since its GroupObjectReference cannot be determined.");
return null;
}
groupValueObjectReference.GroupObjectReference = groupObjectReference;
UnityEditor.EditorUtility.SetDirty(groupValueObjectReference);
return groupValueObjectReference;
}
#endregion
#endif
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 711311f5a3d011a4a9cfbd5297e0ef17
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,28 @@
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// <summary>
/// Enumeration of Wwise object types that can be found in a Wwise project.
/// </summary>
public enum WwiseObjectType
{
None,
AuxBus,
Bus,
Event,
Folder,
PhysicalFolder,
Project,
Soundbank,
State,
StateGroup,
Switch,
SwitchGroup,
WorkUnit,
GameParameter,
Trigger,
AcousticTexture
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 36da97e70be47ef40ad74c5296e76f2f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,11 @@
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief Represents Wwise RTPCs as Unity assets.
public class WwiseRtpcReference : WwiseObjectReference
{
public override WwiseObjectType WwiseObjectType { get { return WwiseObjectType.GameParameter; } }
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b970bf2906600d142bf17beed92ebdb7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,11 @@
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief Represents Wwise state groups as Unity assets.
public class WwiseStateGroupReference : WwiseObjectReference
{
public override WwiseObjectType WwiseObjectType { get { return WwiseObjectType.StateGroup; } }
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0e72cc3e5b2e00e41bd595068b549224
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,23 @@
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief Represents Wwise states as Unity assets.
public class WwiseStateReference : WwiseGroupValueObjectReference
{
[AkShowOnly]
[UnityEngine.SerializeField]
private WwiseStateGroupReference WwiseStateGroupReference;
public override WwiseObjectType WwiseObjectType { get { return WwiseObjectType.State; } }
public override WwiseObjectReference GroupObjectReference
{
get { return WwiseStateGroupReference; }
set { WwiseStateGroupReference = value as WwiseStateGroupReference; }
}
public override WwiseObjectType GroupWwiseObjectType { get { return WwiseObjectType.StateGroup; } }
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: da2228710d4534f4bbbf09cae8e507e0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,11 @@
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief Represents Wwise switch groups as Unity assets.
public class WwiseSwitchGroupReference : WwiseObjectReference
{
public override WwiseObjectType WwiseObjectType { get { return WwiseObjectType.SwitchGroup; } }
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ead763eca402fa047a3594e01b51b4f6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,23 @@
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief Represents Wwise states as Unity assets.
public class WwiseSwitchReference : WwiseGroupValueObjectReference
{
[AkShowOnly]
[UnityEngine.SerializeField]
private WwiseSwitchGroupReference WwiseSwitchGroupReference;
public override WwiseObjectType WwiseObjectType { get { return WwiseObjectType.Switch; } }
public override WwiseObjectReference GroupObjectReference
{
get { return WwiseSwitchGroupReference; }
set { WwiseSwitchGroupReference = value as WwiseSwitchGroupReference; }
}
public override WwiseObjectType GroupWwiseObjectType { get { return WwiseObjectType.SwitchGroup; } }
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: af5d3be874e467c4ba76e417c2fac362
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,11 @@
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018 Audiokinetic Inc. / All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
/// @brief Represents Wwise triggers as Unity assets.
public class WwiseTriggerReference : WwiseObjectReference
{
public override WwiseObjectType WwiseObjectType { get { return WwiseObjectType.Trigger; } }
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6b1f2e8fb79fbe04a8f34e9b2da1c8aa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 547add351e62e2847b5dfbd11c8e8b65
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,20 @@
#if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.
namespace AK.Wwise
{
[System.Serializable]
///@brief This type represents an Acoustic Texture.
public class AcousticTexture : BaseType
{
public WwiseAcousticTextureReference WwiseObjectReference;
public override WwiseObjectReference ObjectReference
{
get { return WwiseObjectReference; }
set { WwiseObjectReference = value as WwiseAcousticTextureReference; }
}
public override WwiseObjectType WwiseObjectType { get { return WwiseObjectType.AcousticTexture; } }
}
}
#endif // #if ! (UNITY_DASHBOARD_WIDGET || UNITY_WEBPLAYER || UNITY_WII || UNITY_WIIU || UNITY_NACL || UNITY_FLASH || UNITY_BLACKBERRY) // Disable under unsupported platforms.

Some files were not shown because too many files have changed in this diff Show more