Beispiel #1
0
    // ----------------------------------------------------------------------------------------------------
    #endregion

    #region Loading Plugins
    // ----------------------------------------------------------------------------------------------------
    /// <summary>
    /// Loads the plugins.
    /// </summary>
    private void LoadPlugins()
    {
        if (pluginPaths == null || pluginPaths.Length == 0)
        {
            return;
        }

        Logger.LogMessage("Loading Plugins.");
        FMOD.System fmodSystem = null;
        Logger.ErrorCheck(FMODStudioSystem.Instance.System.GetLowLevelSystem(out fmodSystem));

        string dir = PluginPath;

        foreach (var name in pluginPaths)
        {
            string path = dir + "/" + GetPluginFileName(name);

            Logger.LogMessage("Loading plugin: " + path);
            if (!CSystem.IO.File.Exists(path))
            {
                Logger.LogWarning("Plugin not found: " + path);
            }

            uint handle;
            Logger.ErrorCheck(fmodSystem.LoadPlugin(path, out handle));
        }
    }
    private static bool CopyBanks(string path)
    {
        UnloadAllBanks();

        var info = new System.IO.DirectoryInfo(path);

        int    bankCount       = 0;
        string copyBanksString = "";
        var    banksToCopy     = new List <System.IO.FileInfo>();

        foreach (var fileInfo in info.GetFiles())
        {
            var ex = fileInfo.Extension;
            if (!ex.Equals(".bank", System.StringComparison.CurrentCultureIgnoreCase) &&
                !ex.Equals(".strings", System.StringComparison.CurrentCultureIgnoreCase))
            {
                Logger.LogWarning("Ignoring unexpected file: \"" + fileInfo.Name + "\": unknown file type: \"" + fileInfo.Extension + "\"");
                continue;
            }

            bankCount++;

            string bankMessage = "(added)";

            var oldBankPath = Path.Combine(Application.dataPath, Path.Combine("StreamingAssets", fileInfo.Name));
            if (System.IO.File.Exists(oldBankPath))
            {
                var oldFileInfo = new System.IO.FileInfo(oldBankPath);
                if (oldFileInfo.LastWriteTime == fileInfo.LastWriteTime)
                {
                    bankMessage = "(same)";
                }
                else if (oldFileInfo.LastWriteTime < fileInfo.LastWriteTime)
                {
                    bankMessage = "(newer)";
                }
                else
                {
                    bankMessage = "(older)";
                }
            }

            copyBanksString += fileInfo.Name + " " + bankMessage + "\n";
            banksToCopy.Add(fileInfo);
        }

        if (bankCount == 0)
        {
            EditorUtility.DisplayDialog("FMOD Studio Importer", "No .bank files found in the directory:\n" + path, "OK");
            return(false);
        }

        if (!EditorUtility.DisplayDialog("FMOD Studio Importer", "The import will modify the following files:\n" + copyBanksString, "Continue", "Cancel"))
        {
            return(false);
        }

        FMODBankList fmodBankList = ScriptableObject.CreateInstance <FMODBankList>();

        fmodBankList.GenerateBankList(banksToCopy);

        CreateDirectories(FMODBankList.AssetPath);
        AssetDatabase.CreateAsset(fmodBankList, FMODBankList.AssetPath);

        return(true);
    }