/// <inheritdoc/> public ReturnCode Run() { if (!m_Parameters.WriteLinkXML) { return(ReturnCode.SuccessNotRun); } var linker = LinkXmlGenerator.CreateDefault(); foreach (var writeResult in m_Results.WriteResults) { linker.AddTypes(writeResult.Value.includedTypes); #if UNITY_2021_1_OR_NEWER linker.AddSerializedClass(writeResult.Value.includedSerializeReferenceFQN); #else if (writeResult.Value.GetType().GetProperty("includedSerializeReferenceFQN") != null) { linker.AddSerializedClass(writeResult.Value.GetType().GetProperty("includedSerializeReferenceFQN").GetValue(writeResult.Value) as System.Collections.Generic.IEnumerable <string>); } #endif } var linkPath = m_Parameters.GetOutputFilePathForIdentifier(k_LinkXml); linker.Save(linkPath); return(ReturnCode.Success); }
internal void InitializeBuildContext(AddressablesDataBuilderInput builderInput, out AddressableAssetsBuildContext aaContext) { var aaSettings = builderInput.AddressableSettings; m_AllBundleInputDefs = new List <AssetBundleBuild>(); m_OutputAssetBundleNames = new List <string>(); var bundleToAssetGroup = new Dictionary <string, string>(); var runtimeData = new ResourceManagerRuntimeData { CertificateHandlerType = aaSettings.CertificateHandlerType, BuildTarget = builderInput.Target.ToString(), ProfileEvents = builderInput.ProfilerEventsEnabled, LogResourceManagerExceptions = aaSettings.buildSettings.LogResourceManagerExceptions, DisableCatalogUpdateOnStartup = aaSettings.DisableCatalogUpdateOnStartup, IsLocalCatalogInBundle = aaSettings.BundleLocalCatalog }; m_Linker = new LinkXmlGenerator(); m_Linker.SetTypeConversion(typeof(UnityEditor.Animations.AnimatorController), typeof(RuntimeAnimatorController)); m_Linker.AddTypes(runtimeData.CertificateHandlerType); m_ResourceProviderData = new List <ObjectInitializationData>(); aaContext = new AddressableAssetsBuildContext { settings = aaSettings, runtimeData = runtimeData, bundleToAssetGroup = bundleToAssetGroup, locations = new List <ContentCatalogDataEntry>(), providerTypes = new HashSet <Type>() }; m_CreatedProviderIds = new HashSet <string>(); }
/// <inheritdoc /> protected override TResult BuildDataImplementation <TResult>(AddressablesDataBuilderInput builderInput) { TResult result = default(TResult); var timer = new Stopwatch(); timer.Start(); var aaSettings = builderInput.AddressableSettings; var locations = new List <ContentCatalogDataEntry>(); m_AllBundleInputDefs = new List <AssetBundleBuild>(); m_OutputAssetBundleNames = new List <string>(); var bundleToAssetGroup = new Dictionary <string, string>(); var runtimeData = new ResourceManagerRuntimeData(); runtimeData.CertificateHandlerType = aaSettings.CertificateHandlerType; runtimeData.BuildTarget = builderInput.Target.ToString(); runtimeData.ProfileEvents = builderInput.ProfilerEventsEnabled; runtimeData.LogResourceManagerExceptions = aaSettings.buildSettings.LogResourceManagerExceptions; m_Linker = new LinkXmlGenerator(); m_Linker.SetTypeConversion(typeof(UnityEditor.Animations.AnimatorController), typeof(RuntimeAnimatorController)); m_Linker.AddTypes(runtimeData.CertificateHandlerType); m_ResourceProviderData = new List <ObjectInitializationData>(); var aaContext = new AddressableAssetsBuildContext { settings = aaSettings, runtimeData = runtimeData, bundleToAssetGroup = bundleToAssetGroup, locations = locations, providerTypes = new HashSet <Type>() }; m_CreatedProviderIds = new HashSet <string>(); var errorString = ProcessAllGroups(aaContext); if (!string.IsNullOrEmpty(errorString)) { result = AddressableAssetBuildResult.CreateResult <TResult>(null, 0, errorString); } if (result == null) { result = DoBuild <TResult>(builderInput, aaContext); } if (result != null) { result.Duration = timer.Elapsed.TotalSeconds; } return(result); }
public void CreateDefault_DoesNotConvert_UnexpectedUnityEditorTypes() { var unexpectedType = typeof(UnityEditor.BuildPipeline); var link = LinkXmlGenerator.CreateDefault(); link.AddTypes(new[] { unexpectedType }); link.Save(k_LinkFile); var xml = ReadLinkXML(k_LinkFile, out int assemblyCount, out int typeCount); Assert.AreEqual(assemblyCount, 1); Assert.AreEqual(typeCount, 1); AssertTypePreserved(xml, unexpectedType); }
public void LinkXML_Preserves_SerializeClasses() { var serializedRefClasses = new[] { "FantasticAssembly:AwesomeNS.Foo", "FantasticAssembly:AwesomeNS.Bar", "SuperFantasticAssembly:SuperAwesomeNS.Bar" }; var link = new LinkXmlGenerator(); link.AddSerializedClass(serializedRefClasses); link.Save(k_LinkFile); var xml = ReadLinkXML(k_LinkFile, out int assemblyCount, out int typeCount); Assert.AreEqual(assemblyCount, 2); Assert.AreEqual(typeCount, 3); AssertTypeWithAttributePreserved(xml, "AwesomeNS.Foo"); AssertTypeWithAttributePreserved(xml, "AwesomeNS.Bar"); AssertTypeWithAttributePreserved(xml, "SuperAwesomeNS.Bar"); }
public void LinkXML_Preserves_MultipleTypes_FromMultipleAssemblies() { var types = new[] { typeof(UnityEngine.MonoBehaviour), typeof(UnityEngine.Build.Pipeline.CompatibilityAssetBundleManifest) }; var link = new LinkXmlGenerator(); link.AddTypes(types); link.Save(k_LinkFile); var xml = ReadLinkXML(k_LinkFile, out int assemblyCount, out int typeCount); Assert.AreEqual(assemblyCount, 2); Assert.AreEqual(typeCount, types.Length); foreach (var t in types) { AssertTypePreserved(xml, t); } }
public void LinkXML_Preserves_Assemblies() { var assemblies = new[] { typeof(UnityEngine.MonoBehaviour).Assembly, typeof(UnityEngine.Build.Pipeline.CompatibilityAssetBundleManifest).Assembly }; var link = new LinkXmlGenerator(); link.AddAssemblies(assemblies); link.Save(k_LinkFile); var xml = ReadLinkXML(k_LinkFile, out int assemblyCount, out int typeCount); Assert.AreEqual(assemblyCount, assemblies.Length); Assert.AreEqual(typeCount, 0); foreach (var a in assemblies) { AssertAssemblyPreserved(xml, a); } }
public ReturnCode Run() { if (!m_Parameters.WriteLinkXML) { return(ReturnCode.SuccessNotRun); } var linker = LinkXmlGenerator.CreateDefault(); foreach (var writeResult in m_Results.WriteResults) { linker.AddTypes(writeResult.Value.includedTypes); } var linkPath = m_Parameters.GetOutputFilePathForIdentifier(k_LinkXml); linker.Save(linkPath); return(ReturnCode.Success); }
public void CreateDefault_Converts_ExpectedUnityEditorTypes() { var types = LinkXmlGenerator.GetEditorTypeConversions(); var editorTypes = types.Select(x => x.Key).ToArray(); var runtimeTypes = types.Select(x => x.Value).ToArray(); var assemblies = runtimeTypes.Select(x => x.Assembly).Distinct().ToArray(); var link = LinkXmlGenerator.CreateDefault(); link.AddTypes(editorTypes); link.Save(k_LinkFile); var xml = ReadLinkXML(k_LinkFile, out int assemblyCount, out int typeCount); Assert.AreEqual(assemblyCount, assemblies.Length); Assert.AreEqual(typeCount, runtimeTypes.Length); foreach (var t in runtimeTypes) { AssertTypePreserved(xml, t); } }