コード例 #1
0
    public static string GetFullSoundBankPath()
    {
        string basePath = AkInitializer.GetBasePath();

        AkBasePathGetter.FixSlashes(ref basePath);
        return(basePath);
    }
コード例 #2
0
ファイル: AkBankManager.cs プロジェクト: joceycesup/Cannibals
    public AkBankHandle(string name, bool decode, bool save)
    {
        bankName        = name;
        bankCallback    = null;
        decodeBank      = decode;
        saveDecodedBank = save;

        // Verify if the bank has already been decoded
        if (decodeBank)
        {
            string DecodedBankPath = System.IO.Path.Combine(AkInitializer.GetDecodedBankFullPath(), bankName + ".bnk");
            string EncodedBankPath = System.IO.Path.Combine(AkBasePathGetter.GetValidBasePath(), bankName + ".bnk");
            if (System.IO.File.Exists(DecodedBankPath))
            {
                try
                {
                    if (System.IO.File.GetLastWriteTime(DecodedBankPath) > System.IO.File.GetLastWriteTime(EncodedBankPath))
                    {
                        relativeBasePath = AkInitializer.GetDecodedBankFolder();
                        decodeBank       = false;
                    }
                }
                catch
                {
                    // Assume the decoded bank exists, but is not accessible. Re-decode it anyway, so we do nothing.
                }
            }
        }
    }
コード例 #3
0
ファイル: BuildScript.cs プロジェクト: desmond0412/LegacyWTOS
    static void GenericBuild(string[] scenes, string targetDir, string appName, BuildTarget buildTarget, BuildOptions buildOptions)
    {
        string res = BuildPipeline.BuildPlayer(scenes, targetDir + "/" + appName + ".exe", buildTarget, buildOptions);

        if (res.Length > 0)
        {
            throw new Exception("BuildPlayer failure: " + res);
        }
        else
        {
            // Copy WWise soundbanks
            string wwiseProjFile              = Path.Combine(Application.dataPath, WwiseSetupWizard.Settings.WwiseProjectPath).Replace('/', '\\');
            string wwiseProjectFolder         = wwiseProjFile.Remove(wwiseProjFile.LastIndexOf(Path.DirectorySeparatorChar));
            string wwisePlatformString        = UnityToWwisePlatformString(EditorUserBuildSettings.activeBuildTarget.ToString());
            string sourceSoundBankFolder      = Path.Combine(wwiseProjectFolder, AkBasePathGetter.GetPlatformBasePath());
            string destinationSoundBankFolder = Path.Combine(targetDir + "/" + appName + "_Data/StreamingAssets",
                                                             Path.Combine(WwiseSetupWizard.Settings.SoundbankPath, wwisePlatformString)
                                                             );

            if (!AkUtilities.DirectoryCopy(sourceSoundBankFolder, destinationSoundBankFolder, true))
            {
                Debug.LogError("WwiseUnity: The soundbank folder for the " + wwisePlatformString + " platform doesn't exist. Make sure it was generated in your Wwise project");
                throw new Exception("BuildPlayer failure: " + res);
            }
            Directory.GetFiles(targetDir + "/" + appName + "_Data/StreamingAssets", "*.meta", SearchOption.AllDirectories).ForEach(file => File.Delete(file));
        }
    }
コード例 #4
0
    public static bool Populate()
    {
        if (UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode || UnityEditor.EditorApplication.isCompiling)
        {
            return(false);
        }

        try
        {
            // Try getting the SoundbanksInfo.xml file for Windows or Mac first, then try to find any other available platform.
            var FullSoundbankPath = AkBasePathGetter.GetPlatformBasePath();
            var filename          = System.IO.Path.Combine(FullSoundbankPath, "SoundbanksInfo.xml");
            if (!System.IO.File.Exists(filename))
            {
                FullSoundbankPath = System.IO.Path.Combine(UnityEngine.Application.streamingAssetsPath,
                                                           WwiseSetupWizard.Settings.SoundbankPath);

                if (!System.IO.Directory.Exists(FullSoundbankPath))
                {
                    return(false);
                }

                var foundFiles =
                    System.IO.Directory.GetFiles(FullSoundbankPath, "SoundbanksInfo.xml", System.IO.SearchOption.AllDirectories);

                if (foundFiles.Length == 0)
                {
                    return(false);
                }

                filename = foundFiles[0];
            }

            var time = System.IO.File.GetLastWriteTime(filename);
            if (time <= s_LastParsed)
            {
                return(false);
            }

            var doc = new System.Xml.XmlDocument();
            doc.Load(filename);

            var bChanged   = false;
            var soundBanks = doc.GetElementsByTagName("SoundBanks");
            for (var i = 0; i < soundBanks.Count; i++)
            {
                var soundBank = soundBanks[i].SelectNodes("SoundBank");
                for (var j = 0; j < soundBank.Count; j++)
                {
                    bChanged = SerialiseSoundBank(soundBank[j]) || bChanged;
                }
            }

            return(bChanged);
        }
        catch
        {
            return(false);
        }
    }
