예제 #1
0
 public static void GatherSerializedObjectCacheEntries(this WriteCommand command, HashSet <CacheEntry> cacheEntries)
 {
     if (command.serializeObjects != null)
     {
         var objectIds = command.serializeObjects.Select(x => x.serializationObject);
         var types     = BuildCacheUtility.GetSortedUniqueTypesForObjects(objectIds);
         cacheEntries.UnionWith(types.Select(BuildCacheUtility.GetCacheEntry));
         cacheEntries.UnionWith(objectIds.Select(BuildCacheUtility.GetCacheEntry));
     }
 }
        public void BuildCacheUtility_GetSortedUniqueTypesForObjects_ReturnsUniqueAndSortedTypeArray()
        {
            var includes = ContentBuildInterface.GetPlayerObjectIdentifiersInAsset(k_TempGuid, EditorUserBuildSettings.activeBuildTarget);

            // Test prefab is created using 2 primitive cubes, one parented to the other, so the includes will in turn contain the sequence 2x:
            Type[] expectedTypes = new[] { typeof(GameObject), typeof(Transform), typeof(MeshFilter), typeof(MeshRenderer), typeof(BoxCollider) };
            Array.Sort(expectedTypes, (x, y) => x.AssemblyQualifiedName.CompareTo(y.AssemblyQualifiedName));

            var actualTypes = BuildCacheUtility.GetSortedUniqueTypesForObjects(includes);

            Assert.AreEqual(expectedTypes.Length * 2, includes.Length);
            Assert.AreEqual(expectedTypes.Length, actualTypes.Length);
            CollectionAssert.AreEqual(expectedTypes, actualTypes);
        }
예제 #3
0
        /// <summary>
        /// Returns the Object Identifiers and Types in a raw Unity Serialized File. The resulting arrays will be empty if a non-serialized file path was used.
        /// </summary>
        /// <param name="path">Path to the Unity Serialized File</param>
        /// <param name="objectIdentifiers">Object Identifiers for all the objects in the serialized file</param>
        /// <param name="types">Types for all the objects in the serialized file</param>
        /// <param name="additionalGlobalUsage">Additional global lighting usage information to include with this custom asset</param>
        public void GetObjectIdentifiersAndTypesForSerializedFile(string path, out ObjectIdentifier[] objectIdentifiers, out Type[] types, BuildUsageTagGlobal additionalGlobalUsage)
        {
            // Additional global usage is local to the custom asset, so we are using a local copy of this additional data to avoid influencing the calcualtion
            // of other custom assets. Additionally we store all the addtional global usage for later copying back into the dependency data result for the final write build task.
            var globalUsage = m_GlobalUsage | additionalGlobalUsage;

            m_CustomUsage = m_CustomUsage | additionalGlobalUsage;
            if (!LoadCachedData(path, out var assetInfo, out var buildUsage, globalUsage))
            {
                GatherAssetData(path, out assetInfo, out buildUsage, globalUsage);
            }

            // Local cache to reuse data from this function in the next function
            m_AssetInfo[path]  = assetInfo;
            m_BuildUsage[path] = buildUsage;

            objectIdentifiers = assetInfo.includedObjects.ToArray();
            types             = BuildCacheUtility.GetSortedUniqueTypesForObjects(objectIdentifiers);
        }