private static void SetImportSettings(BuildTarget platform, string[] assemblyPaths, OdinAssemblyImportSettings importSettings) { foreach (var path in assemblyPaths) { AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, path, importSettings); } }
//[ToggleLeft] //[TitleGroup("Generate AOT DLL"), PropertyOrder(9)] //[InfoBox("If 'Emit AOT Formatters' is enabled, Odin will also generate serialization formatters for types which need it. This removes the need for reflection on AOT platforms, and can significantly speed up serialization.")] //[SerializeField] //private bool emitAOTFormatters = true; public bool ShouldAutomationGeneration(BuildTarget target) { if (AutomateBeforeBuilds == false) { return(false); } if (AutomateForAllAOTPlatforms) { var platform = EditorUserBuildSettings.activeBuildTarget; var backend = AssemblyImportSettingsUtilities.GetCurrentScriptingBackend(); var api = AssemblyImportSettingsUtilities.GetCurrentApiCompatibilityLevel(); if (AssemblyImportSettingsUtilities.IsJITSupported(platform, backend, api)) { return(false); } else { return(true); } } else if (AutomateForPlatforms != null && AutomateForPlatforms.Contains(target)) { return(true); } else { return(false); } }
public static void OnPreprocessBuild() { var scriptingBackend = AssemblyImportSettingsUtilities.GetCurrentScriptingBackend(); var activeBuildTarget = EditorUserBuildSettings.activeBuildTarget; var compileForAOT = scriptingBackend == ScriptingImplementation.IL2CPP || !AssemblyImportSettingsUtilities.JITPlatforms.Contains(activeBuildTarget); // The EditorOnly dll should aways have the same import settings. But lets just make sure. AssemblyImportSettingsUtilities.SetAssemblyImportSettings(EditorAssemblyPath, OdinAssemblyImportSettings.IncludeInEditorOnly); if (compileForAOT) { AssemblyImportSettingsUtilities.SetAssemblyImportSettings(AOTAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly); AssemblyImportSettingsUtilities.SetAssemblyImportSettings(JITAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll); } else { AssemblyImportSettingsUtilities.SetAssemblyImportSettings(AOTAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll); AssemblyImportSettingsUtilities.SetAssemblyImportSettings(JITAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly); } if (compileForAOT) { // Generates dll that contains all serialized generic type variants needed at runtime. List <Type> types; if (AOTSupportUtilities.ScanProjectForSerializedTypes(out types)) { AOTSupportUtilities.GenerateDLL(GenerateAssembliesDir, "OdinAOTSupport", types); } } }
private static void ApplyImportSettings(BuildTarget platform, string[] assemblyPaths, OdinAssemblyImportSettings importSettings) { for (int i = 0; i < assemblyPaths.Length; i++) { AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, assemblyPaths[i], importSettings); } }
private static void ConfigureImportSettings() { if (EditorOnlyModeConfig.Instance.IsEditorOnlyModeEnabled() || ImportSettingsConfig.Instance.AutomateBeforeBuild == false) { return; } BuildTarget platform = EditorUserBuildSettings.activeBuildTarget; string assemblyDirectory = Path.Combine("Assets", SirenixAssetPaths.SirenixAssembliesPath); string[] aotAssemblies = Directory.GetFiles(Path.Combine(assemblyDirectory, AOTAssemblyFolder), "*.dll"); string[] jitAssemblies = Directory.GetFiles(Path.Combine(assemblyDirectory, JITAssemblyFolder), "*.dll"); AssetDatabase.StartAssetEditing(); try { if (AssemblyImportSettingsUtilities.IsJITSupported( platform, AssemblyImportSettingsUtilities.GetCurrentScriptingBackend(), AssemblyImportSettingsUtilities.GetCurrentApiCompatibilityLevel())) { ApplyImportSettings(platform, aotAssemblies, OdinAssemblyImportSettings.ExcludeFromAll); ApplyImportSettings(platform, jitAssemblies, OdinAssemblyImportSettings.IncludeInBuildOnly); } else { ApplyImportSettings(platform, aotAssemblies, OdinAssemblyImportSettings.IncludeInBuildOnly); ApplyImportSettings(platform, jitAssemblies, OdinAssemblyImportSettings.ExcludeFromAll); } } finally { AssetDatabase.StopAssetEditing(); } }
private static void ConfigureImportSettings() { if (EditorOnlyModeConfig.Instance.IsEditorOnlyModeEnabled() || ImportSettingsConfig.Instance.AutomateBeforeBuild == false) { return; } var assemblyDir = SirenixAssetPaths.SirenixAssembliesPath; var aotDir = assemblyDir + "NoEmitAndNoEditor/"; var jitDir = assemblyDir + "NoEditor/"; var aotAssemblies = new List <string>(); var jitAssemblies = new List <string>(); var paths = AssetDatabase.GetAllAssetPaths(); for (int i = 0; i < paths.Length; i++) { var p = paths[i]; if (p.StartsWith(assemblyDir)) { if (!p.EndsWith(".dll", System.StringComparison.InvariantCultureIgnoreCase)) { continue; } if (p.StartsWith(aotDir)) { aotAssemblies.Add(p); } else if (p.StartsWith(jitDir)) { jitAssemblies.Add(p); } } } AssetDatabase.StartAssetEditing(); try { var platform = EditorUserBuildSettings.activeBuildTarget; if (AssemblyImportSettingsUtilities.IsJITSupported( platform, AssemblyImportSettingsUtilities.GetCurrentScriptingBackend(), AssemblyImportSettingsUtilities.GetCurrentApiCompatibilityLevel())) { ApplyImportSettings(platform, aotAssemblies.ToArray(), OdinAssemblyImportSettings.ExcludeFromAll); ApplyImportSettings(platform, jitAssemblies.ToArray(), OdinAssemblyImportSettings.IncludeInBuildOnly); } else { ApplyImportSettings(platform, aotAssemblies.ToArray(), OdinAssemblyImportSettings.IncludeInBuildOnly); ApplyImportSettings(platform, jitAssemblies.ToArray(), OdinAssemblyImportSettings.ExcludeFromAll); } } finally { AssetDatabase.StopAssetEditing(); } }
private static void SetImportSettings(BuildTarget platform, string[] assemblyPaths, OdinAssemblyImportSettings importSettings) { foreach (var path in assemblyPaths) { var p = path.Replace('\\', '/'); AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, p, importSettings); } }
private OdinAssemblyOptions GetRecommendedOption() { return (AssemblyImportSettingsUtilities.IsJITSupported( EditorUserBuildSettings.activeBuildTarget, AssemblyImportSettingsUtilities.GetCurrentScriptingBackend(), AssemblyImportSettingsUtilities.GetCurrentApiCompatibilityLevel()) ? OdinAssemblyOptions.JIT : OdinAssemblyOptions.AOT); }
public void OnPreprocessBuild(BuildReport report) { var platform = EditorUserBuildSettings.activeBuildTarget; _path = Directory.CreateDirectory("Assets/OdinAOT").FullName; try { if (!AssemblyImportSettingsUtilities.IsJITSupported( platform, AssemblyImportSettingsUtilities.GetCurrentScriptingBackend(), AssemblyImportSettingsUtilities.GetCurrentApiCompatibilityLevel()) && AOTSupportUtilities.ScanProjectForSerializedTypes(out var types)) { types.Add(typeof(byte[])); types.Add(typeof(Item)); var providers = AppDomain .CurrentDomain .GetAssemblies() .SelectMany(x => x.GetTypes()) .Where(x => x.GetInterfaces().Contains(typeof(ITypeProvider))) .ToList(); var instances = providers.Select(x => (ITypeProvider)Activator.CreateInstance(x)); foreach (var provider in instances) { var userTypes = provider .GetTypes() .Where(x => !types.Contains(x)); types.AddRange(userTypes); } AOTSupportUtilities.GenerateDLL(_path, "OdinAOTSupport", types); } } finally { AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } }
public static void OnPreprocessBuild() { BuildTarget platform = EditorUserBuildSettings.activeBuildTarget; try { // The EditorOnly dll should aways have the same import settings. But lets just make sure. AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, EditorAssemblyPath, OdinAssemblyImportSettings.IncludeInEditorOnly); if (AssemblyImportSettingsUtilities.IsJITSupported( platform, AssemblyImportSettingsUtilities.GetCurrentScriptingBackend(), AssemblyImportSettingsUtilities.GetCurrentApiCompatibilityLevel())) { AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, AOTAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll); AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, JITAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly); } else { AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, AOTAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly); AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, JITAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll); uNodeAOTScanMethod = "MaxyGames.uNode.Editors.uNodeEditorInitializer".ToType().GetMethod("AOTScan", new Type[] { typeof(List <Type>).MakeByRefType() }); // Generates dll that contains all serialized generic type variants needed at runtime. object[] param = new object[] { null }; bool flag = (bool)uNodeAOTScanMethod.Invoke(null, param); List <Type> types = param[0] as List <Type>; if (flag) { AOTSupportUtilities.GenerateDLL(GenerateAssembliesDir, "OdinAOTSupport", types); } } } finally { AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } }
public static void OnPreprocessBuild() { BuildTarget platform = EditorUserBuildSettings.activeBuildTarget; try { // The EditorOnly dll should aways have the same import settings. But lets just make sure. AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, EditorAssemblyPath, OdinAssemblyImportSettings.IncludeInEditorOnly); if (AssemblyImportSettingsUtilities.IsJITSupported( platform, AssemblyImportSettingsUtilities.GetCurrentScriptingBackend(), AssemblyImportSettingsUtilities.GetCurrentApiCompatibilityLevel())) { AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, AOTAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll); AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, JITAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly); } else { AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, AOTAssemblyPath, OdinAssemblyImportSettings.IncludeInBuildOnly); AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, JITAssemblyPath, OdinAssemblyImportSettings.ExcludeFromAll); // Generates dll that contains all serialized generic type variants needed at runtime. List <Type> types; if (AOTSupportUtilities.ScanProjectForSerializedTypes(out types)) { types.Add(typeof(DataFormat)); AOTSupportUtilities.GenerateDLL(GenerateAssembliesDir, "Lasm.Bolt.UniversalSaver.OdinAOTSupport", types); } } } finally { AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } }
private static void ConfigureImportSettings() { if (EditorOnlyModeConfig.Instance.IsEditorOnlyModeEnabled() || ImportSettingsConfig.Instance.AutomateBeforeBuild == false) { return; } var assemblyDir = new DirectoryInfo(SirenixAssetPaths.SirenixAssembliesPath).FullName; var projectAssetsPath = Directory.GetCurrentDirectory().TrimEnd('\\', '/'); var isPackage = PathUtilities.HasSubDirectory(new DirectoryInfo(projectAssetsPath), new DirectoryInfo(assemblyDir)) == false; var aotDirPath = assemblyDir + "NoEmitAndNoEditor/"; var jitDirPath = assemblyDir + "NoEditor/"; var aotDir = new DirectoryInfo(aotDirPath); var jitDir = new DirectoryInfo(jitDirPath); var aotAssemblies = new List <string>(); var jitAssemblies = new List <string>(); foreach (var file in aotDir.GetFiles("*.dll")) { var path = file.FullName; if (isPackage) { path = SirenixAssetPaths.SirenixAssembliesPath.TrimEnd('\\', '/') + "/" + path.Substring(assemblyDir.Length); } else { path = path.Substring(projectAssetsPath.Length + 1); } aotAssemblies.Add(path); } foreach (var file in jitDir.GetFiles("*.dll")) { var path = file.FullName; if (isPackage) { path = SirenixAssetPaths.SirenixAssembliesPath.TrimEnd('\\', '/') + "/" + path.Substring(assemblyDir.Length); } else { path = path.Substring(projectAssetsPath.Length + 1); } jitAssemblies.Add(path); } AssetDatabase.StartAssetEditing(); try { var platform = EditorUserBuildSettings.activeBuildTarget; if (AssemblyImportSettingsUtilities.IsJITSupported( platform, AssemblyImportSettingsUtilities.GetCurrentScriptingBackend(), AssemblyImportSettingsUtilities.GetCurrentApiCompatibilityLevel())) { ApplyImportSettings(platform, aotAssemblies.ToArray(), OdinAssemblyImportSettings.ExcludeFromAll); ApplyImportSettings(platform, jitAssemblies.ToArray(), OdinAssemblyImportSettings.IncludeInBuildOnly); } else { ApplyImportSettings(platform, aotAssemblies.ToArray(), OdinAssemblyImportSettings.IncludeInBuildOnly); ApplyImportSettings(platform, jitAssemblies.ToArray(), OdinAssemblyImportSettings.ExcludeFromAll); } } finally { AssetDatabase.StopAssetEditing(); } }