コード例 #5
0
ファイル: AkUtilities.cs プロジェクト: desmond0412/LegacyWTOS
    // Parses the .wproj to find out where soundbanks are generated for the given path
    public static string GetWwiseSoundBankDestinationFolder(string Platform, string WwiseProjectPath)
    {
        try
        {
            if (WwiseProjectPath.Length == 0)
            {
                return("");
            }

            XmlDocument doc = new XmlDocument();
            doc.Load(WwiseProjectPath);
            XPathNavigator Navigator = doc.CreateNavigator();

            // Navigate the wproj file (XML format) to where generated soundbank paths are stored
            string          PathExpression = string.Format("//Property[@Name='SoundBankPaths']/ValueList/Value[@Platform='{0}']", Platform);
            XPathExpression expression     = XPathExpression.Compile(PathExpression);
            XPathNavigator  node           = Navigator.SelectSingleNode(expression);
            string          Path           = "";
            if (node != null)
            {
                Path = node.Value;
                AkBasePathGetter.FixSlashes(ref Path);
            }

            return(Path);
        }
        catch (Exception)
        {
            // Error happened, return empty string
            return("");
        }
    }
コード例 #6
0
    private static void UpdateSoundbanksDestinationFolders(string WwiseProjectPath)
    {
        try
        {
            if (WwiseProjectPath.Length == 0)
            {
                return;
            }

            if (!File.Exists(WwiseProjectPath))
            {
                return;
            }

            DateTime t = File.GetLastWriteTime(WwiseProjectPath);
            if (t <= s_LastBankPathUpdate)
            {
                return;
            }

            s_LastBankPathUpdate = t;
            s_ProjectBankPaths.Clear();

            XmlDocument doc = new XmlDocument();
            doc.Load(WwiseProjectPath);
            XPathNavigator Navigator = doc.CreateNavigator();

            // Gather the mapping of Custom platform to Base platform
            XPathNodeIterator itpf = Navigator.Select("//Platform");
            s_BaseToCustomPF.Clear();
            foreach (XPathNavigator node in itpf)
            {
                HashSet <string> customList = null;
                string           basePF     = node.GetAttribute("ReferencePlatform", "");
                if (!s_BaseToCustomPF.TryGetValue(basePF, out customList))
                {
                    customList = new HashSet <string>();
                    s_BaseToCustomPF[basePF] = customList;
                }

                customList.Add(node.GetAttribute("Name", ""));
            }

            // Navigate the wproj file (XML format) to where generated soundbank paths are stored
            XPathNodeIterator it = Navigator.Select("//Property[@Name='SoundBankPaths']/ValueList/Value");
            foreach (XPathNavigator node in it)
            {
                string path = "";
                path = node.Value;
                AkBasePathGetter.FixSlashes(ref path);
                string pf = node.GetAttribute("Platform", "");
                s_ProjectBankPaths[pf] = path;
            }
        }
        catch (Exception ex)
        {
            // Error happened, return empty string
            Debug.LogError("Wwise: Error while reading project " + WwiseProjectPath + ".  Exception: " + ex.Message);
        }
    }
コード例 #7
0
	/// Load a language-specific bank from WWW object
	public void LoadLocalizedBank(string in_bankFilename)
	{
		var bankPath = "file://" + System.IO.Path.Combine(
			               System.IO.Path.Combine(AkBasePathGetter.GetPlatformBasePath(), AkSoundEngine.GetCurrentLanguage()),
			               in_bankFilename);
		DoLoadBank(bankPath);
	}
