Feat : Wwise Integration
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3623a364982648c41aa4417832ac717f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,63 @@
|
||||
/*******************************************************************************
|
||||
The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
|
||||
Technology released in source code form as part of the game integration package.
|
||||
The content of this file may not be used without valid licenses to the
|
||||
AUDIOKINETIC Wwise Technology.
|
||||
Note that the use of the game engine is subject to the Unity(R) Terms of
|
||||
Service at https://unity3d.com/legal/terms-of-service
|
||||
|
||||
License Usage
|
||||
|
||||
Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
|
||||
this file in accordance with the end user license agreement provided with the
|
||||
software or, alternatively, in accordance with the terms contained
|
||||
in a written agreement between you and Audiokinetic Inc.
|
||||
Copyright (c) 2026 Audiokinetic Inc.
|
||||
*******************************************************************************/
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditor.VersionControl;
|
||||
|
||||
[UnityEditor.InitializeOnLoad]
|
||||
public abstract class AkPlatformPluginActivator
|
||||
{
|
||||
public abstract string WwisePlatformName { get; }
|
||||
public abstract string PluginDirectoryName { get; }
|
||||
public virtual ISet<string> Architectures => null;
|
||||
|
||||
public virtual string DSPDirectoryPath => string.Empty;
|
||||
|
||||
public virtual string StaticPluginRegistrationName => null;
|
||||
public virtual string StaticPluginDefine => null;
|
||||
|
||||
public virtual bool RequiresStaticPluginRegistration => false;
|
||||
|
||||
public virtual void FilterOutPlatformIfNeeded(BuildTarget target, PluginImporter pluginImporter,
|
||||
string pluginPlatform)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool IsPluginSDKVersionCompatible(string pluginSDKVersion)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
internal virtual bool IsBuildEnvironmentValid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
internal string[] GetPluginPathParts(string pluginPath)
|
||||
{
|
||||
var indexOfPluginFolder = pluginPath.IndexOf(AkPluginActivatorConstants.WwisePluginFolder, StringComparison.OrdinalIgnoreCase);
|
||||
return pluginPath.Substring(indexOfPluginFolder + AkPluginActivatorConstants.WwisePluginFolder.Length + 1).Split('/');
|
||||
}
|
||||
|
||||
public abstract AkPluginActivator.PluginImporterInformation GetPluginImporterInformation(PluginImporter pluginImporter);
|
||||
internal abstract bool ConfigurePlugin(PluginImporter pluginImporter, AkPluginActivator.PluginImporterInformation pluginImporterInformation);
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51091a89998818947a002e921393ccf2
|
||||
@@ -0,0 +1,283 @@
|
||||
/*******************************************************************************
|
||||
The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
|
||||
Technology released in source code form as part of the game integration package.
|
||||
The content of this file may not be used without valid licenses to the
|
||||
AUDIOKINETIC Wwise Technology.
|
||||
Note that the use of the game engine is subject to the Unity(R) Terms of
|
||||
Service at https://unity3d.com/legal/terms-of-service
|
||||
|
||||
License Usage
|
||||
|
||||
Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
|
||||
this file in accordance with the end user license agreement provided with the
|
||||
software or, alternatively, in accordance with the terms contained
|
||||
in a written agreement between you and Audiokinetic Inc.
|
||||
Copyright (c) 2026 Audiokinetic Inc.
|
||||
*******************************************************************************/
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using AK.Wwise.Unity.Logging;
|
||||
|
||||
internal class AkPlatformPluginList
|
||||
{
|
||||
private static readonly Dictionary<string, System.DateTime> s_LastParsed = new Dictionary<string, System.DateTime>();
|
||||
|
||||
private static readonly Dictionary<string, HashSet<AkPluginInfo>> s_PerPlatformPlugins = new Dictionary<string, HashSet<AkPluginInfo>>();
|
||||
|
||||
internal static void GetPluginsUsedForPlatform(string deploymentTargetName, out HashSet<AkPluginInfo> UsedPlugins)
|
||||
{
|
||||
s_PerPlatformPlugins.TryGetValue(deploymentTargetName, out UsedPlugins);
|
||||
}
|
||||
|
||||
internal static bool ContainsPlatform(string platform)
|
||||
{
|
||||
return s_PerPlatformPlugins.ContainsKey(platform);
|
||||
}
|
||||
|
||||
public static bool IsPluginUsed(AkPlatformPluginActivator in_config, string in_UnityPlatform, string in_PluginName)
|
||||
{
|
||||
var pluginDSPPlatform = in_config.WwisePlatformName;
|
||||
|
||||
if (!s_PerPlatformPlugins.ContainsKey(pluginDSPPlatform))
|
||||
{
|
||||
return false; //XML not parsed, don't touch anything.
|
||||
}
|
||||
|
||||
if (in_PluginName.Contains("AkUnitySoundEngine"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var pluginName = in_PluginName;
|
||||
if (in_PluginName.StartsWith("lib"))
|
||||
{
|
||||
pluginName = in_PluginName.Substring(3);
|
||||
}
|
||||
|
||||
const string factory = "Factory";
|
||||
int indexOfFactory = in_PluginName.IndexOf(factory);
|
||||
// Ensure the plugin name ends with "Factory.h"
|
||||
if (indexOfFactory != -1 && indexOfFactory + factory.Length == in_PluginName.Length)
|
||||
{
|
||||
pluginName = in_PluginName.Substring(0, indexOfFactory);
|
||||
}
|
||||
|
||||
System.Collections.Generic.HashSet<AkPluginInfo> plugins;
|
||||
if (s_PerPlatformPlugins.TryGetValue(pluginDSPPlatform, out plugins))
|
||||
{
|
||||
if (!in_config.RequiresStaticPluginRegistration)
|
||||
{
|
||||
foreach (var pluginInfo in plugins)
|
||||
{
|
||||
if (pluginInfo.DllName == pluginName ||
|
||||
(pluginInfo.StaticLibName == "AkMeterFX" && pluginName.Contains("AkSoundEngine")))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Exceptions
|
||||
if (!string.IsNullOrEmpty(in_config.StaticPluginRegistrationName) && pluginName.Contains(in_config.StaticPluginRegistrationName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//WebGL, iOS, tvOS, visionOS, and Switch deal with the static libs directly, unlike all other platforms.
|
||||
//Luckily the DLL name is always a subset of the lib name.
|
||||
foreach (var pluginInfo in plugins)
|
||||
{
|
||||
if (pluginInfo.StaticLibName == pluginName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void ExecuteParse()
|
||||
{
|
||||
Update();
|
||||
}
|
||||
public static void Update(bool forceUpdate = false)
|
||||
{
|
||||
//Gather all GeneratedSoundBanks folder from the project
|
||||
var allPaths = AkUtilities.GetAllBankPaths(AkWwiseEditorSettings.WwiseProjectAbsolutePath);
|
||||
var bNeedRefresh = false;
|
||||
var projectDir = AkBasePathGetter.GetWwiseProjectDirectory();
|
||||
var baseSoundBankPath = AkWwiseEditorSettings.GetRootOutputPath();
|
||||
|
||||
AkWwiseInitializationSettings.UpdatePlatforms();
|
||||
|
||||
//make a copy of the platform map and handle "special" custom platforms
|
||||
var platformMap = new Dictionary<string, List<string>>();
|
||||
foreach (var key in AkUtilities.PlatformMapping.Keys)
|
||||
{
|
||||
platformMap.Add(key, new List<string>(AkUtilities.PlatformMapping[key]));
|
||||
foreach (var customPF in AkUtilities.PlatformMapping[key])
|
||||
{
|
||||
if (customPF != key && (AkWwiseInitializationSettings.PlatformSettings.IsDistinctPlatform(customPF)))
|
||||
{
|
||||
platformMap.Add(customPF, new List<string> { customPF });
|
||||
platformMap[key].Remove(customPF);
|
||||
}
|
||||
}
|
||||
if (platformMap[key].Count==0)
|
||||
{
|
||||
platformMap.Remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Go through all BasePlatforms
|
||||
foreach (var pairPF in platformMap)
|
||||
{
|
||||
//Go through all custom platforms related to that base platform and check if any of the bank files were updated.
|
||||
var bParse = forceUpdate;
|
||||
var fullPaths = new System.Collections.Generic.List<string>();
|
||||
foreach (var customPF in pairPF.Value)
|
||||
{
|
||||
string bankPath;
|
||||
if (!allPaths.TryGetValue(customPF, out bankPath))
|
||||
continue;
|
||||
|
||||
var pluginFile = "";
|
||||
try
|
||||
{
|
||||
pluginFile = System.IO.Path.Combine(projectDir, System.IO.Path.Combine(bankPath, "PluginInfo.xml"));
|
||||
pluginFile = pluginFile.Replace('/', System.IO.Path.DirectorySeparatorChar);
|
||||
if (!System.IO.File.Exists(pluginFile))
|
||||
{
|
||||
//Try in StreamingAssets too.
|
||||
pluginFile = System.IO.Path.Combine(System.IO.Path.Combine(baseSoundBankPath, customPF), "PluginInfo.xml");
|
||||
if (!System.IO.File.Exists(pluginFile))
|
||||
continue;
|
||||
}
|
||||
|
||||
fullPaths.Add(pluginFile);
|
||||
|
||||
var t = System.IO.File.GetLastWriteTime(pluginFile);
|
||||
var lastTime = System.DateTime.MinValue;
|
||||
bool bParsedBefore = s_LastParsed.TryGetValue(customPF, out lastTime);
|
||||
if (!bParsedBefore || lastTime < t)
|
||||
{
|
||||
bParse = true;
|
||||
s_LastParsed[customPF] = t;
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
WwiseLogger.Error(pluginFile + " could not be parsed. " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
if (bParse)
|
||||
{
|
||||
var platform = pairPF.Key;
|
||||
|
||||
var newDlls = ParsePlugins(platform);
|
||||
System.Collections.Generic.HashSet<AkPluginInfo> oldDlls = null;
|
||||
|
||||
s_PerPlatformPlugins.TryGetValue(platform, out oldDlls);
|
||||
s_PerPlatformPlugins[platform] = newDlls;
|
||||
|
||||
//Check if there was any change.
|
||||
if (!bNeedRefresh && oldDlls != null)
|
||||
{
|
||||
if (oldDlls.Count == newDlls.Count)
|
||||
{
|
||||
oldDlls.IntersectWith(newDlls);
|
||||
}
|
||||
|
||||
bNeedRefresh |= oldDlls.Count != newDlls.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
bNeedRefresh |= newDlls.Count > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bNeedRefresh)
|
||||
{
|
||||
AkPluginActivator.ActivatePluginsForEditor();
|
||||
}
|
||||
}
|
||||
|
||||
private static bool PlatformUsesStaticLibs(string platform)
|
||||
{
|
||||
var pair = AkPluginActivator.BuildTargetToPlatformPluginActivator.FirstOrDefault(x => x.Value.WwisePlatformName == platform);
|
||||
|
||||
if (pair.Equals(default(KeyValuePair<BuildTarget, AkPlatformPluginActivator>)))
|
||||
{
|
||||
// Platform not found
|
||||
return false;
|
||||
}
|
||||
return pair.Value.RequiresStaticPluginRegistration;
|
||||
}
|
||||
|
||||
private static HashSet<AkPluginInfo> ParsePlugins(string platform)
|
||||
{
|
||||
var newPlugins = new System.Collections.Generic.HashSet<AkPluginInfo>();
|
||||
var usesStaticLibs = PlatformUsesStaticLibs(platform);
|
||||
|
||||
try
|
||||
{
|
||||
WwisePluginRefArray pluginRefArray = new WwisePluginRefArray();
|
||||
for (var i = 0; i < WwiseProjectDatabase.GetPluginCount(); i++)
|
||||
{
|
||||
var pluginRef = pluginRefArray[i];
|
||||
var rawPluginID = pluginRef.Id;
|
||||
if (rawPluginID == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
AkPluginActivatorConstants.PluginID pluginID = (AkPluginActivatorConstants.PluginID)rawPluginID;
|
||||
|
||||
if (AkPluginActivatorConstants.alwaysSkipPluginsIDs.Contains(pluginID))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var dll = string.Empty;
|
||||
|
||||
if (!usesStaticLibs && AkPluginActivatorConstants.builtInPluginIDs.Contains(pluginID))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(dll))
|
||||
{
|
||||
dll = pluginRef.DLL;
|
||||
}
|
||||
|
||||
var staticLibName = pluginRef.StaticLib;
|
||||
|
||||
AkPluginInfo newPluginInfo = new AkPluginInfo();
|
||||
newPluginInfo.PluginID = rawPluginID;
|
||||
newPluginInfo.DllName = dll;
|
||||
newPluginInfo.StaticLibName = staticLibName;
|
||||
|
||||
if (string.IsNullOrEmpty(newPluginInfo.StaticLibName) && !AkPluginActivatorConstants.PluginIDToStaticLibName.TryGetValue(pluginID, out newPluginInfo.StaticLibName))
|
||||
{
|
||||
newPluginInfo.StaticLibName = dll;
|
||||
}
|
||||
|
||||
newPlugins.Add(newPluginInfo);
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
WwiseLogger.Error("Plugins could not be parsed. " + ex.Message);
|
||||
}
|
||||
|
||||
return newPlugins;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a2902d2209b5cd48a0f4314a7199ff4
|
||||
@@ -0,0 +1,319 @@
|
||||
/*******************************************************************************
|
||||
The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
|
||||
Technology released in source code form as part of the game integration package.
|
||||
The content of this file may not be used without valid licenses to the
|
||||
AUDIOKINETIC Wwise Technology.
|
||||
Note that the use of the game engine is subject to the Unity(R) Terms of
|
||||
Service at https://unity3d.com/legal/terms-of-service
|
||||
|
||||
License Usage
|
||||
|
||||
Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
|
||||
this file in accordance with the end user license agreement provided with the
|
||||
software or, alternatively, in accordance with the terms contained
|
||||
in a written agreement between you and Audiokinetic Inc.
|
||||
Copyright (c) 2026 Audiokinetic Inc.
|
||||
*******************************************************************************/
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using AK.Wwise.Unity.Logging;
|
||||
|
||||
[InitializeOnLoad]
|
||||
public class AkPluginActivator : UnityEditor.AssetPostprocessor
|
||||
{
|
||||
private const string EditorConfiguration = AkPluginActivatorConstants.CONFIG_PROFILE;
|
||||
private static bool bIsAlreadyActivating = false;
|
||||
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths, bool didDomainReload)
|
||||
{
|
||||
if (UnityEditor.AssetDatabase.IsAssetImportWorkerProcess() || bIsAlreadyActivating)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (didDomainReload)
|
||||
{
|
||||
ActivatePluginsForEditor();
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetCurrentConfig()
|
||||
{
|
||||
var CurrentConfig = AkWwiseProjectInfo.GetData().CurrentPluginConfig;
|
||||
if (string.IsNullOrEmpty(CurrentConfig))
|
||||
{
|
||||
CurrentConfig = AkPluginActivatorConstants.CONFIG_PROFILE;
|
||||
}
|
||||
|
||||
return CurrentConfig;
|
||||
}
|
||||
|
||||
public static Dictionary<BuildTarget, AkPlatformPluginActivator> BuildTargetToPlatformPluginActivator = new Dictionary<BuildTarget, AkPlatformPluginActivator>();
|
||||
|
||||
public static void RegisterPlatformPluginActivator(BuildTarget target, AkPlatformPluginActivator platformPluginActivator)
|
||||
{
|
||||
WwiseLogger.Verbose("Adding platform " + target.ToString() + " to PluginActivator");
|
||||
BuildTargetToPlatformPluginActivator.Add(target, platformPluginActivator);
|
||||
}
|
||||
|
||||
internal static string GetPluginInfoPlatform(string path)
|
||||
{
|
||||
var indexOfPluginFolder = path.IndexOf(AkPluginActivatorConstants.WwisePluginFolder, StringComparison.OrdinalIgnoreCase);
|
||||
if (indexOfPluginFolder == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return path.Substring(indexOfPluginFolder + AkPluginActivatorConstants.WwisePluginFolder.Length + 1).Split('/')[0];
|
||||
}
|
||||
|
||||
internal static List<PluginImporter> GetWwisePluginImporters(string platformFilter = "")
|
||||
{
|
||||
PluginImporter[] pluginImporters = PluginImporter.GetAllImporters();
|
||||
List<PluginImporter> wwisePlugins = new List<PluginImporter>();
|
||||
foreach (var pluginImporter in pluginImporters)
|
||||
{
|
||||
if (pluginImporter.assetPath.Contains("Wwise/API/"))
|
||||
{
|
||||
if (string.IsNullOrEmpty(platformFilter) || platformFilter == GetPluginInfoPlatform(pluginImporter.assetPath))
|
||||
{
|
||||
wwisePlugins.Add(pluginImporter);
|
||||
}
|
||||
}
|
||||
}
|
||||
return wwisePlugins;
|
||||
}
|
||||
|
||||
public class PluginImporterInformation
|
||||
{
|
||||
public string PluginName;
|
||||
public string PluginArch;
|
||||
public string PluginSDKVersion;
|
||||
public string PluginConfig;
|
||||
|
||||
public string EditorOS;
|
||||
public string EditorCPU;
|
||||
|
||||
public bool IsX86 => PluginArch == "x86";
|
||||
public bool IsX64 => PluginArch == "x86_64";
|
||||
|
||||
public bool IsSupportLibrary => AkPluginActivatorConstants.SupportLibraries.Contains(PluginName);
|
||||
}
|
||||
|
||||
public static void ActivatePluginsForDeployment(BuildTarget target, bool Activate)
|
||||
{
|
||||
if (!BuildTargetToPlatformPluginActivator.TryGetValue(target, out var platformPluginActivator))
|
||||
{
|
||||
WwiseLogger.Error("Unable to find Plugin Activator for Build Target " + target + ". Check that platform " + target + " has been installed as part of your Wwise Integration.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!platformPluginActivator.IsBuildEnvironmentValid())
|
||||
{
|
||||
WwiseLogger.Error("Build Environment for platform " + platformPluginActivator.WwisePlatformName + " is not valid. Current BuildTarget is " + EditorUserBuildSettings.activeBuildTarget);
|
||||
return;
|
||||
}
|
||||
|
||||
bIsAlreadyActivating = true;
|
||||
|
||||
if (Activate)
|
||||
{
|
||||
StaticPluginRegistration.Setup(target, platformPluginActivator);
|
||||
}
|
||||
|
||||
var importers = GetWwisePluginImporters();
|
||||
var assetChanged = false;
|
||||
foreach (var pluginImporter in importers)
|
||||
{
|
||||
if (pluginImporter.GetCompatibleWithAnyPlatform())
|
||||
{
|
||||
WwiseLogger.Log("Plugin" + pluginImporter.assetPath + " was compatible with the \"any\" platform, deactivating.");
|
||||
pluginImporter.SetCompatibleWithAnyPlatform(false);
|
||||
assetChanged = true;
|
||||
}
|
||||
|
||||
var pluginPlatform = GetPluginInfoPlatform(pluginImporter.assetPath);
|
||||
if (pluginPlatform != platformPluginActivator.PluginDirectoryName)
|
||||
{
|
||||
if (Activate)
|
||||
{
|
||||
platformPluginActivator.FilterOutPlatformIfNeeded(target, pluginImporter, pluginPlatform);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
var pluginInfo = platformPluginActivator.GetPluginImporterInformation(pluginImporter);
|
||||
var bShouldActivatePlugin = platformPluginActivator.ConfigurePlugin(pluginImporter, pluginInfo);
|
||||
|
||||
if (pluginInfo.PluginConfig == "DSP")
|
||||
{
|
||||
if (!pluginInfo.IsSupportLibrary && !AkPlatformPluginList.IsPluginUsed(platformPluginActivator, pluginPlatform, Path.GetFileNameWithoutExtension(pluginImporter.assetPath)))
|
||||
{
|
||||
WwiseLogger.Verbose("Plugin" + pluginImporter.assetPath + " is not used, skipping.");
|
||||
bShouldActivatePlugin = false;
|
||||
}
|
||||
}
|
||||
else if (pluginInfo.PluginConfig != GetCurrentConfig())
|
||||
{
|
||||
WwiseLogger.Verbose("Plugin" + pluginImporter.assetPath + " does not match current config (" + GetCurrentConfig() + "). Skipping.");
|
||||
bShouldActivatePlugin = false;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(pluginInfo.PluginSDKVersion))
|
||||
{
|
||||
var sdkCompatible = platformPluginActivator.IsPluginSDKVersionCompatible(pluginInfo.PluginSDKVersion);
|
||||
WwiseLogger.Verbose("Plugin " + pluginImporter.assetPath + " is " + (sdkCompatible ? "" : "NOT ") + "compatible with current platform SDK");
|
||||
bShouldActivatePlugin &= sdkCompatible;
|
||||
}
|
||||
|
||||
bool isCompatibleWithPlatform = bShouldActivatePlugin && Activate;
|
||||
WwiseLogger.Verbose("Will set plugin " + pluginImporter.assetPath + " as " + (isCompatibleWithPlatform ? "" : "NOT ") + "compatible with platform.");
|
||||
assetChanged |= pluginImporter.GetCompatibleWithPlatform(target) != isCompatibleWithPlatform;
|
||||
|
||||
pluginImporter.SetCompatibleWithPlatform(target, isCompatibleWithPlatform);
|
||||
|
||||
if (assetChanged)
|
||||
{
|
||||
WwiseLogger.Verbose("Changed plugin " + pluginImporter.assetPath + ", saving and reimporting.");
|
||||
pluginImporter.SaveAndReimport();
|
||||
}
|
||||
}
|
||||
|
||||
bIsAlreadyActivating = false;
|
||||
}
|
||||
|
||||
public static void ActivatePluginsForEditor()
|
||||
{
|
||||
var importers = GetWwisePluginImporters();
|
||||
var changedSomeAssets = false;
|
||||
|
||||
bIsAlreadyActivating = true;
|
||||
AssetDatabase.StartAssetEditing();
|
||||
foreach (var pluginImporter in importers)
|
||||
{
|
||||
var pluginPlatform = GetPluginInfoPlatform(pluginImporter.assetPath);
|
||||
if (string.IsNullOrEmpty(pluginPlatform) || (pluginPlatform != "Mac" && pluginPlatform != "Windows" && pluginPlatform != "Linux"))
|
||||
{
|
||||
pluginImporter.SetCompatibleWithEditor(false);
|
||||
changedSomeAssets = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
BuildTarget pluginBuildTarget;
|
||||
switch (pluginPlatform)
|
||||
{
|
||||
case "Windows":
|
||||
pluginBuildTarget = BuildTarget.StandaloneWindows64;
|
||||
break;
|
||||
case "Mac":
|
||||
pluginBuildTarget = BuildTarget.StandaloneOSX;
|
||||
break;
|
||||
case "Linux":
|
||||
pluginBuildTarget = BuildTarget.StandaloneLinux64;
|
||||
break;
|
||||
default:
|
||||
pluginBuildTarget = BuildTarget.StandaloneWindows64;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!BuildTargetToPlatformPluginActivator.TryGetValue(pluginBuildTarget, out var platformPluginActivator))
|
||||
{
|
||||
WwiseLogger.Log("Build Target " + pluginBuildTarget + " not supported.");
|
||||
bIsAlreadyActivating = false;
|
||||
AssetDatabase.StopAssetEditing();
|
||||
return;
|
||||
}
|
||||
|
||||
var pluginInfo = platformPluginActivator.GetPluginImporterInformation(pluginImporter);
|
||||
|
||||
var assetChanged = false;
|
||||
if (pluginImporter.GetCompatibleWithAnyPlatform())
|
||||
{
|
||||
WwiseLogger.Verbose("ActivatePluginsForEditor: Plugin" + pluginImporter.assetPath + " was compatible with the \"any\" platform, deactivating.");
|
||||
pluginImporter.SetCompatibleWithAnyPlatform(false);
|
||||
assetChanged = true;
|
||||
}
|
||||
|
||||
var bActivate = false;
|
||||
if (!string.IsNullOrEmpty(pluginInfo.EditorOS))
|
||||
{
|
||||
if (pluginInfo.PluginConfig == "DSP")
|
||||
{
|
||||
if (!AkPlatformPluginList.ContainsPlatform(platformPluginActivator.WwisePlatformName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bActivate = AkPlatformPluginList.IsPluginUsed(platformPluginActivator, pluginPlatform,
|
||||
Path.GetFileNameWithoutExtension(pluginImporter.assetPath));
|
||||
}
|
||||
else
|
||||
{
|
||||
bActivate = pluginInfo.PluginConfig == EditorConfiguration;
|
||||
}
|
||||
|
||||
if (bActivate)
|
||||
{
|
||||
WwiseLogger.Verbose("ActivatePluginsForEditor: Activating " + pluginImporter.assetPath);
|
||||
pluginImporter.SetEditorData("CPU", pluginInfo.EditorCPU);
|
||||
pluginImporter.SetEditorData("OS", pluginInfo.EditorOS);
|
||||
}
|
||||
|
||||
assetChanged |= pluginImporter.GetCompatibleWithEditor() != bActivate;
|
||||
pluginImporter.SetCompatibleWithEditor(bActivate);
|
||||
}
|
||||
else
|
||||
{
|
||||
WwiseLogger.Verbose("ActivatePluginsForEditor: Could not determine EditorOS for " + pluginImporter.assetPath);
|
||||
}
|
||||
|
||||
if (assetChanged)
|
||||
{
|
||||
changedSomeAssets = true;
|
||||
WwiseLogger.Verbose("ActivatePluginsForEditor: Changed plugin " + pluginImporter.assetPath + ", saving and reimporting.");
|
||||
}
|
||||
}
|
||||
|
||||
AssetDatabase.StopAssetEditing();
|
||||
if (changedSomeAssets)
|
||||
{
|
||||
WwiseLogger.Log("Plugins successfully activated for " + EditorConfiguration + " in Editor.");
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
bIsAlreadyActivating = false;
|
||||
}
|
||||
|
||||
public static void DeactivateAllPlugins()
|
||||
{
|
||||
var importers = GetWwisePluginImporters();
|
||||
foreach (var pluginImporter in importers)
|
||||
{
|
||||
if (pluginImporter.assetPath.IndexOf(AkPluginActivatorConstants.WwisePluginFolder, StringComparison.OrdinalIgnoreCase) == -1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
pluginImporter.SetCompatibleWithAnyPlatform(false);
|
||||
pluginImporter.SaveAndReimport();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ForceUpdate()
|
||||
{
|
||||
AkPlatformPluginList.Update(true);
|
||||
Update();
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
AkPluginActivatorMenus.CheckMenuItems(GetCurrentConfig());
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ee9c63a2f8292a4297f0e882f20094a
|
||||
@@ -0,0 +1,194 @@
|
||||
/*******************************************************************************
|
||||
The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
|
||||
Technology released in source code form as part of the game integration package.
|
||||
The content of this file may not be used without valid licenses to the
|
||||
AUDIOKINETIC Wwise Technology.
|
||||
Note that the use of the game engine is subject to the Unity(R) Terms of
|
||||
Service at https://unity3d.com/legal/terms-of-service
|
||||
|
||||
License Usage
|
||||
|
||||
Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
|
||||
this file in accordance with the end user license agreement provided with the
|
||||
software or, alternatively, in accordance with the terms contained
|
||||
in a written agreement between you and Audiokinetic Inc.
|
||||
Copyright (c) 2026 Audiokinetic Inc.
|
||||
*******************************************************************************/
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public class AkPluginActivatorConstants
|
||||
{
|
||||
internal const string WwisePluginFolder = "Runtime/Plugins";
|
||||
|
||||
public const string CONFIG_DEBUG = "Debug";
|
||||
public const string CONFIG_PROFILE = "Profile";
|
||||
public const string CONFIG_RELEASE = "Release";
|
||||
|
||||
internal static readonly System.Collections.Generic.HashSet<PluginID> builtInPluginIDs =
|
||||
new System.Collections.Generic.HashSet<PluginID>
|
||||
{
|
||||
PluginID.AkCompressor,
|
||||
PluginID.AkDelay,
|
||||
PluginID.AkExpander,
|
||||
PluginID.AkGain,
|
||||
PluginID.AkMatrixReverb,
|
||||
PluginID.AkParametricEQ,
|
||||
PluginID.AkPeakLimiter,
|
||||
PluginID.AkRoomVerb,
|
||||
PluginID.AkReflect,
|
||||
#if !UNITY_2018_3_OR_NEWER
|
||||
PluginID.VitaReverb,
|
||||
PluginID.VitaCompressor,
|
||||
PluginID.VitaDelay,
|
||||
PluginID.VitaDistortion,
|
||||
PluginID.VitaEQ,
|
||||
#endif
|
||||
};
|
||||
|
||||
internal static readonly System.Collections.Generic.HashSet<PluginID> alwaysSkipPluginsIDs =
|
||||
new System.Collections.Generic.HashSet<PluginID>
|
||||
{
|
||||
PluginID.SineGenerator,
|
||||
PluginID.SinkAuxiliary,
|
||||
PluginID.SinkCommunication,
|
||||
PluginID.SinkControllerHeadphones,
|
||||
PluginID.SinkControllerSpeaker,
|
||||
PluginID.SinkDVRByPass,
|
||||
PluginID.SinkNoOutput,
|
||||
PluginID.SinkSystem,
|
||||
PluginID.ToneGenerator,
|
||||
PluginID.WwiseSilence,
|
||||
PluginID.AkAudioInput,
|
||||
};
|
||||
|
||||
internal static readonly System.Collections.Generic.Dictionary<PluginID, string> PluginIDToStaticLibName =
|
||||
new System.Collections.Generic.Dictionary<PluginID, string>
|
||||
{
|
||||
{ PluginID.Ak3DAudioBedMixer, "Ak3DAudioBedMixerFX" },
|
||||
{ PluginID.AkAudioInput, "AkAudioInputSource" },
|
||||
{ PluginID.AkCompressor, "AkCompressorFX" },
|
||||
{ PluginID.AkRouterMixer, "AkRouterMixerFX" },
|
||||
{ PluginID.AkChannelRouter, "AkChannelRouterFX" },
|
||||
{ PluginID.AkConvolutionReverb, "AkConvolutionReverbFX" },
|
||||
{ PluginID.AkDelay, "AkDelayFX" },
|
||||
{ PluginID.AkExpander, "AkCompressorFX" }, // Compressor lib contains Expander
|
||||
{ PluginID.AkFlanger, "AkFlangerFX" },
|
||||
{ PluginID.AkGain, "AkGainFX" },
|
||||
{ PluginID.AkGuitarDistortion, "AkGuitarDistortionFX" },
|
||||
{ PluginID.AkHarmonizer, "AkHarmonizerFX" },
|
||||
{ PluginID.AkMatrixReverb, "AkMatrixReverbFX" },
|
||||
{ PluginID.AkMeter, "AkMeterFX" },
|
||||
{ PluginID.AkMultibandMeter, "AkMeterFX" }, // Meter lib contains MultibandMeter
|
||||
{ PluginID.AkMotionSink, "AkMotionSink" },
|
||||
{ PluginID.AkMotionSource, "AkMotionSourceSource" },
|
||||
{ PluginID.AkParametricEQ, "AkParametricEQFX" },
|
||||
{ PluginID.AkPeakLimiter, "AkPeakLimiterFX" },
|
||||
{ PluginID.AkPitchShifter, "AkPitchShifterFX" },
|
||||
{ PluginID.AkRecorder, "AkRecorderFX" },
|
||||
{ PluginID.AkReflect, "AkReflectFX" },
|
||||
{ PluginID.AkRoomVerb, "AkRoomVerbFX" },
|
||||
{ PluginID.AkSoundSeedGrain, "AkSoundSeedGrainSource" },
|
||||
{ PluginID.AkSoundSeedWind, "AkSoundSeedWindSource" },
|
||||
{ PluginID.AkSoundSeedWoosh, "AkSoundSeedWooshSource" },
|
||||
{ PluginID.AkStereoDelay, "AkStereoDelayFX" },
|
||||
{ PluginID.AkSynthOne, "AkSynthOneSource" },
|
||||
{ PluginID.AkTimeStretch, "AkTimeStretchFX" },
|
||||
{ PluginID.AkTremolo, "AkTremoloFX" },
|
||||
{ PluginID.AuroHeadphone, "AuroHeadphoneFX" },
|
||||
{ PluginID.CrankcaseAudioREVModelPlayer, "CrankcaseAudioREVModelPlayerSource" },
|
||||
{ PluginID.iZHybridReverb, "iZHybridReverbFX" },
|
||||
{ PluginID.iZTrashBoxModeler, "iZTrashBoxModelerFX" },
|
||||
{ PluginID.iZTrashDelay, "iZTrashDelayFX" },
|
||||
{ PluginID.iZTrashDistortion, "iZTrashDistortionFX" },
|
||||
{ PluginID.iZTrashDynamics, "iZTrashDynamicsFX" },
|
||||
{ PluginID.iZTrashFilters, "iZTrashFiltersFX" },
|
||||
{ PluginID.iZTrashMultibandDistortion, "iZTrashMultibandDistortionFX" },
|
||||
{ PluginID.MasteringSuite, "MasteringSuiteFX" },
|
||||
{ PluginID.AkImpacterSource, "AkImpacterSource" },
|
||||
{ PluginID.McDSPFutzBox, "McDSPFutzBoxFX" },
|
||||
{ PluginID.McDSPLimiter, "McDSPLimiterFX" },
|
||||
{ PluginID.ResonanceAudioRenderer, "ResonanceAudioFX" },
|
||||
{ PluginID.ResonanceAudioRoomEffect, "ResonanceAudioFX" },
|
||||
{ PluginID.IgniterLive, "IgniterLiveSource" },
|
||||
{ PluginID.IgniterLiveSynth, "IgniterLiveSource" }
|
||||
};
|
||||
|
||||
// Support libraries are DLLs that do not have an associated Wwise plug-in ID; they are meant to be loaded manually by the application
|
||||
internal static readonly System.Collections.Generic.List<string> SupportLibraries =
|
||||
new System.Collections.Generic.List<string>
|
||||
{
|
||||
"AkVorbisHwAccelerator"
|
||||
};
|
||||
|
||||
internal enum PluginID
|
||||
{
|
||||
// Built-in plugins
|
||||
Ak3DAudioBedMixer = 0x00BE0003, // Wwise 3D Audio Bed Mixer
|
||||
AkCompressor = 0x006C0003, //Wwise Compressor
|
||||
AkRouterMixer = 0x00AC0006, //Wwise RouterMixer
|
||||
AkChannelRouter = 0x00BF0003, // Wwise Channel Router
|
||||
AkDelay = 0x006A0003, //Delay
|
||||
AkExpander = 0x006D0003, //Wwise Expander
|
||||
AkGain = 0x008B0003, //Gain
|
||||
AkMatrixReverb = 0x00730003, //Matrix Reverb
|
||||
AkMeter = 0x00810003, //Wwise Meter
|
||||
AkMultibandMeter = 0x00C40003, //Wwise Multiband Meter
|
||||
AkParametricEQ = 0x00690003, //Wwise Parametric EQ
|
||||
AkPeakLimiter = 0x006E0003, //Wwise Peak Limiter
|
||||
AkRoomVerb = 0x00760003, //Wwise RoomVerb
|
||||
SineGenerator = 0x00640002, //Sine
|
||||
SinkAuxiliary = 0xB40007,
|
||||
SinkCommunication = 0xB00007,
|
||||
SinkControllerHeadphones = 0xB10007,
|
||||
SinkControllerSpeaker = 0xB30007,
|
||||
SinkDVRByPass = 0xAF0007,
|
||||
SinkNoOutput = 0xB50007,
|
||||
SinkSystem = 0xAE0007,
|
||||
ToneGenerator = 0x00660002, //Tone Generator
|
||||
WwiseSilence = 0x00650002, //Wwise Silence
|
||||
#if !UNITY_2018_3_OR_NEWER
|
||||
VitaReverb = 0x008C0003, //Vita Reverb
|
||||
VitaCompressor = 0x008D0003, //Vita Compressor
|
||||
VitaDelay = 0x008E0003, //Vita Delay
|
||||
VitaDistortion = 0x008F0003, //Vita Distortion
|
||||
VitaEQ = 0x00900003, //Vita EQ
|
||||
#endif
|
||||
|
||||
// Static or DLL plugins
|
||||
AkAudioInput = 0xC80002,
|
||||
AkConvolutionReverb = 0x7F0003,
|
||||
AkFlanger = 0x7D0003,
|
||||
AkGuitarDistortion = 0x7E0003,
|
||||
AkHarmonizer = 0x8A0003,
|
||||
AkMotionSink = 0x1FB0007,
|
||||
AkMotionSource = 0x1990002,
|
||||
AkPitchShifter = 0x880003,
|
||||
AkRecorder = 0x840003,
|
||||
AkReflect = 0xAB0003,
|
||||
AkSoundSeedGrain = 0xB70002,
|
||||
AkSoundSeedWind = 0x770002,
|
||||
AkSoundSeedWoosh = 0x780002,
|
||||
AkStereoDelay = 0x870003,
|
||||
AkSynthOne = 0x940002,
|
||||
AkTimeStretch = 0x820003,
|
||||
AkTremolo = 0x830003,
|
||||
AuroHeadphone = 0x44C1073,
|
||||
CrankcaseAudioREVModelPlayer = 0x1A01052,
|
||||
iZHybridReverb = 0x21033,
|
||||
iZTrashBoxModeler = 0x71033,
|
||||
iZTrashDelay = 0x41033,
|
||||
iZTrashDistortion = 0x31033,
|
||||
iZTrashDynamics = 0x51033,
|
||||
iZTrashFilters = 0x61033,
|
||||
iZTrashMultibandDistortion = 0x91033,
|
||||
MasteringSuite = 0xBA0003,
|
||||
AkImpacterSource = 0xB80002,
|
||||
McDSPFutzBox = 0x6E1003,
|
||||
McDSPLimiter = 0x671003,
|
||||
ResonanceAudioRenderer = 0x641103,
|
||||
ResonanceAudioRoomEffect = 0xC81106,
|
||||
IgniterLive = 0x5110D2,
|
||||
IgniterLiveSynth = 0x5210D2
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfb04570cf048bb45a9630875dc77f66
|
||||
@@ -0,0 +1,60 @@
|
||||
/*******************************************************************************
|
||||
The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
|
||||
Technology released in source code form as part of the game integration package.
|
||||
The content of this file may not be used without valid licenses to the
|
||||
AUDIOKINETIC Wwise Technology.
|
||||
Note that the use of the game engine is subject to the Unity(R) Terms of
|
||||
Service at https://unity3d.com/legal/terms-of-service
|
||||
|
||||
License Usage
|
||||
|
||||
Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
|
||||
this file in accordance with the end user license agreement provided with the
|
||||
software or, alternatively, in accordance with the terms contained
|
||||
in a written agreement between you and Audiokinetic Inc.
|
||||
Copyright (c) 2026 Audiokinetic Inc.
|
||||
*******************************************************************************/
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public class AkPluginActivatorMenus
|
||||
{
|
||||
private const string MENU_PATH = "Assets/Wwise/Activate Plugins/";
|
||||
|
||||
[UnityEditor.MenuItem(MENU_PATH + AkPluginActivatorConstants.CONFIG_DEBUG)]
|
||||
public static void ActivateDebug()
|
||||
{
|
||||
ActivateConfig(AkPluginActivatorConstants.CONFIG_DEBUG);
|
||||
}
|
||||
|
||||
[UnityEditor.MenuItem(MENU_PATH + AkPluginActivatorConstants.CONFIG_PROFILE)]
|
||||
public static void ActivateProfile()
|
||||
{
|
||||
ActivateConfig(AkPluginActivatorConstants.CONFIG_PROFILE);
|
||||
}
|
||||
|
||||
[UnityEditor.MenuItem(MENU_PATH + AkPluginActivatorConstants.CONFIG_RELEASE)]
|
||||
public static void ActivateRelease()
|
||||
{
|
||||
ActivateConfig(AkPluginActivatorConstants.CONFIG_RELEASE);
|
||||
}
|
||||
|
||||
public static void CheckMenuItems(string config)
|
||||
{
|
||||
UnityEditor.Menu.SetChecked(MENU_PATH + AkPluginActivatorConstants.CONFIG_DEBUG, config == AkPluginActivatorConstants.CONFIG_DEBUG);
|
||||
UnityEditor.Menu.SetChecked(MENU_PATH + AkPluginActivatorConstants.CONFIG_PROFILE, config == AkPluginActivatorConstants.CONFIG_PROFILE);
|
||||
UnityEditor.Menu.SetChecked(MENU_PATH + AkPluginActivatorConstants.CONFIG_RELEASE, config == AkPluginActivatorConstants.CONFIG_RELEASE);
|
||||
}
|
||||
private static void SetCurrentConfig(string config)
|
||||
{
|
||||
var data = AkWwiseProjectInfo.GetData();
|
||||
data.CurrentPluginConfig = config;
|
||||
}
|
||||
|
||||
private static void ActivateConfig(string config)
|
||||
{
|
||||
SetCurrentConfig(config);
|
||||
AkPluginActivatorMenus.CheckMenuItems(config);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4a930db9f9a6f04aadd6f4935deb96d
|
||||
@@ -0,0 +1,35 @@
|
||||
/*******************************************************************************
|
||||
The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
|
||||
Technology released in source code form as part of the game integration package.
|
||||
The content of this file may not be used without valid licenses to the
|
||||
AUDIOKINETIC Wwise Technology.
|
||||
Note that the use of the game engine is subject to the Unity(R) Terms of
|
||||
Service at https://unity3d.com/legal/terms-of-service
|
||||
|
||||
License Usage
|
||||
|
||||
Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
|
||||
this file in accordance with the end user license agreement provided with the
|
||||
software or, alternatively, in accordance with the terms contained
|
||||
in a written agreement between you and Audiokinetic Inc.
|
||||
Copyright (c) 2026 Audiokinetic Inc.
|
||||
*******************************************************************************/
|
||||
|
||||
#if UNITY_EDITOR
|
||||
internal class AkPluginInfo
|
||||
{
|
||||
public uint PluginID;
|
||||
public string DllName;
|
||||
public string StaticLibName;
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return PluginID.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return PluginID.Equals(obj);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f2a22fee1f1c5a46a423275042bd02e
|
||||
@@ -0,0 +1,196 @@
|
||||
/*******************************************************************************
|
||||
The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
|
||||
Technology released in source code form as part of the game integration package.
|
||||
The content of this file may not be used without valid licenses to the
|
||||
AUDIOKINETIC Wwise Technology.
|
||||
Note that the use of the game engine is subject to the Unity(R) Terms of
|
||||
Service at https://unity3d.com/legal/terms-of-service
|
||||
|
||||
License Usage
|
||||
|
||||
Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
|
||||
this file in accordance with the end user license agreement provided with the
|
||||
software or, alternatively, in accordance with the terms contained
|
||||
in a written agreement between you and Audiokinetic Inc.
|
||||
Copyright (c) 2026 Audiokinetic Inc.
|
||||
*******************************************************************************/
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using System.IO;
|
||||
using AK.Wwise.Unity.Logging;
|
||||
|
||||
|
||||
internal class StaticPluginRegistration
|
||||
{
|
||||
private readonly System.Collections.Generic.HashSet<string> FactoriesHeaderFilenames =
|
||||
new System.Collections.Generic.HashSet<string>();
|
||||
|
||||
private readonly UnityEditor.BuildTarget Target;
|
||||
|
||||
public static void Setup(UnityEditor.BuildTarget target, AkPlatformPluginActivator platformPluginActivator)
|
||||
{
|
||||
if (!platformPluginActivator.RequiresStaticPluginRegistration)
|
||||
return;
|
||||
|
||||
string deploymentTargetName = platformPluginActivator.WwisePlatformName;
|
||||
|
||||
var staticPluginRegistration = new StaticPluginRegistration(target);
|
||||
var importers = AkPluginActivator.GetWwisePluginImporters(platformPluginActivator.PluginDirectoryName);
|
||||
foreach (var pluginImporter in importers)
|
||||
{
|
||||
var pluginInfo = platformPluginActivator.GetPluginImporterInformation(pluginImporter);
|
||||
var pluginPlatform = AkPluginActivator.GetPluginInfoPlatform(pluginImporter.assetPath);
|
||||
if (pluginPlatform != platformPluginActivator.PluginDirectoryName)
|
||||
continue;
|
||||
|
||||
if (platformPluginActivator.Architectures != null && platformPluginActivator.Architectures.Count != 0)
|
||||
{
|
||||
if (!platformPluginActivator.Architectures.Contains(pluginInfo.PluginArch))
|
||||
{
|
||||
WwiseLogger.Log("Architecture not found: " + pluginInfo.PluginArch);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (pluginInfo.PluginConfig != "DSP")
|
||||
continue;
|
||||
|
||||
if (!AkPlatformPluginList.IsPluginUsed(platformPluginActivator, pluginPlatform, Path.GetFileNameWithoutExtension(pluginImporter.assetPath)))
|
||||
continue;
|
||||
|
||||
staticPluginRegistration.TryAddLibrary(platformPluginActivator, pluginImporter.assetPath);
|
||||
}
|
||||
|
||||
System.Collections.Generic.HashSet<AkPluginInfo> plugins;
|
||||
AkPlatformPluginList.GetPluginsUsedForPlatform(deploymentTargetName, out plugins);
|
||||
var missingPlugins = staticPluginRegistration.GetMissingPlugins(plugins);
|
||||
if (missingPlugins.Count == 0)
|
||||
{
|
||||
if (plugins == null)
|
||||
WwiseLogger.WarningFormat("The activated Wwise plug-ins may not be correct. Could not read PluginInfo.xml for platform: {0}", deploymentTargetName);
|
||||
|
||||
staticPluginRegistration.TryWriteToFile(platformPluginActivator);
|
||||
}
|
||||
else
|
||||
{
|
||||
WwiseLogger.ErrorFormat(
|
||||
"These plugins used by the Wwise project are missing from the Unity project: {0}. Please check folder Assets/Wwise/API/Runtime/Plugin/{1}.",
|
||||
string.Join(", ", missingPlugins.ToArray()), deploymentTargetName);
|
||||
}
|
||||
}
|
||||
|
||||
private StaticPluginRegistration(UnityEditor.BuildTarget target)
|
||||
{
|
||||
Target = target;
|
||||
}
|
||||
|
||||
private void TryAddLibrary(AkPlatformPluginActivator config, string AssetPath)
|
||||
{
|
||||
if (AssetPath.EndsWith(".a"))
|
||||
{
|
||||
//Extract the lib name, generate the registration code.
|
||||
var begin = AssetPath.LastIndexOf('/') + 4;
|
||||
var end = AssetPath.LastIndexOf('.') - begin;
|
||||
var LibName = AssetPath.Substring(begin, end); //Remove the lib prefix and the .a extension
|
||||
|
||||
if (!LibName.Contains("AkUnitySoundEngine"))
|
||||
{
|
||||
string headerFilename = LibName + "Factory.h";
|
||||
|
||||
string fullPath = Path.GetFullPath(AkUtilities.GetPathInPackage(Path.Combine(AkPluginActivatorConstants.WwisePluginFolder, config.DSPDirectoryPath, headerFilename)));
|
||||
|
||||
if (File.Exists(fullPath))
|
||||
{
|
||||
FactoriesHeaderFilenames.Add(headerFilename);
|
||||
}
|
||||
else
|
||||
{
|
||||
WwiseLogger.ErrorFormat("Could not find '{0}', required for building plugin.", fullPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (AssetPath.EndsWith("Factory.h"))
|
||||
{
|
||||
FactoriesHeaderFilenames.Add(Path.GetFileName(AssetPath));
|
||||
}
|
||||
}
|
||||
|
||||
private void TryWriteToFile(AkPlatformPluginActivator config)
|
||||
{
|
||||
System.Text.StringBuilder CppText = new System.Text.StringBuilder(2000);
|
||||
|
||||
string RelativePath = Path.Combine(config.DSPDirectoryPath, config.StaticPluginRegistrationName + ".cpp");
|
||||
CppText.AppendLine("#define " + config.StaticPluginDefine);
|
||||
|
||||
// The purpose of this cpp file is to force the linker to recognize the usage of AK::PluginRegistration global objects
|
||||
// so that the static constructors for these objects are executed when the binary is being loaded in.
|
||||
// However, some platforms (e.g. WebGL) have a really aggressive LTO (link-time optimization) pass that will strip these
|
||||
// symbols even when they are defined as extern here.
|
||||
// To avoid any stripping, we call from C# a native function (AkVerifyPluginRegistration)
|
||||
// that looks at these symbols, forcing the linker to recognize that these symbols are required for proper program execution.
|
||||
|
||||
CppText.AppendLine(@"namespace AK { class PluginRegistration; };");
|
||||
CppText.AppendLine(@"class AkUnityStaticPlugin;");
|
||||
CppText.AppendLine(@"AkUnityStaticPlugin * g_pAkUnityStaticPluginList = nullptr;");
|
||||
CppText.AppendLine(@"class AkUnityStaticPlugin {");
|
||||
CppText.AppendLine("\tpublic:");
|
||||
CppText.AppendLine("\tAkUnityStaticPlugin(AK::PluginRegistration* pReg) : m_pNext(g_pAkUnityStaticPluginList), m_pReg(pReg) { g_pAkUnityStaticPluginList = this; }");
|
||||
CppText.AppendLine("\tAkUnityStaticPlugin *m_pNext;");
|
||||
CppText.AppendLine("\tAK::PluginRegistration * m_pReg;");
|
||||
CppText.AppendLine(@"};");
|
||||
|
||||
CppText.AppendLine(@"#define AK_STATIC_LINK_PLUGIN(_pluginName_) \");
|
||||
CppText.AppendLine(@"extern AK::PluginRegistration _pluginName_##Registration; \");
|
||||
CppText.AppendLine(@"AkUnityStaticPlugin _pluginName_##UnityStaticPlugin(&_pluginName_##Registration);");
|
||||
|
||||
foreach (var filename in FactoriesHeaderFilenames)
|
||||
{
|
||||
CppText.AppendLine("#include \"" + filename + "\"");
|
||||
}
|
||||
CppText.AppendLine("extern \"C\" {");
|
||||
CppText.AppendLine("\t__attribute__ ((visibility(\"default\"))) bool AkVerifyPluginRegistration() {");
|
||||
CppText.AppendLine("\t\tbool bReg = true;");
|
||||
CppText.AppendLine("\t\tAkUnityStaticPlugin * pNext = g_pAkUnityStaticPluginList;");
|
||||
CppText.AppendLine("\t\twhile (pNext != nullptr) { bReg = bReg && pNext->m_pReg != nullptr; pNext = pNext->m_pNext; }");
|
||||
CppText.AppendLine("\t\treturn bReg;");
|
||||
CppText.AppendLine("\t}");
|
||||
CppText.AppendLine("}");
|
||||
|
||||
try
|
||||
{
|
||||
var FullPath = Path.GetFullPath(AkUtilities.GetPathInPackage(Path.Combine(AkPluginActivatorConstants.WwisePluginFolder, RelativePath)));
|
||||
File.WriteAllText(FullPath, CppText.ToString());
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
WwiseLogger.Error("Could not write <" + RelativePath + ">. Exception: " + e.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
private System.Collections.Generic.List<string> GetMissingPlugins(System.Collections.Generic.HashSet<AkPluginInfo> usedPlugins)
|
||||
{
|
||||
var pluginList = new System.Collections.Generic.List<string>();
|
||||
if (usedPlugins == null)
|
||||
return pluginList;
|
||||
|
||||
foreach (var plugin in usedPlugins)
|
||||
{
|
||||
if (string.IsNullOrEmpty(plugin.StaticLibName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string includeFilename = plugin.StaticLibName + "Factory.h";
|
||||
if (!FactoriesHeaderFilenames.Contains(includeFilename))
|
||||
{
|
||||
pluginList.Add(plugin.StaticLibName);
|
||||
}
|
||||
}
|
||||
|
||||
return pluginList;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40533e511c51acb4f9b7fe6d47b7855a
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 794f0925934d2a84ba8cca191ac7d3f2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,58 @@
|
||||
/*******************************************************************************
|
||||
The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
|
||||
Technology released in source code form as part of the game integration package.
|
||||
The content of this file may not be used without valid licenses to the
|
||||
AUDIOKINETIC Wwise Technology.
|
||||
Note that the use of the game engine is subject to the Unity(R) Terms of
|
||||
Service at https://unity3d.com/legal/terms-of-service
|
||||
|
||||
License Usage
|
||||
|
||||
Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
|
||||
this file in accordance with the end user license agreement provided with the
|
||||
software or, alternatively, in accordance with the terms contained
|
||||
in a written agreement between you and Audiokinetic Inc.
|
||||
Copyright (c) 2026 Audiokinetic Inc.
|
||||
*******************************************************************************/
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
|
||||
[UnityEditor.InitializeOnLoad]
|
||||
public class AkMacPluginActivator : AkPlatformPluginActivator
|
||||
{
|
||||
public override string WwisePlatformName => "Mac";
|
||||
public override string PluginDirectoryName => "Mac";
|
||||
|
||||
static AkMacPluginActivator()
|
||||
{
|
||||
if (UnityEditor.AssetDatabase.IsAssetImportWorkerProcess())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AkPluginActivator.RegisterPlatformPluginActivator(BuildTarget.StandaloneOSX, new AkMacPluginActivator());
|
||||
}
|
||||
|
||||
private const int CONFIG_INDEX = 1;
|
||||
public override AkPluginActivator.PluginImporterInformation GetPluginImporterInformation(PluginImporter pluginImporter)
|
||||
{
|
||||
return new AkPluginActivator.PluginImporterInformation
|
||||
{
|
||||
PluginConfig = GetPluginPathParts(pluginImporter.assetPath)[CONFIG_INDEX],
|
||||
|
||||
EditorOS = "OSX",
|
||||
EditorCPU = "AnyCPU"
|
||||
};
|
||||
}
|
||||
|
||||
internal override bool ConfigurePlugin(PluginImporter pluginImporter, AkPluginActivator.PluginImporterInformation pluginImporterInformation)
|
||||
{
|
||||
pluginImporter.SetPlatformData(BuildTarget.StandaloneLinux64, "CPU", "None");
|
||||
pluginImporter.SetPlatformData(BuildTarget.StandaloneWindows, "CPU", "None");
|
||||
pluginImporter.SetPlatformData(BuildTarget.StandaloneWindows64, "CPU", "None");
|
||||
pluginImporter.SetPlatformData(BuildTarget.StandaloneOSX, "CPU", "AnyCPU");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0078b6cee531cf47a76bf7978500f51
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15549a8355d379843aa7ee8792e7d5e2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,79 @@
|
||||
/*******************************************************************************
|
||||
The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
|
||||
Technology released in source code form as part of the game integration package.
|
||||
The content of this file may not be used without valid licenses to the
|
||||
AUDIOKINETIC Wwise Technology.
|
||||
Note that the use of the game engine is subject to the Unity(R) Terms of
|
||||
Service at https://unity3d.com/legal/terms-of-service
|
||||
|
||||
License Usage
|
||||
|
||||
Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
|
||||
this file in accordance with the end user license agreement provided with the
|
||||
software or, alternatively, in accordance with the terms contained
|
||||
in a written agreement between you and Audiokinetic Inc.
|
||||
Copyright (c) 2026 Audiokinetic Inc.
|
||||
*******************************************************************************/
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using AK.Wwise.Unity.Logging;
|
||||
|
||||
[UnityEditor.InitializeOnLoad]
|
||||
public class AkWindowsPluginActivator : AkPlatformPluginActivator
|
||||
{
|
||||
public override string WwisePlatformName => "Windows";
|
||||
public override string PluginDirectoryName => "Windows";
|
||||
|
||||
|
||||
|
||||
static AkWindowsPluginActivator()
|
||||
{
|
||||
if (UnityEditor.AssetDatabase.IsAssetImportWorkerProcess())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AkPluginActivator.RegisterPlatformPluginActivator(BuildTarget.StandaloneWindows, new AkWindowsPluginActivator());
|
||||
AkPluginActivator.RegisterPlatformPluginActivator(BuildTarget.StandaloneWindows64, new AkWindowsPluginActivator());
|
||||
}
|
||||
|
||||
private const int ARCH_INDEX = 1;
|
||||
private const int CONFIG_INDEX = 2;
|
||||
|
||||
private const int EDITOR_CPU_INDEX = 1;
|
||||
public override AkPluginActivator.PluginImporterInformation GetPluginImporterInformation(PluginImporter pluginImporter)
|
||||
{
|
||||
var parts = GetPluginPathParts(pluginImporter.assetPath);
|
||||
return new AkPluginActivator.PluginImporterInformation
|
||||
{
|
||||
PluginConfig = parts[CONFIG_INDEX],
|
||||
PluginArch = parts[ARCH_INDEX],
|
||||
|
||||
EditorOS = "Windows",
|
||||
EditorCPU = parts[EDITOR_CPU_INDEX]
|
||||
};
|
||||
}
|
||||
|
||||
internal override bool ConfigurePlugin(PluginImporter pluginImporter, AkPluginActivator.PluginImporterInformation pluginImporterInformation)
|
||||
{
|
||||
if (pluginImporterInformation.PluginArch != "x86" && pluginImporterInformation.PluginArch != "x86_64")
|
||||
{
|
||||
WwiseLogger.Log("Architecture not found: " + pluginImporterInformation.PluginArch);
|
||||
return false;
|
||||
}
|
||||
|
||||
pluginImporter.SetPlatformData(BuildTarget.StandaloneLinux64, "CPU", "None");
|
||||
pluginImporter.SetPlatformData(BuildTarget.StandaloneWindows, "CPU", pluginImporterInformation.IsX86 ? "AnyCPU" : "None");
|
||||
pluginImporter.SetPlatformData(BuildTarget.StandaloneWindows64, "CPU", pluginImporterInformation.IsX64 ? "AnyCPU" : "None");
|
||||
pluginImporter.SetPlatformData(BuildTarget.StandaloneOSX, "CPU", "None");
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void FilterOutPlatformIfNeeded(BuildTarget target, PluginImporter pluginImporter,
|
||||
string pluginPlatform)
|
||||
{
|
||||
pluginImporter.SetCompatibleWithPlatform(target, false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d07a21f4872187e4ca59da771dc15ca8
|
||||
Reference in New Issue
Block a user