private static void UpdateFileWatcherPath() { string sourceBankPath = Settings.Instance.SourceBankPath; string pathToWatch; if (Path.IsPathRooted(sourceBankPath)) { pathToWatch = Path.GetFullPath(sourceBankPath); } else { pathToWatch = Path.GetFullPath(Environment.CurrentDirectory + "/" + sourceBankPath); } if (currentWatchPath != pathToWatch) { currentWatchPath = pathToWatch; try { sourceFileWatcher.EnableRaisingEvents = false; sourceFilesChanged = false; if (!string.IsNullOrEmpty(sourceBankPath)) { sourceFileWatcher.Path = pathToWatch; sourceFileWatcher.EnableRaisingEvents = true; } } catch (ArgumentException e) { RuntimeUtils.DebugLogWarningFormat("Error watching {0}: {1}", pathToWatch, e.Message); } } }
private void PopulatePlatformsFromAsset() { Platforms.Clear(); #if UNITY_EDITOR string assetPath = AssetDatabase.GetAssetPath(this); UnityEngine.Object[] assets = AssetDatabase.LoadAllAssetsAtPath(assetPath); Platform[] assetPlatforms = assets.OfType <Platform>().ToArray(); #else Platform[] assetPlatforms = Resources.LoadAll <Platform>(SettingsAssetName); #endif foreach (Platform newPlatform in assetPlatforms) { Platform existingPlatform = FindPlatform(newPlatform.Identifier); if (existingPlatform != null) { // Duplicate platform; clean one of them up Platform platformToDestroy; if (newPlatform.Active && !existingPlatform.Active) { RemovePlatform(existingPlatform.Identifier); platformToDestroy = existingPlatform; existingPlatform = null; } else { platformToDestroy = newPlatform; } RuntimeUtils.DebugLogWarningFormat("FMOD: Cleaning up duplicate platform: ID = {0}, name = '{1}', type = {2}", platformToDestroy.Identifier, platformToDestroy.DisplayName, platformToDestroy.GetType().Name); DestroyImmediate(platformToDestroy, true); } if (existingPlatform == null) { newPlatform.EnsurePropertiesAreValid(); AddPlatform(newPlatform); } } #if UNITY_EDITOR if (editorSettings != null) { ForEachPlatform(editorSettings.UpdateMigratedPlatform); } #endif }
// Loads static FMOD plugins for this platform. public virtual void LoadStaticPlugins(FMOD.System coreSystem, Action <FMOD.RESULT, string> reportResult) { if (StaticPlugins.Count > 0) { #if !UNITY_EDITOR && ENABLE_IL2CPP // We use reflection here to avoid compile errors if the plugin registration code doesn't exist. // It should be generated by Settings.PreprocessStaticPlugins(), which is called from // IPreprocessBuildWithReport.OnPreprocessBuild(). However, some compilation scenarios // (such as AddressableAssetSettings.BuildPlayerContent()) don't call OnPreprocessBuild(), // so we can't generate the plugin registration code. string className = string.Format("FMODUnity.{0}", RegisterStaticPluginsClassName); Type type = Type.GetType(className); if (type == null) { RuntimeUtils.DebugLogWarningFormat( "FMOD: {0} static plugins specified, but the {1} class was not found.", StaticPlugins.Count, className); return; } MethodInfo method = type.GetMethod(RegisterStaticPluginsFunctionName, BindingFlags.Public | BindingFlags.Static); if (method == null) { RuntimeUtils.DebugLogWarningFormat( "FMOD: {0} static plugins specified, but the {1}.{2} method was not found.", StaticPlugins.Count, className, RegisterStaticPluginsFunctionName); return; } method.Invoke(null, new object[] { coreSystem, reportResult }); #else RuntimeUtils.DebugLogWarningFormat( "FMOD: {0} static plugins specified, but static plugins are only supported on the IL2CPP scripting backend", StaticPlugins.Count); #endif } }
private void PreprocessStaticPlugins(Platform platform, BuildTarget target) { // Ensure we don't have leftover temporary changes from a previous build. CleanTemporaryFiles(); BuildTargetGroup buildTargetGroup = BuildPipeline.GetBuildTargetGroup(target); ScriptingImplementation scriptingBackend = PlayerSettings.GetScriptingBackend(buildTargetGroup); if (platform.StaticPlugins.Count > 0) { if (scriptingBackend == ScriptingImplementation.IL2CPP) { Action <string> reportError = message => { RuntimeUtils.DebugLogWarningFormat("FMOD: Error processing static plugins for platform {0}: {1}", platform.DisplayName, message); }; if (!AssetDatabase.IsValidFolder(CacheFolderFull)) { RuntimeUtils.DebugLogFormat("Creating {0}", CacheFolderFull); AssetDatabase.CreateFolder(FMODFolderFull, CacheFolderName); } // Generate registration code and import it so it's included in the build. RuntimeUtils.DebugLogFormat("FMOD: Generating static plugin registration code in {0}", RegisterStaticPluginsAssetPathFull); string filePath = Application.dataPath + "/" + RegisterStaticPluginsAssetPathRelative; CodeGeneration.GenerateStaticPluginRegistration(filePath, platform, reportError); AssetDatabase.ImportAsset(RegisterStaticPluginsAssetPathFull); } else { RuntimeUtils.DebugLogWarningFormat( "FMOD: Platform {0} has {1} static plugins specified, " + "but static plugins are only supported on the IL2CPP scripting backend", platform.DisplayName, platform.StaticPlugins.Count); } } }