コード例 #8
0
        static void Reload(UnityModManager.ModEntry modEntry)
        {
            CustomSoundpackPaths.Clear();
            foreach (var soundPackSettings in settings.SoundPackSettingsList)
            {
                soundPackSettings.IsValid = soundPackSettings.Files.All(fileName => !CustomSoundpackPaths.ContainsKey(fileName));
                if (!soundPackSettings.IsValid)
                {
                    continue;
                }
                if (!soundPackSettings.Enabled)
                {
                    continue;
                }
                foreach (var soundBank in soundPackSettings.Files)
                {
                    var basePath   = new Uri(AkBasePathGetter.GetValidBasePath());
                    var customPath = new Uri(Path.Combine(modEntry.Path, soundPackSettings.Name));
                    CustomSoundpackPaths[soundBank] = Uri.UnescapeDataString(basePath.MakeRelativeUri(customPath).ToString());
                }
            }
            var loadedBanks = Traverse.Create(typeof(SoundBanksManager)).Field("s_LoadCount").GetValue <Dictionary <string, int> >();

            foreach (var soundBank in DirtySoundbanks)
            {
                if (loadedBanks.ContainsKey(soundBank))
                {
                    AkBankManager.UnloadBank(soundBank);
                    AkBankManager.DoUnloadBanks();
                    AkBankManager.LoadBank(soundBank, false, false);
                }
            }
            DirtySoundbanks.Clear();
        }
コード例 #9
0
ファイル: AkBankManager.cs プロジェクト: EsbenNyboe/WwiseTest
        /// 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));
            }

            AKRESULT res = AKRESULT.AK_Success;

            if (!string.IsNullOrEmpty(decodedBankPath))
            {
                res = AkSoundEngine.SetBasePath(decodedBankPath);
            }

            if (res == AKRESULT.AK_Success)
            {
                res = AkSoundEngine.LoadBank(bankName, AkSoundEngine.AK_DEFAULT_POOL_ID, out m_BankID);

                if (!string.IsNullOrEmpty(decodedBankPath))
                {
                    AkSoundEngine.SetBasePath(AkBasePathGetter.GetSoundbankBasePath());
                }
            }

            return(res);
        }
コード例 #10
0
    public static bool CopySoundbanks(bool generate, string platformName, ref string destinationFolder)
    {
        if (string.IsNullOrEmpty(platformName))
        {
            UnityEngine.Debug.LogErrorFormat("WwiseUnity: Could not determine platform name for <{0}> platform", platformName);
            return(false);
        }

        if (generate)
        {
            var platforms = new System.Collections.Generic.List <string> {
                platformName
            };
            AkUtilities.GenerateSoundbanks(platforms);
        }

        string sourceFolder;

        if (!AkBasePathGetter.GetSoundBankPaths(platformName, out sourceFolder, out destinationFolder))
        {
            return(false);
        }

        if (!AkUtilities.DirectoryCopy(sourceFolder, destinationFolder, true))
        {
            destinationFolder = null;
            UnityEngine.Debug.LogErrorFormat("WwiseUnity: Could not copy SoundBank folder for <{0}> platform", platformName);
            return(false);
        }

        UnityEngine.Debug.LogFormat("WwiseUnity: Copied SoundBank folder to streaming assets folder <{0}> for <{1}> platform build", destinationFolder, platformName);
        return(true);
    }
コード例 #11
0
    public void loadAllGameSoundBank(string lang = "")
    {
        string text = string.Concat(new string[]
        {
            Application.streamingAssetsPath,
            "/Audio/GeneratedSoundBanks/",
            AkBasePathGetter.GetPlatformName(),
            "/",
            lang
        });

        if (!Directory.Exists(text))
        {
            Debug.LogError(text + " does not exist!");
            return;
        }
        string[] files = Directory.GetFiles(text);
        string[] array = files;
        for (int i = 0; i < array.Length; i++)
        {
            string text2 = array[i];
            if (text2.EndsWith(".bnk"))
            {
                int    num   = text2.LastIndexOf("/");
                string text3 = text2.Substring(num + 1, text2.Length - num - 1);
                string name  = text3;
                AkBankManager.LoadBank(name, 0);
            }
        }
    }
