I've integrated Wwise (2022.1.0) in a Unity (2022.1.1) project. When I start the game I can play sounds from Wwise but I get the following error. I searched for solutions but couldn't find anything. Seems like the AkWwiseProjectData.asset
which stores some data is a temporary cache file.
WwiseUnity: Unable to load Wwise Data: UnityEngine.UnityException: LoadAssetAtPath can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. at (wrapper managed-to-native) UnityEditor.AssetDatabase.LoadAssetAtPath(string,System.Type) at UnityEditor.AssetDatabase.LoadAssetAtPath[T] (System.String assetPath) [0x00001] in /Users/bokken/buildslave/unity/build/Modules/AssetDatabase/Editor/ScriptBindings/AssetDatabase.bindings.cs:233 at AkWwiseProjectInfo.GetData () [0x0001a] in /Users/studio/Game/Assets/Wwise/API/Editor/WwiseWindows/AkWwiseProjectInfo.cs:72 UnityEngine.Debug:LogError (object) AkWwiseProjectInfo:GetData () (at Assets/Wwise/API/Editor/WwiseWindows/AkWwiseProjectInfo.cs:95) AkWwiseTreeProjectDataSource:SaveExpansionStatus (System.Collections.Generic.List`1) (at Assets/Wwise/API/Editor/WwiseWindows/AkWwiseTreeProjectDataSource.cs:284) AkWwiseTreeView:SaveExpansionStatus () (at Assets/Wwise/API/Editor/WwiseWindows/AkWwiseTreeView.cs:128) AkWwiseTreeView:Finalize () (at Assets/Wwise/API/Editor/WwiseWindows/AkWwiseTreeView.cs:872)
And here is the method that I am sent to
public static class AkWwiseProjectInfo
{
...
public static AkWwiseProjectData GetData()
{
if (ProjectData == null && WwiseFolderExists())
{
try
{
ProjectData = UnityEditor.AssetDatabase.LoadAssetAtPath<AkWwiseProjectData>(s_dataAssetPath);
if (ProjectData == null)
{
var dataAbsolutePath = System.IO.Path.Combine(UnityEngine.Application.dataPath, s_dataRelativePath);
var dataExists = System.IO.File.Exists(dataAbsolutePath);
if (dataExists)
{
UnityEngine.Debug.LogWarning("WwiseUnity: Unable to load asset at <" + dataAbsolutePath + ">.");
}
else
{
var dataAbsoluteDirectory = System.IO.Path.Combine(UnityEngine.Application.dataPath, s_dataRelativeDirectory);
if (!System.IO.Directory.Exists(dataAbsoluteDirectory))
System.IO.Directory.CreateDirectory(dataAbsoluteDirectory);
}
CreateWwiseProjectData();
}
}
catch (System.Exception e)
{
UnityEngine.Debug.LogError("WwiseUnity: Unable to load Wwise Data: " + e);
}
}
return ProjectData;
}
...
}