public static void AddFrameworkDependency(string pluginPath, BuildTarget target, string framework) { PluginImporter plugin = AssetImporter.GetAtPath(pluginPath) as PluginImporter; if (plugin == null) { return; } string dependencies = plugin.GetPlatformData(target, "FrameworkDependencies"); if (!dependencies.Contains(framework)) { plugin.SetPlatformData(target, "FrameworkDependencies", dependencies + ";" + framework); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); // Debug.Log ("Adding framework dependency to " + target + ": " + framework); } }
private static void CheckDynamicFrameworkSetting(string searchPath = "Assets/Plugins/IOS") { string[] keys = { "MoPub" }; foreach (string filePath in Directory.GetDirectories(searchPath, "*.framework", searchOption: SearchOption.AllDirectories)) { bool isContainKeyWorld = false; foreach (string key in keys) { if (filePath.Contains(key)) { isContainKeyWorld = true; break; } } if (!isContainKeyWorld) { continue; } PluginImporter importer = AssetImporter.GetAtPath(filePath) as PluginImporter; if (importer == null) { Debug.LogError("PluginImporter not found" + filePath); throw new System.Exception("PluginImporter not found"); } string oldValue = importer.GetPlatformData(BuildTarget.iOS, "AddToEmbeddedBinaries"); if (oldValue != "true") { Debug.Log("begin set AddToEmbeddedBinaries in: " + filePath); importer.SetPlatformData(BuildTarget.iOS, "AddToEmbeddedBinaries", "true"); importer.SaveAndReimport(); } else { Debug.LogFormat("{0} already set AddToEmbeddedBinaries.", filePath); } } }
public override void PostBuild(NativePlugin plugin, NativeBuildOptions buildOptions) { base.PostBuild(plugin, buildOptions); string assetFile = CombinePath( AssetDatabase.GetAssetPath(plugin.pluginBinaryFolder), "WSA", buildOptions.Architecture.ToString(), string.Format("{0}.dll", plugin.Name)); PluginImporter pluginImporter = PluginImporter.GetAtPath((assetFile)) as PluginImporter; if (pluginImporter != null) { SetPluginBaseInfo(plugin, buildOptions, pluginImporter); pluginImporter.SetCompatibleWithAnyPlatform(false); pluginImporter.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, true); pluginImporter.SetPlatformData(BuildTarget.WSAPlayer, "CPU", buildOptions.Architecture.ToString()); pluginImporter.SaveAndReimport(); } }
/// <summary> /// Sets the plugins. /// </summary> /// <param name="files">Files.</param> /// <param name="editorSettings">Editor settings.</param> /// <param name="settings">Settings.</param> static void SetPlugins(string[] files, Dictionary<string,string> editorSettings, Dictionary<BuildTarget,Dictionary<string,string>> settings) { foreach (string item in files) { PluginImporter pluginImporter = PluginImporter.GetAtPath (item) as PluginImporter; if (pluginImporter != null) { pluginImporter.SetCompatibleWithAnyPlatform (false); pluginImporter.SetCompatibleWithEditor (false); if (editorSettings != null) { pluginImporter.SetCompatibleWithEditor (true); foreach (KeyValuePair<string, string> pair in editorSettings) { pluginImporter.SetEditorData (pair.Key, pair.Value); } } foreach (KeyValuePair<BuildTarget, Dictionary<string,string>> settingPair in settings) { pluginImporter.SetCompatibleWithPlatform (settingPair.Key, true); if (settingPair.Value != null) { foreach (KeyValuePair<string, string> pair in settingPair.Value) { pluginImporter.SetPlatformData (settingPair.Key, pair.Key, pair.Value); } } } pluginImporter.SaveAndReimport (); Debug.Log ("SetPluginImportSettings Success :" + item); } else { Debug.LogError ("SetPluginImportSettings Faild :" + item); } } }
public static void SetPlatformCPU(PluginImporter plugin, BuildTarget platform, string cpu) { plugin.SetPlatformData(platform, "CPU", cpu); }
public static void EnforcePluginPlatformSettings(PluginPlatform platform) { string path = GetPlatformPluginPath(platform); if (!Directory.Exists(path) && !File.Exists(path)) { path += PluginDisabledSuffix; } if ((Directory.Exists(path)) || (File.Exists(path))) { string basePath = GetCurrentProjectPath(); string relPath = path.Substring(basePath.Length + 1); PluginImporter pi = PluginImporter.GetAtPath(relPath) as PluginImporter; if (pi == null) { return; } // Disable support for all platforms, then conditionally enable desired support below pi.SetCompatibleWithEditor(false); pi.SetCompatibleWithAnyPlatform(false); pi.SetCompatibleWithPlatform(BuildTarget.Android, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); #pragma warning disable CS0618 // Type or member is obsolete pi.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #pragma warning restore CS0618 // Type or member is obsolete #if UNITY_2017_3_OR_NEWER pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); #endif switch (platform) { case PluginPlatform.Android32: pi.SetCompatibleWithPlatform(BuildTarget.Android, true); pi.SetPlatformData(BuildTarget.Android, "CPU", "ARMv7"); break; case PluginPlatform.Android64: pi.SetCompatibleWithPlatform(BuildTarget.Android, true); pi.SetPlatformData(BuildTarget.Android, "CPU", "ARM64"); break; default: throw new ArgumentException("Attempted to enable platform support for unsupported platform: " + platform); } AssetDatabase.ImportAsset(relPath, ImportAssetOptions.ForceUpdate); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); } }
private static void EnablePluginPackage(PluginPackage pluginPkg) { foreach (var kvp in pluginPkg.Plugins) { PluginPlatform platform = kvp.Key; string path = kvp.Value; if ((Directory.Exists(path + GetDisabledPluginSuffix())) || (File.Exists(path + GetDisabledPluginSuffix()))) { string basePath = GetCurrentProjectPath(); string relPath = path.Substring(basePath.Length + 1); string relDisabledPath = relPath + GetDisabledPluginSuffix(); AssetDatabase.MoveAsset(relDisabledPath, relPath); AssetDatabase.ImportAsset(relPath, ImportAssetOptions.ForceUpdate); PluginImporter pi = PluginImporter.GetAtPath(relPath) as PluginImporter; if (pi == null) { continue; } // Disable support for all platforms, then conditionally enable desired support below pi.SetCompatibleWithEditor(false); pi.SetCompatibleWithAnyPlatform(false); pi.SetCompatibleWithPlatform(BuildTarget.Android, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); #if UNITY_2017_3_OR_NEWER pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); #endif switch (platform) { case PluginPlatform.Android: pi.SetCompatibleWithPlatform(BuildTarget.Android, !unityVersionSupportsAndroidUniversal); pi.SetPlatformData(BuildTarget.Android, "CPU", "ARMv7"); break; case PluginPlatform.AndroidUniversal: pi.SetCompatibleWithPlatform(BuildTarget.Android, unityVersionSupportsAndroidUniversal); pi.SetPlatformData(BuildTarget.Android, "CPU", "ARM64"); break; case PluginPlatform.OSXUniversal: #if UNITY_2017_3_OR_NEWER pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, true); #else pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, true); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, true); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, true); #endif pi.SetCompatibleWithEditor(true); pi.SetEditorData("CPU", "AnyCPU"); pi.SetEditorData("OS", "OSX"); pi.SetPlatformData("Editor", "CPU", "AnyCPU"); pi.SetPlatformData("Editor", "OS", "OSX"); break; case PluginPlatform.Win: pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, true); pi.SetCompatibleWithEditor(true); pi.SetEditorData("CPU", "X86"); pi.SetEditorData("OS", "Windows"); pi.SetPlatformData("Editor", "CPU", "X86"); pi.SetPlatformData("Editor", "OS", "Windows"); break; case PluginPlatform.Win64: pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, true); pi.SetCompatibleWithEditor(true); pi.SetEditorData("CPU", "X86_64"); pi.SetEditorData("OS", "Windows"); pi.SetPlatformData("Editor", "CPU", "X86_64"); pi.SetPlatformData("Editor", "OS", "Windows"); break; default: throw new ArgumentException("Attempted EnablePluginPackage() for unsupported BuildTarget: " + platform); } AssetDatabase.ImportAsset(relPath, ImportAssetOptions.ForceUpdate); } } AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); }
/** * @brief プラグインのターゲットプラットフォーム別設定の実行. * @param plugin 対象となるプラグイン. * @param isEnableAnyPlatform すべてのプラットフォームに対し有効にするかどうかのフラグ. * @param buildTarget 対象となるプラグインのプラットフォーム. * @param cpuType 対象となるプラグインのサポートCPUタイプ. */ static void SettingPlatform(PluginImporter plugin, bool isEnableAnyPlatform, BuildTarget[] buildTargets = null, string cpuType = "AnyCPU") { // 一旦すべてのプラットフォーム依存を解除 plugin.SetCompatibleWithPlatform(BuildTarget.Android, false); plugin.SetCompatibleWithPlatform(BuildTarget.iOS, false); plugin.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); plugin.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); plugin.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER plugin.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else plugin.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); plugin.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); plugin.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif plugin.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); plugin.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); plugin.SetCompatibleWithPlatform(BuildTarget.WebGL, false); plugin.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, false); plugin.SetCompatibleWithEditor(false); plugin.SetCompatibleWithAnyPlatform(false); if (isEnableAnyPlatform) { // 全プラットフォームに対する有効化 plugin.SetCompatibleWithAnyPlatform(isEnableAnyPlatform); } else if (buildTargets != null) { // 個別プラットフォーム向け設定 foreach (BuildTarget buildTarget in buildTargets) { plugin.SetCompatibleWithPlatform(buildTarget, true); switch (buildTarget) { case BuildTarget.Android: { if (!cpuType.Equals("AnyCPU") && cpuType.Length > 0) { plugin.SetPlatformData(buildTarget, "CPU", cpuType); } } break; case BuildTarget.StandaloneLinux: case BuildTarget.StandaloneLinux64: case BuildTarget.StandaloneLinuxUniversal: { if (cpuType == "x86") { plugin.SetPlatformData(BuildTarget.StandaloneLinux, "CPU", "AnyCPU"); plugin.SetPlatformData(BuildTarget.StandaloneLinux64, "CPU", "None"); plugin.SetPlatformData(BuildTarget.StandaloneLinuxUniversal, "CPU", "AnyCPU"); } else if (cpuType == "x86_64") { plugin.SetPlatformData(BuildTarget.StandaloneLinux, "CPU", "None"); plugin.SetPlatformData(BuildTarget.StandaloneLinux64, "CPU", "AnyCPU"); plugin.SetPlatformData(BuildTarget.StandaloneLinuxUniversal, "CPU", "AnyCPU"); } else { plugin.SetPlatformData(BuildTarget.StandaloneLinux, "CPU", "AnyCPU"); plugin.SetPlatformData(BuildTarget.StandaloneLinux64, "CPU", "AnyCPU"); plugin.SetPlatformData(BuildTarget.StandaloneLinuxUniversal, "CPU", "AnyCPU"); } } break; #if UNITY_2017_3_OR_NEWER case BuildTarget.StandaloneOSX: { plugin.SetPlatformData(buildTarget, "CPU", cpuType); } break; #else case BuildTarget.StandaloneOSXIntel: case BuildTarget.StandaloneOSXIntel64: case BuildTarget.StandaloneOSXUniversal: { if (cpuType == "x86") { plugin.SetPlatformData(BuildTarget.StandaloneOSXIntel, "CPU", "AnyCPU"); plugin.SetPlatformData(BuildTarget.StandaloneOSXIntel64, "CPU", "None"); plugin.SetPlatformData(BuildTarget.StandaloneOSXUniversal, "CPU", "AnyCPU"); } else if (cpuType == "x86_64") { plugin.SetPlatformData(BuildTarget.StandaloneOSXIntel, "CPU", "None"); plugin.SetPlatformData(BuildTarget.StandaloneOSXIntel64, "CPU", "AnyCPU"); plugin.SetPlatformData(BuildTarget.StandaloneOSXUniversal, "CPU", "AnyCPU"); } else { plugin.SetPlatformData(BuildTarget.StandaloneOSXIntel, "CPU", "AnyCPU"); plugin.SetPlatformData(BuildTarget.StandaloneOSXIntel64, "CPU", "AnyCPU"); plugin.SetPlatformData(BuildTarget.StandaloneOSXUniversal, "CPU", "AnyCPU"); } } break; #endif case BuildTarget.StandaloneWindows: case BuildTarget.StandaloneWindows64: { if (cpuType == "x86") { plugin.SetPlatformData(BuildTarget.StandaloneWindows, "CPU", "AnyCPU"); plugin.SetPlatformData(BuildTarget.StandaloneWindows64, "CPU", "None"); } else if (cpuType == "x86_64") { plugin.SetPlatformData(BuildTarget.StandaloneWindows, "CPU", "None"); plugin.SetPlatformData(BuildTarget.StandaloneWindows64, "CPU", "AnyCPU"); } else { plugin.SetPlatformData(BuildTarget.StandaloneWindows, "CPU", "AnyCPU"); plugin.SetPlatformData(BuildTarget.StandaloneWindows64, "CPU", "AnyCPU"); } } break; case BuildTarget.WSAPlayer: { if (cpuType == "x86") { plugin.SetPlatformData(BuildTarget.WSAPlayer, "CPU", "x86"); } else if (cpuType == "x86_64") { plugin.SetPlatformData(BuildTarget.WSAPlayer, "CPU", "x64"); } else { plugin.SetPlatformData(BuildTarget.WSAPlayer, "CPU", "AnyCPU"); } } break; } } } }
private static void SetStandaloneTarget(PluginImporter pluginImporter, BuildTarget target) { switch (target) { case BuildTarget.StandaloneLinux: pluginImporter.SetPlatformData(BuildTarget.StandaloneLinux, "CPU", "x86"); pluginImporter.SetPlatformData(BuildTarget.StandaloneLinux64, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneLinuxUniversal, "CPU", "x86"); pluginImporter.SetPlatformData(BuildTarget.StandaloneOSXIntel, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneOSXIntel64, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneOSXUniversal, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneWindows, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneWindows64, "CPU", "None"); return; case BuildTarget.StandaloneLinux64: pluginImporter.SetPlatformData(BuildTarget.StandaloneLinux, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneLinux64, "CPU", "x86_64"); pluginImporter.SetPlatformData(BuildTarget.StandaloneLinuxUniversal, "CPU", "x86_64"); pluginImporter.SetPlatformData(BuildTarget.StandaloneOSXIntel, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneOSXIntel64, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneOSXUniversal, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneWindows, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneWindows64, "CPU", "None"); return; case BuildTarget.StandaloneOSXIntel: case BuildTarget.StandaloneOSXIntel64: pluginImporter.SetPlatformData(BuildTarget.StandaloneLinux, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneLinux64, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneLinuxUniversal, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneOSXIntel, "CPU", "AnyCPU"); pluginImporter.SetPlatformData(BuildTarget.StandaloneOSXIntel64, "CPU", "AnyCPU"); pluginImporter.SetPlatformData(BuildTarget.StandaloneOSXUniversal, "CPU", "AnyCPU"); pluginImporter.SetPlatformData(BuildTarget.StandaloneWindows, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneWindows64, "CPU", "None"); return; case BuildTarget.StandaloneWindows: pluginImporter.SetPlatformData(BuildTarget.StandaloneLinux, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneLinux64, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneLinuxUniversal, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneOSXIntel, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneOSXIntel64, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneOSXUniversal, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneWindows, "CPU", "AnyCPU"); pluginImporter.SetPlatformData(BuildTarget.StandaloneWindows64, "CPU", "None"); return; case BuildTarget.StandaloneWindows64: pluginImporter.SetPlatformData(BuildTarget.StandaloneLinux, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneLinux64, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneLinuxUniversal, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneOSXIntel, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneOSXIntel64, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneOSXUniversal, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneWindows, "CPU", "None"); pluginImporter.SetPlatformData(BuildTarget.StandaloneWindows64, "CPU", "AnyCPU"); return; default: return; } }
private static void RestoreStandardOVRPlugin() { if (!unityVersionSupportsAndroidUniversal) // sanity check { UnityEngine.Debug.LogError("Unexpected error: Unity must support AndroidUniversal version of Oculus Utilities Plugin for accessing OpenXR"); return; } if (OVRPluginUpdaterStub.IsInsidePackageDistribution()) { UnityEngine.Debug.LogError("Unable to change plugin when using package distribution"); return; } List <PluginPackage> allUtilsPluginPkgs = GetAllUtilitiesPluginPackages(); PluginPackage enabledUtilsPluginPkg = null; foreach (PluginPackage pluginPkg in allUtilsPluginPkgs) { if (pluginPkg.IsEnabled()) { enabledUtilsPluginPkg = pluginPkg; break; } } if (enabledUtilsPluginPkg == null) { UnityEngine.Debug.LogError("Unable to Restore Standard Oculus Utilities Plugin: Oculus Utilities Plugin package not activated"); return; } if (!enabledUtilsPluginPkg.IsAndroidUniversalPresent() && !enabledUtilsPluginPkg.IsWin64Present()) { UnityEngine.Debug.LogError("Unable to Restore Standard Oculus Utilities Plugin: Both AndroidOpenXR/OVRPlugin.aar and Win64/OVRPlugin.dll does not exist"); return; } if (enabledUtilsPluginPkg.IsAndroidUniversalEnabled() && enabledUtilsPluginPkg.IsWin64Enabled()) { if (!unityRunningInBatchmode) { EditorUtility.DisplayDialog("Unable to Restore Standard Oculus Utilities Plugin", "Both AndroidUniversal/OVRPlugin.aar and Win64/OVRPlugin.dll already enabled", "Ok"); } return; } if (enabledUtilsPluginPkg.IsAndroidUniversalPresent() && !enabledUtilsPluginPkg.IsAndroidUniversalEnabled()) { if (enabledUtilsPluginPkg.IsAndroidOpenXREnabled()) { string androidOpenXRPluginPath = enabledUtilsPluginPkg.Plugins[PluginPlatform.AndroidOpenXR]; string androidOpenXRPluginBasePath = GetCurrentProjectPath(); string androidOpenXRPluginRelPath = androidOpenXRPluginPath.Substring(androidOpenXRPluginBasePath.Length + 1); PluginImporter pi = PluginImporter.GetAtPath(androidOpenXRPluginRelPath) as PluginImporter; if (pi != null) { pi.SetCompatibleWithPlatform(BuildTarget.Android, false); AssetDatabase.ImportAsset(androidOpenXRPluginRelPath, ImportAssetOptions.ForceUpdate); } else { UnityEngine.Debug.LogWarning("Unable to find PluginImporter: " + androidOpenXRPluginRelPath); } } { string androidUniveralPluginPath = enabledUtilsPluginPkg.Plugins[PluginPlatform.AndroidUniversal]; string androidUniveralPluginBasePath = GetCurrentProjectPath(); string androidUniveralPluginRelPath = androidUniveralPluginPath.Substring(androidUniveralPluginBasePath.Length + 1); PluginImporter pi = PluginImporter.GetAtPath(androidUniveralPluginRelPath) as PluginImporter; if (pi != null) { pi.SetCompatibleWithPlatform(BuildTarget.Android, true); AssetDatabase.ImportAsset(androidUniveralPluginRelPath, ImportAssetOptions.ForceUpdate); } else { UnityEngine.Debug.LogWarning("Unable to find PluginImporter: " + androidUniveralPluginRelPath); } } } bool win64PluginUpdated = false; if (enabledUtilsPluginPkg.IsWin64Present() && !enabledUtilsPluginPkg.IsWin64Enabled()) { if (enabledUtilsPluginPkg.IsWin64OpenXREnabled()) { string win64OpenXRPluginPath = enabledUtilsPluginPkg.Plugins[PluginPlatform.Win64OpenXR]; string win64OpenXRPluginBasePath = GetCurrentProjectPath(); string win64OpenXRPluginRelPath = win64OpenXRPluginPath.Substring(win64OpenXRPluginBasePath.Length + 1); PluginImporter pi = PluginImporter.GetAtPath(win64OpenXRPluginRelPath) as PluginImporter; if (pi != null) { pi.ClearSettings(); pi.SetCompatibleWithEditor(false); pi.SetCompatibleWithAnyPlatform(false); AssetDatabase.ImportAsset(win64OpenXRPluginRelPath, ImportAssetOptions.ForceUpdate); } else { UnityEngine.Debug.LogWarning("Unable to find PluginImporter: " + win64OpenXRPluginRelPath); } } { string win64PluginPath = enabledUtilsPluginPkg.Plugins[PluginPlatform.Win64]; string win64PluginBasePath = GetCurrentProjectPath(); string win64PluginRelPath = win64PluginPath.Substring(win64PluginBasePath.Length + 1); PluginImporter pi = PluginImporter.GetAtPath(win64PluginRelPath) as PluginImporter; if (pi != null) { pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, true); pi.SetCompatibleWithEditor(true); pi.SetEditorData("CPU", "X86_64"); pi.SetEditorData("OS", "Windows"); pi.SetPlatformData("Editor", "CPU", "X86_64"); pi.SetPlatformData("Editor", "OS", "Windows"); AssetDatabase.ImportAsset(win64PluginRelPath, ImportAssetOptions.ForceUpdate); } else { UnityEngine.Debug.LogWarning("Unable to find PluginImporter: " + win64PluginRelPath); } } win64PluginUpdated = true; } AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); if (!unityRunningInBatchmode) { EditorUtility.DisplayDialog("Restore Standard OVRPlugin", "Standard version of Oculus Utilities Plugin has been enabled on Android", "Ok"); if (win64PluginUpdated && EditorUtility.DisplayDialog("Restart Unity", "Win64 plugin updated. Do you want to restart Unity editor?", "Restart", "Not Now")) { RestartUnityEditor(); } } }
private static void EnablePluginPackage(PluginPackage pluginPkg) { #if UNITY_2020_1_OR_NEWER bool activateOpenXRPlugin = pluginPkg.Version >= minimalProductionVersionForOpenXR; if (activateOpenXRPlugin && !unityRunningInBatchmode) { while (true) { // display a dialog to prompt developer to confirm if they want to proceed with OpenXR backend int result = EditorUtility.DisplayDialogComplex("OpenXR Backend", "OpenXR is now fully supported by Oculus. However, some of the functionalities are not supported in the baseline OpenXR spec, which would be provided in our future releases.\n\nIf you depend on the following features in your project, please click Cancel to continue using the legacy backend:\n\n 1. Advanced hand tracking features (collision capsule, input metadata, Thumb0, default handmesh)\n 2. Mixed Reality Capture on Rift\n\nNew features, such as Passthrough API, are only supported through the OpenXR backend.\n\nPlease check our release notes for more details.\n\nReminder: you can switch the legacy and OpenXR backends at any time from Oculus > Tools > OpenXR menu options.", "Use OpenXR", "Cancel", "Release Notes"); if (result == 0) { break; } else if (result == 1) { activateOpenXRPlugin = false; break; } else if (result == 2) { Application.OpenURL("https://developer.oculus.com/downloads/package/unity-integration/"); } else { UnityEngine.Debug.LogWarningFormat("Unrecognized result from DisplayDialogComplex: {0}", result); break; } } } #else bool activateOpenXRPlugin = false; #endif if (activateOpenXRPlugin) { UnityEngine.Debug.Log("OVRPlugin with OpenXR backend is activated by default"); if (!unityRunningInBatchmode) { EditorUtility.DisplayDialog("OVRPlugin", "OVRPlugin with OpenXR backend will be activated by default", "Ok"); } } else { UnityEngine.Debug.Log("OVRPlugin with LibOVR/VRAPI backend is activated by default"); if (!unityRunningInBatchmode) { EditorUtility.DisplayDialog("OVRPlugin", "OVRPlugin with LibOVR/VRAPI backend will be activated by default", "Ok"); } } foreach (var kvp in pluginPkg.Plugins) { PluginPlatform platform = kvp.Key; string path = kvp.Value; if ((Directory.Exists(path + GetDisabledPluginSuffix())) || (File.Exists(path + GetDisabledPluginSuffix()))) { string basePath = GetCurrentProjectPath(); string relPath = path.Substring(basePath.Length + 1); string relDisabledPath = relPath + GetDisabledPluginSuffix(); AssetDatabase.MoveAsset(relDisabledPath, relPath); AssetDatabase.ImportAsset(relPath, ImportAssetOptions.ForceUpdate); PluginImporter pi = PluginImporter.GetAtPath(relPath) as PluginImporter; if (pi == null) { continue; } // Disable support for all platforms, then conditionally enable desired support below pi.SetCompatibleWithEditor(false); pi.SetCompatibleWithAnyPlatform(false); pi.SetCompatibleWithPlatform(BuildTarget.Android, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); switch (platform) { case PluginPlatform.Android: pi.SetCompatibleWithPlatform(BuildTarget.Android, !unityVersionSupportsAndroidUniversal); if (!unityVersionSupportsAndroidUniversal) { pi.SetPlatformData(BuildTarget.Android, "CPU", "ARMv7"); } break; case PluginPlatform.AndroidUniversal: if (!activateOpenXRPlugin) { pi.SetCompatibleWithPlatform(BuildTarget.Android, unityVersionSupportsAndroidUniversal); } break; case PluginPlatform.AndroidOpenXR: if (activateOpenXRPlugin) { pi.SetCompatibleWithPlatform(BuildTarget.Android, unityVersionSupportsAndroidUniversal); } break; case PluginPlatform.OSXUniversal: pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, true); pi.SetCompatibleWithEditor(true); pi.SetEditorData("CPU", "AnyCPU"); pi.SetEditorData("OS", "OSX"); pi.SetPlatformData("Editor", "CPU", "AnyCPU"); pi.SetPlatformData("Editor", "OS", "OSX"); break; case PluginPlatform.Win: pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, true); pi.SetCompatibleWithEditor(true); pi.SetEditorData("CPU", "X86"); pi.SetEditorData("OS", "Windows"); pi.SetPlatformData("Editor", "CPU", "X86"); pi.SetPlatformData("Editor", "OS", "Windows"); break; case PluginPlatform.Win64: if (!activateOpenXRPlugin) { pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, true); pi.SetCompatibleWithEditor(true); pi.SetEditorData("CPU", "X86_64"); pi.SetEditorData("OS", "Windows"); pi.SetPlatformData("Editor", "CPU", "X86_64"); pi.SetPlatformData("Editor", "OS", "Windows"); } break; case PluginPlatform.Win64OpenXR: if (activateOpenXRPlugin) { pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, true); pi.SetCompatibleWithEditor(true); pi.SetEditorData("CPU", "X86_64"); pi.SetEditorData("OS", "Windows"); pi.SetPlatformData("Editor", "CPU", "X86_64"); pi.SetPlatformData("Editor", "OS", "Windows"); } break; default: throw new ArgumentException("Attempted EnablePluginPackage() for unsupported BuildTarget: " + platform); } AssetDatabase.ImportAsset(relPath, ImportAssetOptions.ForceUpdate); } } AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { #region iOS and tvOS { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/tvOS/GameAnalyticsTVOS.h") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.tvOS) || importer.GetCompatibleWithPlatform(BuildTarget.iOS))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, true); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, false); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, false); importer.SaveAndReimport(); } } { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/tvOS/GameAnalyticsTVOSUnity.m") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.tvOS) || importer.GetCompatibleWithPlatform(BuildTarget.iOS))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, true); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, false); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, false); importer.SaveAndReimport(); } } { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/tvOS/libGameAnalyticsTVOS.a") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.tvOS) || importer.GetCompatibleWithPlatform(BuildTarget.iOS))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, true); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, false); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, false); importer.SaveAndReimport(); } } #endregion // iOS and tvOS #region General { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/GameAnalytics.dll") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.StandaloneLinux) || !importer.GetCompatibleWithPlatform(BuildTarget.StandaloneLinux64) || !importer.GetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal) || #if UNITY_2017_3_OR_NEWER !importer.GetCompatibleWithPlatform(BuildTarget.StandaloneOSX) || #else !importer.GetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel) || !importer.GetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64) || !importer.GetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal) || #endif !importer.GetCompatibleWithPlatform(BuildTarget.StandaloneWindows) || !importer.GetCompatibleWithPlatform(BuildTarget.StandaloneWindows64) || !importer.GetCompatibleWithPlatform(BuildTarget.WSAPlayer) || !importer.GetPlatformData(BuildTarget.WSAPlayer, "SDK").Equals("UWP") || !importer.GetPlatformData(BuildTarget.WSAPlayer, "ScriptingBackend").Equals("Il2Cpp"))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, true); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, true); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, true); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, true); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, true); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, true); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, true); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, true); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, true); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, false); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, false); importer.SetCompatibleWithPlatform(BuildTarget.Tizen, false); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, true); importer.SetPlatformData(BuildTarget.WSAPlayer, "SDK", "UWP"); importer.SetPlatformData(BuildTarget.WSAPlayer, "ScriptingBackend", "Il2Cpp"); importer.SaveAndReimport(); } } #endregion // General #region Standalone { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/Windows/x86/sqlite3.dll") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.StandaloneWindows))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, true); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, false); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, false); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, false); importer.SaveAndReimport(); } } { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/Windows/x64/sqlite3.dll") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.StandaloneWindows64))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, true); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, false); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, false); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, false); importer.SaveAndReimport(); } } { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/Linux/sqlite3.so") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.StandaloneLinux) || !importer.GetCompatibleWithPlatform(BuildTarget.StandaloneLinux64) || !importer.GetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, true); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, true); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, true); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, false); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, false); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, false); importer.SaveAndReimport(); } } #endregion // Standalone #region WebGL { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/WebGL/GameAnalytics.WebGL.dll") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.WebGL))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, false); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, true); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, false); importer.SaveAndReimport(); } } { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/WebGL/HandleIO.jslib") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.WebGL))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, false); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, true); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, false); importer.SaveAndReimport(); } } { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/WebGL/Mono.Data.Sqlite.dll") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.WebGL))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, false); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, true); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, false); importer.SaveAndReimport(); } } { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/WebGL/sqlite.c") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.WebGL))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, false); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, true); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, false); importer.SaveAndReimport(); } } { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/WebGL/sqlite.h") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.WebGL))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, false); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, true); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, false); importer.SaveAndReimport(); } } #endregion // WebGL #region WSA { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/WSA/GameAnalytics.UWP.dll") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.WSAPlayer) || !importer.GetPlatformData(BuildTarget.WSAPlayer, "SDK").Equals("UWP") || !importer.GetPlatformData(BuildTarget.WSAPlayer, "ScriptingBackend").Equals("DotNet"))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, false); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, false); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, true); importer.SetPlatformData(BuildTarget.WSAPlayer, "SDK", "UWP"); importer.SetPlatformData(BuildTarget.WSAPlayer, "ScriptingBackend", "DotNet"); importer.SaveAndReimport(); } } { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/WSA/Microsoft.Data.Sqlite.dll") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.WSAPlayer) || !importer.GetPlatformData(BuildTarget.WSAPlayer, "SDK").Equals("UWP"))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, false); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, false); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, true); importer.SetPlatformData(BuildTarget.WSAPlayer, "SDK", "UWP"); importer.SaveAndReimport(); } } { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/WSA/MetroLog.dll") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.WSAPlayer) || !importer.GetPlatformData(BuildTarget.WSAPlayer, "SDK").Equals("AnySDK"))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, false); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, false); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, true); importer.SetPlatformData(BuildTarget.WSAPlayer, "SDK", "AnySDK"); importer.SaveAndReimport(); } } { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/WSA/x86/sqlite3.dll") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.WSAPlayer) || !importer.GetPlatformData(BuildTarget.WSAPlayer, "SDK").Equals("UWP") || !importer.GetPlatformData(BuildTarget.WSAPlayer, "CPU").Equals("X86"))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, false); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, false); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, true); importer.SetPlatformData(BuildTarget.WSAPlayer, "SDK", "UWP"); importer.SetPlatformData(BuildTarget.WSAPlayer, "CPU", "X86"); importer.SaveAndReimport(); } } { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/WSA/x64/sqlite3.dll") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.WSAPlayer) || !importer.GetPlatformData(BuildTarget.WSAPlayer, "SDK").Equals("UWP") || !importer.GetPlatformData(BuildTarget.WSAPlayer, "CPU").Equals("X64"))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, false); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, false); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, true); importer.SetPlatformData(BuildTarget.WSAPlayer, "SDK", "UWP"); importer.SetPlatformData(BuildTarget.WSAPlayer, "CPU", "X64"); importer.SaveAndReimport(); } } { PluginImporter importer = AssetImporter.GetAtPath("Assets/GameAnalytics/Plugins/WSA/ARM/sqlite3.dll") as PluginImporter; if (importer != null && (importer.GetCompatibleWithAnyPlatform() || !importer.GetCompatibleWithPlatform(BuildTarget.WSAPlayer) || !importer.GetPlatformData(BuildTarget.WSAPlayer, "SDK").Equals("UWP") || !importer.GetPlatformData(BuildTarget.WSAPlayer, "CPU").Equals("ARM"))) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithEditor(false); importer.SetCompatibleWithPlatform(BuildTarget.Android, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, false); #if UNITY_2017_3_OR_NEWER importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); #endif importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); importer.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, false); importer.SetCompatibleWithPlatform(BuildTarget.tvOS, false); importer.SetCompatibleWithPlatform(BuildTarget.WebGL, false); importer.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, true); importer.SetPlatformData(BuildTarget.WSAPlayer, "SDK", "UWP"); importer.SetPlatformData(BuildTarget.WSAPlayer, "CPU", "ARM"); importer.SaveAndReimport(); } } #endregion // WSA }
private static void AttemptSpatializerPluginUpdate(bool triggeredByAutoUpdate) { // We use a simplified path to update spatializer plugins: // If there is a new AudioPluginOculusSpatializer.dll.new, we'll rename the original one to .old, and the new one to .dll, and restart the editor string pluginsPath = GetSpatializerPluginsRootPath(); string newX86PluginPath = Path.GetFullPath(Path.Combine(pluginsPath, "x86/AudioPluginOculusSpatializer.dll.new")); string newX64PluginPath = Path.GetFullPath(Path.Combine(pluginsPath, "x86_64/AudioPluginOculusSpatializer.dll.new")); if (File.Exists(newX86PluginPath) || File.Exists(newX64PluginPath)) { bool userAcceptsUpdate = false; if (unityRunningInBatchmode) { userAcceptsUpdate = true; } else { int dialogResult = EditorUtility.DisplayDialogComplex("Update Spatializer Plugins", "New spatializer plugin found. Do you want to upgrade? If you choose 'Upgrade', the old plugin will be renamed to AudioPluginOculusSpatializer.old", "Upgrade", "Don't upgrade", "Delete new plugin"); if (dialogResult == 0) { userAcceptsUpdate = true; } else if (dialogResult == 1) { // do nothing } else if (dialogResult == 2) { try { File.Delete(newX86PluginPath); File.Delete(newX86PluginPath + ".meta"); File.Delete(newX64PluginPath); File.Delete(newX64PluginPath + ".meta"); } catch (Exception e) { UnityEngine.Debug.LogWarning("Exception happened when deleting new spatializer plugin: " + e.Message); } } } if (userAcceptsUpdate) { bool upgradeDone = false; string curX86PluginPath = Path.Combine(pluginsPath, "x86/AudioPluginOculusSpatializer.dll"); if (File.Exists(newX86PluginPath)) { RenameSpatializerPluginToOld(curX86PluginPath); try { File.Move(newX86PluginPath, curX86PluginPath); File.Move(newX86PluginPath + ".meta", curX86PluginPath + ".meta"); // fix the platform string curX86PluginPathRel = "Assets/Oculus/Spatializer/Plugins/x86/AudioPluginOculusSpatializer.dll"; UnityEngine.Debug.Log("path = " + curX86PluginPathRel); AssetDatabase.ImportAsset(curX86PluginPathRel, ImportAssetOptions.ForceUpdate); PluginImporter pi = PluginImporter.GetAtPath(curX86PluginPathRel) as PluginImporter; pi.SetCompatibleWithEditor(false); pi.SetCompatibleWithAnyPlatform(false); pi.SetCompatibleWithPlatform(BuildTarget.Android, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); #if UNITY_2017_3_OR_NEWER pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); #endif pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, true); pi.SetCompatibleWithEditor(true); pi.SetEditorData("CPU", "X86"); pi.SetEditorData("OS", "Windows"); pi.SetPlatformData("Editor", "CPU", "X86"); pi.SetPlatformData("Editor", "OS", "Windows"); AssetDatabase.ImportAsset(curX86PluginPathRel, ImportAssetOptions.ForceUpdate); AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); upgradeDone = true; } catch (Exception e) { UnityEngine.Debug.LogWarning("Unable to rename the new spatializer plugin: " + e.Message); } } string curX64PluginPath = Path.Combine(pluginsPath, "x86_64/AudioPluginOculusSpatializer.dll"); if (File.Exists(newX64PluginPath)) { RenameSpatializerPluginToOld(curX64PluginPath); try { File.Move(newX64PluginPath, curX64PluginPath); File.Move(newX64PluginPath + ".meta", curX64PluginPath + ".meta"); // fix the platform string curX64PluginPathRel = "Assets/Oculus/Spatializer/Plugins/x86_64/AudioPluginOculusSpatializer.dll"; UnityEngine.Debug.Log("path = " + curX64PluginPathRel); AssetDatabase.ImportAsset(curX64PluginPathRel, ImportAssetOptions.ForceUpdate); PluginImporter pi = PluginImporter.GetAtPath(curX64PluginPathRel) as PluginImporter; pi.SetCompatibleWithEditor(false); pi.SetCompatibleWithAnyPlatform(false); pi.SetCompatibleWithPlatform(BuildTarget.Android, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); #if UNITY_2017_3_OR_NEWER pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); #else pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXUniversal, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); #endif pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, true); pi.SetCompatibleWithEditor(true); pi.SetEditorData("CPU", "X86_64"); pi.SetEditorData("OS", "Windows"); pi.SetPlatformData("Editor", "CPU", "X86_64"); pi.SetPlatformData("Editor", "OS", "Windows"); AssetDatabase.ImportAsset(curX64PluginPathRel, ImportAssetOptions.ForceUpdate); AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); upgradeDone = true; } catch (Exception e) { UnityEngine.Debug.LogWarning("Unable to rename the new spatializer plugin: " + e.Message); } } if (upgradeDone) { if (unityRunningInBatchmode || EditorUtility.DisplayDialog("Restart Unity", "Spatializer plugins has been upgraded." + "\n\nPlease restart the Unity Editor to complete the update process." #if !UNITY_2017_1_OR_NEWER + " You may need to manually relaunch Unity if you are using Unity 5.6 and higher." #endif , "Restart", "Not Now")) { RestartUnityEditor(); } } } } }
static void SetCompatibility(string guid, PlatformSupport[] platformSupport) { string pluginPath = AssetDatabase.GUIDToAssetPath(guid); PluginImporter plugin = AssetImporter.GetAtPath(pluginPath) as PluginImporter; if (plugin == null) { return; } bool updateRequired = false; if (platformSupport.Length == 0) { // Just set every platform to disabled before enabling the correct ones foreach (BuildTarget bt in Enum.GetValues(typeof(BuildTarget))) { // If the build target is obsolete if (bt < 0) { continue; } // Use a string here to handle issue where a platform dependency may not be installed // within the current Unity Editor install if (plugin.GetCompatibleWithPlatform(bt.ToString())) { updateRequired = true; } } } else { foreach (PlatformSupport s in platformSupport) { if (!plugin.GetCompatibleWithPlatform(s.platformName)) { updateRequired = true; } if (plugin.GetCompatibleWithEditor() != s.editorSupport) { updateRequired = true; } if (s.editorSupport) { if (plugin.GetEditorData("OS") != s.editorOS || plugin.GetEditorData("CPU") != s.editorCPU) { updateRequired = true; } } } } if (updateRequired) { #if UNITY_5_5_OR_NEWER plugin.ClearSettings(); #endif plugin.SetCompatibleWithEditor(false); plugin.SetCompatibleWithAnyPlatform(false); // Just set every platform to disabled before enabling the correct ones foreach (BuildTarget bt in Enum.GetValues(typeof(BuildTarget))) { // If the build target is obsolete if (bt < 0) { continue; } // Use a string here to handle issue where a platform dependency may not be installed // within the current Unity Editor install plugin.SetCompatibleWithPlatform(bt.ToString(), false); } foreach (PlatformSupport s in platformSupport) { plugin.SetCompatibleWithPlatform(s.platformName, s.platformSupport); plugin.SetPlatformData("Any", "Exclude Editor", (s.editorSupport ? 0 : 1).ToString()); plugin.SetPlatformData("Any", "Exclude " + s.platformName, (s.platformSupport ? 0 : 1).ToString()); if (!string.IsNullOrEmpty(s.platformCPU)) { plugin.SetPlatformData(s.platformName, "CPU", s.platformCPU); } plugin.SetCompatibleWithEditor(s.editorSupport); if (s.editorSupport) { plugin.SetEditorData("OS", s.editorOS); plugin.SetEditorData("CPU", s.editorCPU); } } plugin.SaveAndReimport(); } }
public static void SetPlatformEditor(PluginImporter plugin, string os, string cpu) { SetPlatformEditor(plugin, true); plugin.SetPlatformData("Editor", "OS", os); plugin.SetPlatformData("Editor", "CPU", cpu); }
private static void EnablePluginPackage(PluginPackage pluginPkg) { foreach (var kvp in pluginPkg.Plugins) { BuildTarget platform = kvp.Key; string path = kvp.Value; if ((Directory.Exists(path + GetDisabledPluginSuffix())) || (File.Exists(path + GetDisabledPluginSuffix()))) { string basePath = GetCurrentProjectPath(); string relPath = path.Substring(basePath.Length + 1); AssetDatabase.MoveAsset(relPath + GetDisabledPluginSuffix(), relPath); AssetDatabase.ImportAsset(relPath, ImportAssetOptions.ForceUpdate); PluginImporter pi = PluginImporter.GetAtPath(relPath) as PluginImporter; if (pi == null) { continue; } pi.SetCompatibleWithAnyPlatform(false); switch (platform) { case BuildTarget.Android: pi.SetCompatibleWithPlatform(BuildTarget.Android, true); pi.SetPlatformData(BuildTarget.Android, "CPU", "ARMv7"); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); pi.SetCompatibleWithEditor(false); break; case BuildTarget.StandaloneOSX: pi.SetCompatibleWithPlatform(BuildTarget.Android, false); pi.SetPlatformData(BuildTarget.Android, "CPU", "ARMv7"); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, true); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, true); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, true); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); pi.SetCompatibleWithEditor(true); pi.SetEditorData("CPU", "AnyCPU"); pi.SetEditorData("OS", "OSX"); pi.SetPlatformData("Editor", "CPU", "AnyCPU"); pi.SetPlatformData("Editor", "OS", "OSX"); break; case BuildTarget.StandaloneWindows: pi.SetCompatibleWithPlatform(BuildTarget.Android, false); pi.SetPlatformData(BuildTarget.Android, "CPU", "ARMv7"); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, true); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, false); pi.SetCompatibleWithEditor(true); pi.SetEditorData("CPU", "X86"); pi.SetEditorData("OS", "Windows"); pi.SetPlatformData("Editor", "CPU", "X86"); pi.SetPlatformData("Editor", "OS", "Windows"); break; case BuildTarget.StandaloneWindows64: pi.SetCompatibleWithPlatform(BuildTarget.Android, false); pi.SetPlatformData(BuildTarget.Android, "CPU", "ARMv7"); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneOSXIntel64, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, true); pi.SetCompatibleWithEditor(true); pi.SetEditorData("CPU", "X86_64"); pi.SetEditorData("OS", "Windows"); pi.SetPlatformData("Editor", "CPU", "X86_64"); pi.SetPlatformData("Editor", "OS", "Windows"); break; default: throw new ArgumentException("Attempted EnablePluginPackage() for unsupported BuildTarget: " + platform); } AssetDatabase.ImportAsset(relPath, ImportAssetOptions.ForceUpdate); } } AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); }
private static void ActivateOVRPluginOpenXR() { if (!unityVersionSupportsAndroidUniversal) { UnityEngine.Debug.LogError("Unexpected error: Unity must support AndroidUniversal version of Oculus Utilities Plugin for accessing OpenXR"); return; } if (OVRPluginUpdaterStub.IsInsidePackageDistribution()) { UnityEngine.Debug.LogError("Unable to change plugin when using package distribution"); return; } #if !USING_XR_SDK && !REQUIRES_XR_SDK UnityEngine.Debug.LogError("Oculus Utilities Plugin with OpenXR only supports XR Plug-in Managmenent with Oculus XR Plugin"); return; #else List <PluginPackage> allUtilsPluginPkgs = GetAllUtilitiesPluginPackages(); PluginPackage enabledUtilsPluginPkg = null; foreach (PluginPackage pluginPkg in allUtilsPluginPkgs) { if (pluginPkg.IsEnabled()) { enabledUtilsPluginPkg = pluginPkg; break; } } if (enabledUtilsPluginPkg == null) { UnityEngine.Debug.LogError("Unable to Activate OVRPlugin with OpenXR: Oculus Utilities Plugin package not activated"); return; } if (!enabledUtilsPluginPkg.IsAndroidOpenXRPresent() && !enabledUtilsPluginPkg.IsWin64OpenXRPresent()) { UnityEngine.Debug.LogError("Unable to Activate OVRPlugin with OpenXR: Both AndroidOpenXR/OVRPlugin.aar or Win64OpenXR/OVRPlugin.dll does not exist"); return; } if (enabledUtilsPluginPkg.IsAndroidOpenXREnabled() && enabledUtilsPluginPkg.IsWin64OpenXREnabled()) { if (!unityRunningInBatchmode) { EditorUtility.DisplayDialog("Unable to Activate OVRPlugin with OpenXR", "Both AndroidOpenXR/OVRPlugin.aar and Win64OpenXR/OVRPlugin.dll already enabled", "Ok"); } return; } if (enabledUtilsPluginPkg.Version < minimalProductionVersionForOpenXR) { if (!unityRunningInBatchmode) { bool accepted = EditorUtility.DisplayDialog("Warning", "OVRPlugin with OpenXR backend is experimental before v31. You may expect to encounter stability issues and/or missing functionalities, " + "including but not limited to, fixed foveated rendering / composition layer / display refresh rates / etc." + "\n\n" + "Also, OVRPlugin with OpenXR backend only supports XR Plug-in Managmenent with Oculus XR Plugin on Quest", "Continue", "Cancel"); if (!accepted) { return; } } } if (enabledUtilsPluginPkg.IsAndroidOpenXRPresent() && !enabledUtilsPluginPkg.IsAndroidOpenXREnabled()) { if (enabledUtilsPluginPkg.IsAndroidUniversalEnabled()) { string androidUniveralPluginPath = enabledUtilsPluginPkg.Plugins[PluginPlatform.AndroidUniversal]; string androidUniveralPluginBasePath = GetCurrentProjectPath(); string androidUniveralPluginRelPath = androidUniveralPluginPath.Substring(androidUniveralPluginBasePath.Length + 1); PluginImporter pi = PluginImporter.GetAtPath(androidUniveralPluginRelPath) as PluginImporter; if (pi != null) { pi.SetCompatibleWithPlatform(BuildTarget.Android, false); AssetDatabase.ImportAsset(androidUniveralPluginRelPath, ImportAssetOptions.ForceUpdate); } else { UnityEngine.Debug.LogWarning("Unable to find PluginImporter: " + androidUniveralPluginRelPath); } } { string androidOpenXRPluginPath = enabledUtilsPluginPkg.Plugins[PluginPlatform.AndroidOpenXR]; string androidOpenXRPluginBasePath = GetCurrentProjectPath(); string androidOpenXRPluginRelPath = androidOpenXRPluginPath.Substring(androidOpenXRPluginBasePath.Length + 1); PluginImporter pi = PluginImporter.GetAtPath(androidOpenXRPluginRelPath) as PluginImporter; if (pi != null) { pi.SetCompatibleWithPlatform(BuildTarget.Android, true); AssetDatabase.ImportAsset(androidOpenXRPluginRelPath, ImportAssetOptions.ForceUpdate); } else { UnityEngine.Debug.LogWarning("Unable to find PluginImporter: " + androidOpenXRPluginRelPath); } } } bool win64PluginUpdated = false; if (enabledUtilsPluginPkg.IsWin64OpenXRPresent() && !enabledUtilsPluginPkg.IsWin64OpenXREnabled()) { if (enabledUtilsPluginPkg.IsWin64Enabled()) { string win64PluginPath = enabledUtilsPluginPkg.Plugins[PluginPlatform.Win64]; string win64PluginBasePath = GetCurrentProjectPath(); string win64PluginRelPath = win64PluginPath.Substring(win64PluginBasePath.Length + 1); PluginImporter pi = PluginImporter.GetAtPath(win64PluginRelPath) as PluginImporter; if (pi != null) { pi.ClearSettings(); pi.SetCompatibleWithEditor(false); pi.SetCompatibleWithAnyPlatform(false); AssetDatabase.ImportAsset(win64PluginRelPath, ImportAssetOptions.ForceUpdate); } else { UnityEngine.Debug.LogWarning("Unable to find PluginImporter: " + win64PluginRelPath); } } { string win64OpenXRPluginPath = enabledUtilsPluginPkg.Plugins[PluginPlatform.Win64OpenXR]; string win64OpenXRPluginBasePath = GetCurrentProjectPath(); string win64OpenXRPluginRelPath = win64OpenXRPluginPath.Substring(win64OpenXRPluginBasePath.Length + 1); PluginImporter pi = PluginImporter.GetAtPath(win64OpenXRPluginRelPath) as PluginImporter; if (pi != null) { pi.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, true); pi.SetCompatibleWithEditor(true); pi.SetEditorData("CPU", "X86_64"); pi.SetEditorData("OS", "Windows"); pi.SetPlatformData("Editor", "CPU", "X86_64"); pi.SetPlatformData("Editor", "OS", "Windows"); AssetDatabase.ImportAsset(win64OpenXRPluginRelPath, ImportAssetOptions.ForceUpdate); } else { UnityEngine.Debug.LogWarning("Unable to find PluginImporter: " + win64OpenXRPluginRelPath); } } win64PluginUpdated = true; } AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); if (!unityRunningInBatchmode) { EditorUtility.DisplayDialog("Activate OVRPlugin with OpenXR", "Oculus Utilities Plugin with OpenXR has been enabled on Android", "Ok"); if (win64PluginUpdated && EditorUtility.DisplayDialog("Restart Unity", "Win64 plugin updated. Do you want to restart Unity editor?", "Restart", "Not Now")) { RestartUnityEditor(); } } #endif // !USING_XR_SDK }