コード例 #12
0
    private void HandleXmlChange()
    {
        var logWarnings = AkBasePathGetter.LogWarnings;

        AkBasePathGetter.LogWarnings = false;
        generatedSoundbanksPath      = AkBasePathGetter.GetPlatformBasePath();

        if (XmlExceptionOccurred || generatedSoundbanksPath != XmlWatcher?.Path)
        {
            new Thread(CreateXmlWatcher).Start();
        }

        if (!xmlChanged)
        {
            return;
        }

        xmlChanged = false;

        var populate = PopulateXML;

        if (populate == null || !populate())
        {
            return;
        }

        var callback = XMLUpdated;

        if (callback != null)
        {
            callback();
        }
    }
コード例 #13
0
    private AkWwiseXMLWatcher()
    {
        XmlWatcher      = new System.IO.FileSystemWatcher();
        SoundBankFolder = AkBasePathGetter.GetSoundbankBasePath();

        try
        {
            XmlWatcher.Path         = SoundBankFolder;
            XmlWatcher.NotifyFilter = System.IO.NotifyFilters.LastWrite;

            // Event handlers that are watching for specific event
            XmlWatcher.Created += RaisePopulateFlag;
            XmlWatcher.Changed += RaisePopulateFlag;

            XmlWatcher.Filter = "*.xml";
            XmlWatcher.IncludeSubdirectories = true;
            XmlWatcher.EnableRaisingEvents   = true;
        }
        catch (System.Exception)
        {
            // Deliberately left empty
        }

        UnityEditor.EditorApplication.update += onEditorUpdate;
    }
コード例 #14
0
    public static void PerformMigration(int migrateStart)
    {
        UpdateProgressBar(0);

        UnityEngine.Debug.Log("WwiseUnity: Migrating from Unity Integration Version " + migrateStart + " to " + AkUtilities.MigrationStopIndex);

        AkPluginActivator.DeactivateAllPlugins();
        AkPluginActivator.Update();
        AkPluginActivator.ActivatePluginsForEditor();

        // Get the name of the currently opened scene.
        var activeScene     = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
        var loadedScenePath = activeScene.path;

        if (!string.IsNullOrEmpty(loadedScenePath))
        {
            AkBasePathGetter.FixSlashes(ref loadedScenePath, '\\', '/', false);
        }

        UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects);

        // obtain a list of ScriptableObjects before any migration is performed
        ScriptableObjectGuids = UnityEditor.AssetDatabase.FindAssets("t:ScriptableObject", new[] { "Assets" });

        AkUtilities.BeginMigration(migrateStart);
        AkWwiseProjectInfo.GetData().Migrate();
        AkWwiseWWUBuilder.UpdateWwiseObjectReferenceData();

        MigratePrefabs();
        MigrateScenes();
        MigrateScriptableObjects();

        UnityEditor.EditorUtility.UnloadUnusedAssetsImmediate();

        UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects);
        AkUtilities.EndMigration();

        UpdateProgressBar(TotalNumberOfSections);

        // Reopen the scene that was opened before the migration process started.
        if (!string.IsNullOrEmpty(loadedScenePath))
        {
            UnityEditor.SceneManagement.EditorSceneManager.OpenScene(loadedScenePath);
        }

        UnityEngine.Debug.Log("WwiseUnity: Removing lock for launcher.");

        // TODO: Moving one folder up is not nice at all. How to find the current project path?
        try
        {
            System.IO.File.Delete(UnityEngine.Application.dataPath + "/../.WwiseLauncherLockFile");
        }
        catch (System.Exception)
        {
            // Ignore if not present.
        }

        UnityEditor.EditorUtility.ClearProgressBar();
    }
コード例 #15
0
    public static string GetPlatformBasePath()
    {
        string result = string.Empty;

        result = Path.Combine(AkBasePathGetter.GetFullSoundBankPath(), AkBasePathGetter.GetPlatformName());
        AkBasePathGetter.FixSlashes(ref result);
        return(result);
    }
