public static ObjectIdentifier[] FilterReferencedObjectIDs(GUID asset, ObjectIdentifier[] references, BuildTarget target, TypeDB typeDB, HashSet <GUID> dependencies) { // Expectation: references is populated with DependencyType.ValidReferences only for the given asset var collectedImmediateReferences = new HashSet <ObjectIdentifier>(); var encounteredDependencies = new HashSet <ObjectIdentifier>(); while (references.Length > 0) { // Track which roots we encounter to do dependency pruning encounteredDependencies.UnionWith(references.Where(x => x.guid != asset && dependencies.Contains(x.guid))); // We only want to recursively grab references for objects being pulled in and won't go to another bundle ObjectIdentifier[] immediateReferencesNotInOtherBundles = references.Where(x => !dependencies.Contains(x.guid) && !collectedImmediateReferences.Contains(x)).ToArray(); collectedImmediateReferences.UnionWith(immediateReferencesNotInOtherBundles); // Grab next set of valid references and loop references = ContentBuildInterface.GetPlayerDependenciesForObjects(immediateReferencesNotInOtherBundles, target, typeDB, DependencyType.ValidReferences); } // We need to ensure that we have a reference to a visible representation so our runtime dependency appending process // can find something that can be appended, otherwise the necessary data will fail to load correctly in all cases. (EX: prefab A has reference to component on prefab B) foreach (var dependency in encounteredDependencies) { // For each dependency, add just the main representation as a reference var representations = ContentBuildInterface.GetPlayerAssetRepresentations(dependency.guid, target); collectedImmediateReferences.Add(representations.First()); } collectedImmediateReferences.UnionWith(encounteredDependencies); return(collectedImmediateReferences.ToArray()); }
static internal void GatherAssetRepresentations(GUID asset, BuildTarget target, out ExtendedAssetData extendedData) { extendedData = null; ObjectIdentifier[] representations = ContentBuildInterface.GetPlayerAssetRepresentations(asset, target); // Main Asset always returns at index 0, we only want representations, so check for greater than 1 length if (representations.IsNullOrEmpty() || representations.Length < 2) { return; } extendedData = new ExtendedAssetData(); extendedData.Representations.AddRange(representations.Skip(1)); }
static internal void GatherAssetRepresentations(GUID asset, BuildTarget target, ObjectIdentifier[] includedObjects, out ExtendedAssetData extendedData) { extendedData = null; var includeSet = new HashSet <ObjectIdentifier>(includedObjects); // GetPlayerAssetRepresentations can return editor only objects, filter out those to only include what is in includedObjects ObjectIdentifier[] representations = ContentBuildInterface.GetPlayerAssetRepresentations(asset, target); var filteredRepresentations = representations.Where(includeSet.Contains); // Main Asset always returns at index 0, we only want representations, so check for greater than 1 length if (representations.IsNullOrEmpty() || filteredRepresentations.Count() < 2) { return; } extendedData = new ExtendedAssetData(); extendedData.Representations.AddRange(filteredRepresentations.Skip(1)); }