/// <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) { if (files == null) { return; } 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); } } if (settings != null) { 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); } } } } else { foreach (BuildTarget target in Enum.GetValues(typeof(BuildTarget))) { pluginImporter.SetCompatibleWithPlatform(target, false); } } pluginImporter.SaveAndReimport(); Debug.Log("SetPluginImportSettings Success :" + item); } else { Debug.LogWarning("SetPluginImportSettings Faild :" + item); } } }
private static void BuildTypeModel() { RuntimeTypeModel model = TypeModelCreator.Create(); string dllName = RTSLPath.TypeModelDll; model.Compile(new RuntimeTypeModel.CompilerOptions() { OutputPath = dllName, TypeName = "RTSLTypeModel" }); string srcPath = Application.dataPath.Remove(Application.dataPath.LastIndexOf("Assets")) + dllName; string dstPath = Application.dataPath + RTSLPath.UserRoot + "/" + dllName; Debug.LogFormat("Done! Move {0} to {1} ...", srcPath, dstPath); File.Delete(dstPath); File.Move(srcPath, dstPath); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); PluginImporter importer = AssetImporter.GetAtPath("Assets" + RTSLPath.UserRoot + "/" + dllName) as PluginImporter; importer.SetCompatibleWithAnyPlatform(true); importer.SetExcludeEditorFromAnyPlatform(true); importer.SaveAndReimport(); }
static void OnPostprocessAllAssets ( string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths ) { #if false //UNITY_5_0 foreach ( string asset in importedAssets ) { if ( asset.ToLower() == "assets/plugins/x86/oculusplugin.dll" || asset.ToLower() == "assets/plugins/x86_64/oculusplugin.dll" ) { Debug.Log( "[OVRImportProcessor] Updating plugin compatibility: " + asset ); PluginImporter pluginImporter = PluginImporter.GetAtPath( asset ) as PluginImporter; if ( pluginImporter != null ) { bool x86_64 = asset.Contains( "x86_64" ); pluginImporter.SetCompatibleWithEditor( true ); pluginImporter.SetCompatibleWithAnyPlatform( false ); pluginImporter.SetEditorData( "OS", "Windows" ); if ( x86_64 ) { pluginImporter.SetCompatibleWithPlatform( BuildTarget.StandaloneWindows, false ); pluginImporter.SetCompatibleWithPlatform( BuildTarget.StandaloneWindows64, true ); } else { pluginImporter.SetCompatibleWithPlatform( BuildTarget.StandaloneWindows64, false ); pluginImporter.SetCompatibleWithPlatform( BuildTarget.StandaloneWindows, true ); } } AssetDatabase.WriteImportSettingsIfDirty( asset ); } } #endif }
public override void PostBuild(NativePlugin plugin, NativeBuildOptions buildOptions) { base.PostBuild(plugin, buildOptions); string assetFile = CombinePath( AssetDatabase.GetAssetPath(plugin.pluginBinaryFolder), "Windows", 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); if (buildOptions.Architecture == Architecture.x86) { pluginImporter.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, true); } else { pluginImporter.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, true); } pluginImporter.SetCompatibleWithEditor(true); pluginImporter.SetEditorData("OS", "Windows"); pluginImporter.SetEditorData("CPU", buildOptions.Architecture.ToString()); pluginImporter.SaveAndReimport(); } }
public override void PostBuild(NativePlugin plugin, NativeBuildOptions buildOptions) { base.PostBuild(plugin, buildOptions); string archName = buildOptions.Architecture == Architecture.ARMv7 ? "armeabi-v7a" : "x86"; string assetFile = CombinePath( AssetDatabase.GetAssetPath(plugin.pluginBinaryFolder), "Android", archName, string.Format("lib{0}.so", plugin.Name)); PluginImporter pluginImporter = PluginImporter.GetAtPath((assetFile)) as PluginImporter; if (pluginImporter != null) { SetPluginBaseInfo(plugin, buildOptions, pluginImporter); pluginImporter.SetCompatibleWithAnyPlatform(false); pluginImporter.SetCompatibleWithPlatform(BuildTarget.Android, true); pluginImporter.SetEditorData("CPU", buildOptions.Architecture.ToString()); pluginImporter.SetEditorData("ANDROID_SDK_VERSION", buildOptions.AndroidSdkVersion.ToString()); pluginImporter.SaveAndReimport(); } }
public static void ConfigurePluginPlatforms() { PluginImporter[] importers = PluginImporter.GetAllImporters(); PluginImporter iOSPlugin = null; PluginImporter androidPlugin = null; foreach (PluginImporter importer in importers) { if (importer.assetPath.Contains(AudienceNetworkFramework)) { iOSPlugin = importer; Debug.Log("Audience Network iOS plugin found at " + importer.assetPath + "."); } else if (importer.assetPath.Contains(AudienceNetworkAAR)) { androidPlugin = importer; Debug.Log("Audience Network Android plugin found at " + importer.assetPath + "."); } } if (iOSPlugin != null) { iOSPlugin.SetCompatibleWithAnyPlatform(false); iOSPlugin.SetCompatibleWithEditor(false); iOSPlugin.SetCompatibleWithPlatform(BuildTarget.iOS, true); iOSPlugin.SetPlatformData(BuildTarget.iOS, FrameworkDependenciesKey, RequiredFrameworks); iOSPlugin.SaveAndReimport(); } if (androidPlugin != null) { androidPlugin.SetCompatibleWithAnyPlatform(false); androidPlugin.SetCompatibleWithEditor(false); androidPlugin.SetCompatibleWithPlatform(BuildTarget.Android, true); androidPlugin.SaveAndReimport(); } }
static bool ResetPluginSettings(PluginImporter plugin, string CPU, string OS) { bool didUpdate = false; if (plugin.GetCompatibleWithAnyPlatform() != false) { plugin.SetCompatibleWithAnyPlatform(false); didUpdate = true; } if (plugin.GetCompatibleWithEditor() != true) { plugin.SetCompatibleWithEditor(true); didUpdate = true; } if (plugin.GetEditorData("CPU") != CPU) { plugin.SetEditorData("CPU", CPU); didUpdate = true; } if (plugin.GetEditorData("OS") != OS) { plugin.SetEditorData("OS", OS); didUpdate = true; } return(didUpdate); }
private static void SetPluginCompatibleIdp(BuildTarget target, string path, bool enable) { // if (File.Exists (path) == true || Directory.Exists (path) == true) { // FileAttributes attr = File.GetAttributes (path); // string[] pathSplit = path.Split ('/'); // string name = pathSplit [pathSplit.Length - 1]; // if ((attr & FileAttributes.Directory) == FileAttributes.Directory && name.Contains (".") == false) { // Debug.LogError ("directory : " + path); // string[] directoryPaths = Directory.GetDirectories (path, "*", SearchOption.TopDirectoryOnly); // foreach (string directoryPath in directoryPaths) { // SetPluginCompatibleIdp (target, directoryPath, enable); // } // } else { // Debug.LogError ("file : " + path); if (File.Exists(path) == true || Directory.Exists(path) == true) { PluginImporter pluginImporter = PluginImporter.GetAtPath(path) as PluginImporter; if (pluginImporter != null) { if (pluginImporter.GetCompatibleWithAnyPlatform() == true) { pluginImporter.SetCompatibleWithAnyPlatform(false); } if (pluginImporter.GetCompatibleWithPlatform(target) != enable) { pluginImporter.SetCompatibleWithPlatform(target, enable); pluginImporter.SaveAndReimport(); } } } // } // } }
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); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, false); pi.SetCompatibleWithPlatform(BuildTarget.StandaloneLinuxUniversal, 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.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(); } }
static void FixPlayMakerMetroPluginSettings(PluginImporter pluginImporter) { LogChange("Fixed Plugin Settings: " + pluginImporter.assetPath); pluginImporter.SetCompatibleWithAnyPlatform(false); pluginImporter.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, true); AssetDatabase.Refresh(); }
private static void SetCompatibleWithAnyPlatform(PluginImporter pluginImporter, bool enable) { if (pluginImporter.GetCompatibleWithAnyPlatform() != enable) { pluginImporter.SetCompatibleWithAnyPlatform(enable); mHasAtLeastOneLibraryBeenModified = true; } }
/// <summary> /// Update the <see cref="PluginImporter"/> <paramref name="pluginImporter"/> to be explicitly /// incompatible with any build target. /// </summary> /// <param name="pluginImporter"></param> private static void ExcludeFromAllBuildTargets(PluginImporter pluginImporter) { pluginImporter.SetCompatibleWithAnyPlatform(false); foreach (var buildTarget in ALL_BUILD_TARGETS) { pluginImporter.SetCompatibleWithPlatform(buildTarget, false); } }
static void FixPlayMakerDllSettings(PluginImporter pluginImporter) { LogChange("Fixed Plugin Settings: " + pluginImporter.assetPath); pluginImporter.SetCompatibleWithAnyPlatform(false); pluginImporter.SetCompatibleWithEditor(true); SetCompatiblePlatforms(pluginImporter, standardPlatforms); AssetDatabase.Refresh(); }
internal bool UpdateCompatibleWithAnyPlatform(PluginImporter pluginImporter) { if (CompatibleWithAnyPlatform != pluginImporter.GetCompatibleWithAnyPlatform()) { pluginImporter.SetCompatibleWithAnyPlatform(CompatibleWithAnyPlatform); return(true); } return(false); }
static void ResetPluginSettings(PluginImporter plugin, string CPU, string OS) { #if UNITY_5_5_OR_NEWER plugin.ClearSettings(); #endif plugin.SetCompatibleWithAnyPlatform(false); plugin.SetCompatibleWithEditor(true); plugin.SetEditorData("CPU", CPU); plugin.SetEditorData("OS", OS); }
private static void OnScriptsReloaded() { if (EditorPrefs.GetBool("RTSL_BuildAll")) { EditorPrefs.SetBool("RTSL_BuildAll", false); try { AssetDatabase.StartAssetEditing(); CreateAssetLibraryForActiveScene(); Debug.Log("Asset Libraries Updated"); CreateAssetLibrariesList(); Debug.Log("Asset Libraries List Updated"); CreateShaderProfiles(); Debug.Log("Shader Profiles Updated"); } finally { AssetDatabase.StopAssetEditing(); } try { AssetDatabase.StartAssetEditing(); BuildTypeModel(); EditorUtility.DisplayProgressBar("Build All", "Updating type model import settings", 0.99f); } catch { EditorUtility.ClearProgressBar(); } finally { AssetDatabase.StopAssetEditing(); } } if (EditorPrefs.GetBool("RTSL_UpdateTypeModelImportSettings")) { EditorPrefs.SetBool("RTSL_UpdateTypeModelImportSettings", false); try { PluginImporter importer = AssetImporter.GetAtPath("Assets" + RTSLPath.UserRoot + "/" + RTSLPath.TypeModelDll) as PluginImporter; importer.SetCompatibleWithAnyPlatform(true); importer.SetExcludeEditorFromAnyPlatform(true); importer.SaveAndReimport(); } finally { EditorUtility.ClearProgressBar(); } } }
void _SetCompatibleWithAnyPlatform(bool enable) { if (_pluginImporter != null) { if (_pluginImporter.GetCompatibleWithAnyPlatform() != enable) { _pluginImporter.SetCompatibleWithAnyPlatform(enable); _isWritten = true; } } }
private static void ClearAllPlatforms(PluginImporter plugin) { plugin.SetCompatibleWithEditor(false); plugin.SetCompatibleWithAnyPlatform(false); Enum.GetValues(typeof(BuildTarget)) .Cast <BuildTarget>() .Where(target => !IsObsolete(target)) .Where(target => (int)target != -2) .ToList() .ForEach(target => plugin.SetCompatibleWithPlatform(target, false)); }
public static void IgnoreAssembly(PluginImporter Target, bool _ignore) { Debug.LogFormat("{0}gnoring {1} assembly!", _ignore ? "I" : "Dei", me.fileName); if (Target == null) { return; } Target.SetCompatibleWithAnyPlatform(!_ignore); Target.SetCompatibleWithEditor(!_ignore); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); // WIP: This doesn't actually works, scripts have to be reloaded manually DLLManager.SetBool(me.fileName, _ignore); }
static void AddPlugin(string editorDir, string pluginDir) { if (Directory.Exists(pluginDir)) { return; } // create plugin directory structure Debug.Log("Creating plugin dir: " + pluginDir); string[] components = pluginDir.Split('/'); // get path components if (components.Length == 0 || components[0] != "Assets") { Debug.LogError("Can't add " + Constants.PluginName + ". Unexpected plugin path: " + pluginDir); return; } string path = "Assets"; for (int i = 1; i < components.Length; ++i) { string subpath = path + "/" + components[i]; // can't use Path.Combine since it will screw it up on Windows if (!Directory.Exists(subpath)) { AssetDatabase.CreateFolder(path, components[i]); } path = subpath; } // copy plugin files string[] pluginFiles = { "AndroidManifest.xml", "project.properties", "libs", "res" }; foreach (string pluginFile in pluginFiles) { string srcPath = editorDir + "/" + pluginFile; string dstPath = pluginDir + "/" + pluginFile; AssetDatabase.CopyAsset(srcPath, dstPath); } PluginImporter pluginImporter = PluginImporter.GetAtPath(pluginDir) as PluginImporter; pluginImporter.SetCompatibleWithAnyPlatform(false); pluginImporter.SetCompatibleWithPlatform(BuildTarget.Android, true); AssetDatabase.ImportAsset(pluginDir, ImportAssetOptions.ImportRecursive); }
private static void SetPluginCompatibleAnyPlatform(string path, bool enable) { if (File.Exists(path) == true || Directory.Exists(path) == true) { PluginImporter pluginImporter = PluginImporter.GetAtPath(path) as PluginImporter; if (pluginImporter != null) { if (pluginImporter.GetCompatibleWithAnyPlatform() != enable) { pluginImporter.SetCompatibleWithAnyPlatform(enable); pluginImporter.SaveAndReimport(); } } } }
private void CheckWSADllPlatforms() { #if !UNITY_4 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2 string pluginPath = "Assets/Plugins/UTNotifications.dll"; PluginImporter pluginImporter = ((PluginImporter)AssetImporter.GetAtPath(pluginPath)); if (pluginImporter.GetCompatibleWithAnyPlatform() || pluginImporter.GetCompatibleWithPlatform(BuildTarget.WSAPlayer)) { pluginImporter.SetCompatibleWithAnyPlatform(false); pluginImporter.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, false); pluginImporter.SetCompatibleWithEditor(true); pluginImporter.SaveAndReimport(); AssetDatabase.ImportAsset(pluginPath); } #endif }
private static bool DisableDLL(string pathToDLL) { if (HasCompatibility(pathToDLL, new BuildTarget[] {}, false)) { return(false); } PluginImporter pluginImporter = (PluginImporter)AssetImporter.GetAtPath(pathToDLL); pluginImporter.ClearSettings(); pluginImporter.SetCompatibleWithAnyPlatform(false); pluginImporter.SaveAndReimport(); return(true); }
private static void SetIl2cppConfig(bool isCpp, PluginImporter dll) { #if !UNITY_2018_1_OR_NEWER var target = BuildTarget.StandaloneOSX; #else var target = BuildTarget.StandaloneOSX; #endif dll.ClearSettings(); dll.SetCompatibleWithAnyPlatform(false); if (isCpp) { dll.SetCompatibleWithPlatform(target, true); //StandaloneOSX } dll.SaveAndReimport(); }
public static void SwitchCompatibleWithPlatform(PluginImporter plugin, bool value) { if (value) { Debug.Log("Platform " + EditorUserBuildSettings.activeBuildTarget + ". Switch Nuitrack dll to " + plugin.assetPath); } plugin.SetCompatibleWithAnyPlatform(false); plugin.SetCompatibleWithPlatform(BuildTarget.iOS, value); plugin.SetCompatibleWithPlatform(BuildTarget.Android, value); plugin.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux, value); plugin.SetCompatibleWithPlatform(BuildTarget.StandaloneLinux64, value); plugin.SetCompatibleWithPlatform(BuildTarget.StandaloneOSX, value); plugin.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows, value); plugin.SetCompatibleWithPlatform(BuildTarget.StandaloneWindows64, value); plugin.SetCompatibleWithEditor(value); }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { for (int i = 0; i < importedAssets.Length; i++) { if (!importedAssets[i].Contains("Assets/Game/Knight/GameAsset/Hotfix/Libs")) { continue; } PluginImporter rPluginImporter = AssetImporter.GetAtPath(importedAssets[i]) as PluginImporter; if (rPluginImporter == null) { continue; } rPluginImporter.SetCompatibleWithAnyPlatform(false); } }
private static bool SetDLLCompatibility(string pathToDLL, BuildTarget[] supportedBuildTargets, bool isCompatibleWithEditor) { if (HasCompatibility(pathToDLL, supportedBuildTargets, isCompatibleWithEditor)) { return(false); } PluginImporter pluginImporter = (PluginImporter)AssetImporter.GetAtPath(pathToDLL); pluginImporter.SetCompatibleWithAnyPlatform(false); pluginImporter.SetCompatibleWithEditor(isCompatibleWithEditor); foreach (BuildTarget buildTarget in supportedBuildTargets) { pluginImporter.SetCompatibleWithPlatform(buildTarget, true); } pluginImporter.SaveAndReimport(); return(true); }
static void Update() { EditorApplication.update -= Update; IAPChecker.CheckItNow(); if (Directory.Exists("Assets/EasyMobile")) { AddDefine("EASY_MOBILE_LITE", BuildTargetGroup.Android); AddDefine("EASY_MOBILE_LITE", BuildTargetGroup.iOS); } PluginImporter importer = AssetImporter.GetAtPath("Assets/EasyMobile/Plugins/iOS/libEasyMobileLite.a") as PluginImporter; if (importer != null) { importer.SetCompatibleWithAnyPlatform(false); importer.SetCompatibleWithPlatform(BuildTarget.iOS, true); importer.SaveAndReimport(); } }
public override void PostBuild(NativePlugin plugin, NativeBuildOptions buildOptions) { base.PostBuild(plugin, buildOptions); string assetFile = CombinePath( AssetDatabase.GetAssetPath(plugin.pluginBinaryFolder), "iOS", string.Format("lib{0}.a", plugin.Name)); PluginImporter pluginImporter = PluginImporter.GetAtPath((assetFile)) as PluginImporter; if (pluginImporter != null) { SetPluginBaseInfo(plugin, buildOptions, pluginImporter); pluginImporter.SetCompatibleWithAnyPlatform(false); pluginImporter.SetCompatibleWithPlatform(BuildTarget.iOS, true); pluginImporter.SaveAndReimport(); } }
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(); } }