コード例 #16
0
    public static string GetDecodedBankFullPath()
    {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
        return(Path.Combine(Application.persistentDataPath, GetDecodedBankFolder()));
#else
        return(Path.Combine(AkBasePathGetter.GetPlatformBasePath(), GetDecodedBankFolder()));
#endif
    }
コード例 #17
0
        // public string WwiseInstallationPathMac = @"E:\Wwise 2017.2.8.6698\";



        public void Init()
        {
#if UNITY_EDITOR
            BankFolder_UnityEditor = System.IO.Path.Combine(Application.dataPath, BankEditorAssetRelativePath);
            AkBasePathGetter.FixSlashes(ref BankFolder_UnityEditor);
#else
#endif
        }
コード例 #18
0
ファイル: AkBankManager.cs プロジェクト: joceycesup/Cannibals
    /// Loads a bank. This version blocks until the bank is loaded. See AK::SoundEngine::LoadBank for more information.
    public void LoadBank()
    {
        if (m_RefCount == 0)
        {
            AKRESULT res = AKRESULT.AK_Fail;

            // There might be a case where we were asked to unload the SoundBank, but then asked immediately after to load that bank.
            // If that happens, there will be a short amount of time where the ref count will be 0, but the bank will still be in memory.
            // In that case, we do not want to unload the bank, so we have to remove it from the list of pending bank unloads.
            if (AkBankManager.BanksToUnload.Contains(this))
            {
                AkBankManager.BanksToUnload.Remove(this);
                IncRef();
                return;
            }

            if (decodeBank == false)
            {
                string basePathToSet = null;

                if (!string.IsNullOrEmpty(relativeBasePath))
                {
                    basePathToSet = AkBasePathGetter.GetValidBasePath();
                    if (string.IsNullOrEmpty(basePathToSet))
                    {
                        Debug.LogWarning("WwiseUnity: Bank " + bankName + " failed to load (could not obtain base path to set).");
                        return;
                    }

                    res = AkSoundEngine.SetBasePath(System.IO.Path.Combine(basePathToSet, relativeBasePath));
                }
                else
                {
                    res = AKRESULT.AK_Success;
                }

                if (res == AKRESULT.AK_Success)
                {
                    res = AkSoundEngine.LoadBank(bankName, AkSoundEngine.AK_DEFAULT_POOL_ID, out m_BankID);

                    if (!string.IsNullOrEmpty(basePathToSet))
                    {
                        AkSoundEngine.SetBasePath(basePathToSet);
                    }
                }
            }
            else
            {
                res = AkSoundEngine.LoadAndDecodeBank(bankName, saveDecodedBank, out m_BankID);
            }

            if (res != AKRESULT.AK_Success)
            {
                Debug.LogWarning("WwiseUnity: Bank " + bankName + " failed to load (" + res.ToString() + ")");
            }
        }
        IncRef();
    }
コード例 #19
0
    public static string GetDecodedBankFullPath()
    {
#if (UNITY_ANDROID || UNITY_IOS || UNITY_SWITCH) && !UNITY_EDITOR
        // This is for platforms that only have a specific file location for persistent data.
        return(Path.Combine(Application.persistentDataPath, GetDecodedBankFolder()));
#else
        return(Path.Combine(AkBasePathGetter.GetPlatformBasePath(), GetDecodedBankFolder()));
#endif
    }
コード例 #20
0
    public static string GetBankAssetFolder()
    {
#if UNITY_EDITOR
        string path_unityEditor = System.IO.Path.Combine(Application.dataPath, CustomizeSettingData.BankEditorAssetRelativePath);
        AkBasePathGetter.FixSlashes(ref path_unityEditor);
        return(path_unityEditor);
#else
        return("");
#endif
    }
コード例 #21
0
    public void StartWatchers()
    {
        generatedSoundbanksPath = AkBasePathGetter.GetPlatformBasePath();
        wwiseProjectPath        = AkBasePathGetter.GetWwiseProjectDirectory();

        new Thread(CreateXmlWatcher).Start();
        new Thread(CreateProjectWatcher).Start();

        WwiseProjectUpdated += AkUtilities.SoundBankDestinationsUpdated;
        UnityEditor.EditorApplication.update += OnEditorUpdate;
    }
