Пример #1
0
        public void TryAddLibrary(string AssetPath)
        {
            Active = true;
            if (AssetPath.Contains(".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("AkSoundEngine"))
                {
                    string headerFilename = LibName + "Factory.h";

                    string fullPath = System.IO.Path.GetFullPath(AkUtilities.GetPathInPackage(WwisePluginFolder + GetWwisePluginRelativeDSPFolder() + headerFilename));

                    if (System.IO.File.Exists(fullPath))
                    {
                        FactoriesHeaderFilenames.Add(headerFilename);
                    }
                    else
                    {
                        UnityEngine.Debug.LogErrorFormat("WwiseUnity: Could not find '{0}', required for building plugin.", WwisePluginFolder + GetWwisePluginRelativeDSPFolder() + headerFilename);
                    }
                }
            }
            else if (AssetPath.Contains("Factory.h"))
            {
                FactoriesHeaderFilenames.Add(System.IO.Path.GetFileName(AssetPath));
            }
        }
    protected static string GetPluginPath()
    {
#if UNITY_EDITOR_WIN
        return(System.IO.Path.GetFullPath(AkUtilities.GetPathInPackage(@"Runtime\Plugins\Windows\x86_64\DSP")));
#elif UNITY_EDITOR_OSX
        return(System.IO.Path.GetFullPath(AkUtilities.GetPathInPackage("Runtime/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 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
    }
Пример #3
0
        public void TryWriteToFile()
        {
            if (!Active)
            {
                return;
            }

            string RelativePath;
            string CppText;

            if (Target == UnityEditor.BuildTarget.iOS)
            {
                RelativePath = GetWwisePluginRelativeDSPFolder() + "AkiOSPlugins.cpp";
                CppText      = "#define AK_IOS";
            }
            else if (Target == UnityEditor.BuildTarget.tvOS)
            {
                RelativePath = GetWwisePluginRelativeDSPFolder() + "AktvOSPlugins.cpp";
                CppText      = "#define AK_IOS";
            }
            else if (Target == SwitchBuildTarget)
            {
                RelativePath = GetWwisePluginRelativeDSPFolder() + "AkSwitchPlugins.cpp";
                CppText      = "#define AK_NX";
            }
            else
            {
                return;
            }

            CppText += @"
namespace AK { class PluginRegistration; };
#define AK_STATIC_LINK_PLUGIN(_pluginName_) \
extern AK::PluginRegistration _pluginName_##Registration; \
void *_pluginName_##_fp = (void*)&_pluginName_##Registration;

";

            foreach (var filename in FactoriesHeaderFilenames)
            {
                CppText += "#include \"" + filename + "\"\n";
            }

            try
            {
                var FullPath = System.IO.Path.GetFullPath(AkUtilities.GetPathInPackage(WwisePluginFolder + RelativePath));
                System.IO.File.WriteAllText(FullPath, CppText);
            }
            catch (System.Exception e)
            {
                UnityEngine.Debug.LogError("WwiseUnity: Could not write <" + RelativePath + ">. Exception: " + e.Message);
                return;
            }

            UnityEditor.AssetDatabase.Refresh();
        }