コード例 #22
0
        public static void Postfix(string ___name)
        {
            if (!ModTek.CustomResources["SoundBank"].ContainsKey(___name))
            {
                return;
            }

            var basePath = AkBasePathGetter.GetValidBasePath();

            AkSoundEngine.SetBasePath(basePath);
        }
コード例 #23
0
    public static string GetBankAssetFolder()
    {
#if UNITY_EDITOR
        string path_unityEditor = System.IO.Path.Combine(Application.dataPath, AudioPluginSettingData.BankEditorAssetRelativePath);
        AkBasePathGetter.FixSlashes(ref path_unityEditor);
        return(path_unityEditor);
#else
        return(Application.streamingAssetsPath);

        //return Application.dataPath + "/StreamingAssets";
#endif
    }
コード例 #24
0
    public static string GetDecodedBankFullPath()
    {
#if UNITY_SWITCH && !UNITY_EDITOR
        // Calling Application.persistentDataPath crashes Switch
        return(null);
#elif (UNITY_ANDROID || PLATFORM_LUMIN || UNITY_IOS) && !UNITY_EDITOR
        // This is for platforms that only have a specific file location for persistent data.
        return(System.IO.Path.Combine(UnityEngine.Application.persistentDataPath, GetDecodedBankFolder()));
#else
        return(System.IO.Path.Combine(AkBasePathGetter.GetPlatformBasePath(), GetDecodedBankFolder()));
#endif
    }
コード例 #25
0
    public static MinMaxEventDuration GetMinMaxDuration(AK.Wwise.Event akEvent)
    {
        var result            = new MinMaxEventDuration();
        var FullSoundbankPath = AkBasePathGetter.GetPlatformBasePath();
        var filename          = System.IO.Path.Combine(FullSoundbankPath, "SoundbanksInfo.xml");
        var MaxDuration       = 1000000.0f;

        if (System.IO.File.Exists(filename))
        {
            var doc = new System.Xml.XmlDocument();
            doc.Load(filename);

            var soundBanks = doc.GetElementsByTagName("SoundBanks");
            for (var i = 0; i < soundBanks.Count; i++)
            {
                var soundBank = soundBanks[i].SelectNodes("SoundBank");
                for (var j = 0; j < soundBank.Count; j++)
                {
                    var includedEvents = soundBank[j].SelectNodes("IncludedEvents");
                    for (var ie = 0; ie < includedEvents.Count; ie++)
                    {
                        var events = includedEvents[i].SelectNodes("Event");
                        for (var e = 0; e < events.Count; e++)
                        {
                            if (events[e].Attributes["Id"] != null && uint.Parse(events[e].Attributes["Id"].InnerText) == (uint)akEvent.ID)
                            {
                                if (events[e].Attributes["DurationType"] != null &&
                                    events[e].Attributes["DurationType"].InnerText == "Infinite")
                                {
                                    // Set both min and max to MaxDuration for infinite events
                                    result.MinDuration = MaxDuration;
                                    result.MaxDuration = MaxDuration;
                                }

                                if (events[e].Attributes["DurationMin"] != null)
                                {
                                    result.MinDuration = float.Parse(events[e].Attributes["DurationMin"].InnerText);
                                }
                                if (events[e].Attributes["DurationMax"] != null)
                                {
                                    result.MaxDuration = float.Parse(events[e].Attributes["DurationMax"].InnerText);
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }

        return(result);
    }
コード例 #26
0
    public void loadLanguageSoundBank(string filename)
    {
        string text = string.Concat(new string[]
        {
            Application.streamingAssetsPath,
            "/Audio/GeneratedSoundBanks/",
            AkBasePathGetter.GetPlatformName(),
            "/",
            this.language
        });

        AkBankManager.LoadBank(filename + ".bnk", 0);
    }
コード例 #27
0
    public static bool Populate()
    {
        if (EditorApplication.isPlayingOrWillChangePlaymode || EditorApplication.isCompiling)
        {
            return(false);
        }

        // Try getting the SoundbanksInfo.xml file for Windows or Mac first, then try to find any other available platform.
        string FullSoundbankPath = AkBasePathGetter.GetPlatformBasePath();
        string filename          = Path.Combine(FullSoundbankPath, "SoundbanksInfo.xml");

        if (!File.Exists(filename))
        {
            FullSoundbankPath = Path.Combine(Application.streamingAssetsPath, WwiseSetupWizard.Settings.SoundbankPath);
#if UNITY_EDITOR_OSX
            FullSoundbankPath = FullSoundbankPath.Replace('\\', '/');
#endif
            string[] foundFiles = Directory.GetFiles(FullSoundbankPath, "SoundbanksInfo.xml", SearchOption.AllDirectories);
            if (foundFiles.Length > 0)
            {
                // We just want any file, doesn't matter which one.
                filename = foundFiles[0];
            }
        }

        bool bChanged = false;
        if (File.Exists(filename))
        {
            DateTime time = File.GetLastWriteTime(filename);
            if (time <= s_LastParsed)
            {
                return(false);
            }

            XmlDocument doc = new XmlDocument();
            doc.Load(filename);

            XmlNodeList soundBanks = doc.GetElementsByTagName("SoundBanks");
            for (int i = 0; i < soundBanks.Count; i++)
            {
                XmlNodeList soundBank = soundBanks[i].SelectNodes("SoundBank");
                for (int j = 0; j < soundBank.Count; j++)
                {
                    bChanged = bChanged || SerialiseSoundBank(soundBank[j]);
                }
            }
        }
        return(bChanged);
    }
コード例 #28
0
    // Based on AkExampleAppBuilderBase.Build
    private static void MoveSoundBanks(string wwisePlatformString)
    {
        string wwiseProjFile      = Path.Combine(Application.dataPath, WwiseSetupWizard.Settings.WwiseProjectPath).Replace('/', Path.DirectorySeparatorChar);
        string wwiseProjectFolder = wwiseProjFile.Remove(wwiseProjFile.LastIndexOf(Path.DirectorySeparatorChar));

        string sourceSoundBankFolder      = Path.Combine(wwiseProjectFolder, AkBasePathGetter.GetPlatformBasePath());
        string destinationSoundBankFolder = Path.Combine(Application.dataPath + Path.DirectorySeparatorChar + "StreamingAssets",
                                                         Path.Combine(WwiseSetupWizard.Settings.SoundbankPath, wwisePlatformString));

        Debug.Log("Copying soundbanks from: " + sourceSoundBankFolder + "\nto: " + destinationSoundBankFolder);
        if (!AkUtilities.DirectoryCopy(sourceSoundBankFolder, destinationSoundBankFolder, true))
        {
            Debug.LogError("WwiseUnity: The soundbank folder for the " + wwisePlatformString + " platform doesn't exist. Make sure it was generated in your Wwise project");
        }
        UnityEditor.AssetDatabase.Refresh();
    }
コード例 #29
0
    private void HandleWprojChange()
    {
        wwiseProjectPath = AkBasePathGetter.GetWwiseProjectDirectory();

        if (ProjectExceptionOccurred || wwiseProjectPath != WprojWatcher?.Path)
        {
            new Thread(CreateProjectWatcher).Start();
        }

        if (!wprojChanged)
        {
            return;
        }

        wprojChanged = false;
        WwiseProjectUpdated?.Invoke(WprojWatcher.Path);
    }
コード例 #30
0
    private void OnEditorUpdate()
    {
        var logWarnings = AkBasePathGetter.LogWarnings;

        AkBasePathGetter.LogWarnings = false;
        var path = AkBasePathGetter.GetPlatformBasePath();

        AkBasePathGetter.LogWarnings = logWarnings;

        try
        {
            if (ExceptionOccurred || path != XmlWatcher.Path)
            {
                XmlWatcher.Path = path;
            }

            ExceptionOccurred = false;
        }
        catch
        {
            ExceptionOccurred = true;
        }

        if (!fireEvent)
        {
            return;
        }

        fireEvent = false;

        var populate = PopulateXML;

        if (populate == null || !populate())
        {
            return;
        }

        var callback = XMLUpdated;

        if (callback != null)
        {
            callback();
        }

        AkBankManager.ReloadAllBanks();
    }