public void Changing_SceneCallbackVersionHash_ChangesHashesOf_SceneWriteOperations()
        {
            Hash128[] preHash = new Hash128[5];
            for (int i = 0; i < WriteOperations.Length; i++)
            {
                preHash[i] = WriteOperations[i].GetHash128();
            }

            BuildInterfacesWrapper.SceneCallbackVersionHash = HashingMethods.Calculate(GUID.Generate()).ToHash128();

            Hash128[] postHash = new Hash128[5];
            for (int i = 0; i < WriteOperations.Length; i++)
            {
                postHash[i] = WriteOperations[i].GetHash128();
            }

            // We expect AssetBundleWriteOperation [0] and RawWriteOperation [1] to not be changed by  the scene callback version hash.
            for (int i = 0; i < 2; i++)
            {
                Assert.AreEqual(preHash[i], postHash[i], "{0} hash changed.", WriteOperations[i].GetType().Name);
            }

            // We expect SceneBundleWriteOperation [2], SceneDataWriteOperation [3], and SceneRawWriteOperation [4] to be changed by the scene callback version hash.
            for (int i = 2; i < WriteOperations.Length; i++)
            {
                Assert.AreNotEqual(preHash[i], postHash[i], "{0} hash unchanged. Not", WriteOperations[i].GetType().Name);
            }
        }
Esempio n. 2
0
        public Hash128 CalculateInputHash(BuildCommandSet commands, BuildSettings settings)
        {
            // TODO: Figure out if explicitAssets hash is not enough and we need use assetBundleObjects instead
            var assetHashes = new List <string>();

            if (!commands.commands.IsNullOrEmpty())
            {
                for (var i = 0; i < commands.commands.Length; i++)
                {
                    if (commands.commands[i].explicitAssets.IsNullOrEmpty())
                    {
                        continue;
                    }

                    for (var k = 0; k < commands.commands[i].explicitAssets.Length; k++)
                    {
                        // TODO: Create GUIDToAssetPath that takes GUID struct
                        var path = AssetDatabase.GUIDToAssetPath(commands.commands[i].explicitAssets[k].asset.ToString());
                        var hash = AssetDatabase.GetAssetDependencyHash(path);
                        // TODO: Figure out a way to not create a string for every hash.
                        assetHashes.Add(hash.ToString());
                    }
                }
            }

            return(HashingMethods.CalculateMD5Hash(Version, commands, settings.target, settings.group, settings.editorBundles, assetHashes));
        }
        public void CreateAssetEntryForObjectIdentifiers_ThrowsExceptionOnAssetGUIDCollision()
        {
            var address   = "CustomAssetAddress";
            var assetInfo = new Dictionary <GUID, AssetLoadInfo>();

            assetInfo.Add(HashingMethods.Calculate(address).ToGUID(), new AssetLoadInfo());

            var customContent = new List <CustomContent>
            {
                new CustomContent
                {
                    Asset     = new GUID(),
                    Processor = (guid, task) =>
                    {
                        var ex       = Assert.Throws <System.ArgumentException>(() => task.CreateAssetEntryForObjectIdentifiers(null, null, null, address, null));
                        var expected = string.Format("Custom Asset '{0}' already exists. Building duplicate asset entries is not supported.", address);
                        Assert.That(ex.Message, Is.EqualTo(expected));
                    }
                }
            };

            var buildTask = CreateDefaultBuildTask(customContent, assetInfo);

            buildTask.Run();
        }
Esempio n. 4
0
        public void CsMD4_Calcualte_FileNames_IdenticalTo_CppMD4()
        {
            // Test ensures our C# implementation of MD4 matches our expected C++ MD4 for compatibility
            // Until which time we no longer care about compatibility with BuildPipeline.BuildAssetBundles
            var sourceNames = new[]
            {
                "basic_sprite",
                "audio",
                "prefabs",
                "shaderwithcollection",
                "multi_sprite_packed"
            };

            var expectedNames = new[]
            {
                "a67a7313ceb7840411094318a4aa7055",
                "d5ae2b5aa3edc0f73b4bb6b1ae125a53",
                "6fee5e41c4939eed80f81beb3e5e6ebc",
                "dc5d7d3a7d9efcf91a0314cdcc3af3c8",
                "ddc8dcea83a5ff418d94c6a1623e81ad"
            };

            for (var i = 0; i < 5; i++)
            {
                Assert.AreEqual(expectedNames[i], HashingMethods.Calculate <MD4>(sourceNames[i]).ToString());
            }
        }
Esempio n. 5
0
 static void GetRawHashes <T>(byte[] b, List <RawHash> hashes) where T : HashAlgorithm
 {
     for (int i = 0; i < k_PerfRunCount; i++)
     {
         hashes.Add(HashingMethods.Calculate <T>(b));
     }
 }
        public void CSharpMD4GeneratesCppMD4IdenticalFileNames()
        {
            var sourceNames = new[]
            {
                "basic_sprite",
                "audio",
                "prefabs",
                "shaderwithcollection",
                "multi_sprite_packed"
            };

            var expectedNames = new[]
            {
                "a67a7313ceb7840411094318a4aa7055",
                "d5ae2b5aa3edc0f73b4bb6b1ae125a53",
                "6fee5e41c4939eed80f81beb3e5e6ebc",
                "dc5d7d3a7d9efcf91a0314cdcc3af3c8",
                "ddc8dcea83a5ff418d94c6a1623e81ad"
            };

            for (var i = 0; i < 5; i++)
            {
                Assert.AreEqual(expectedNames[i], HashingMethods.Calculate <MD4>(sourceNames[i]).ToString());
            }
        }
Esempio n. 7
0
    public static CacheEntry GetCacheEntry(string path, int version = 1)
    {
        CacheEntry entry;
        KeyValuePair <string, int> key = new KeyValuePair <string, int>(path, version);

        if (m_PathToHash.TryGetValue(key, out entry))
        {
            return(entry);
        }

        var guid = AssetDatabase.AssetPathToGUID(path);

        if (!string.IsNullOrEmpty(guid))
        {
            return(GetCacheEntry(new GUID(guid), version));
        }

        entry = new CacheEntry {
            File = path, Version = version
        };
        entry.Guid = HashingMethods.Calculate("FileHash", entry.File).ToGUID();
        if (File.Exists(entry.File))
        {
            entry.Hash = HashingMethods.Calculate(HashingMethods.CalculateFile(entry.File), entry.Version).ToHash128();
        }
        entry.Type = CacheEntry.EntryType.File;

        m_PathToHash[key] = entry;
        return(entry);
    }
        public Hash128 CalculateInputHash(BuildInput input, BuildTarget target)
        {
            var assetHashes = new List <string>();

            if (!input.definitions.IsNullOrEmpty())
            {
                for (var i = 0; i < input.definitions.Length; i++)
                {
                    if (input.definitions[i].explicitAssets.IsNullOrEmpty())
                    {
                        continue;
                    }

                    for (var k = 0; k < input.definitions[i].explicitAssets.Length; k++)
                    {
                        // TODO: Create GUIDToAssetPath that takes GUID struct
                        var path = AssetDatabase.GUIDToAssetPath(input.definitions[i].explicitAssets[k].asset.ToString());
                        var hash = AssetDatabase.GetAssetDependencyHash(path);
                        // TODO: Figure out a way to not create a string for every hash.
                        assetHashes.Add(hash.ToString());
                    }
                }
            }

            return(HashingMethods.CalculateMD5Hash(Version, input, target, assetHashes));
        }
        /// <inheritdoc />
        public Hash128 GetHash128(IBuildLogger log)
        {
#if UNITY_2019_3_OR_NEWER
            CacheEntry entry = BuildCacheUtility.GetCacheEntry(Scene);
#else
            CacheEntry entry = BuildCacheUtility.GetCacheEntry(ProcessedScene);
#endif
            HashSet <CacheEntry> hashObjects = new HashSet <CacheEntry>();
            using (log.ScopedStep(LogLevel.Verbose, $"Gather Objects", Command.fileName))
                Command.GatherSerializedObjectCacheEntries(hashObjects);

            List <Hash128> hashes = new List <Hash128>();
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing Command", Command.fileName))
                hashes.Add(Command.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing UsageSet", Command.fileName))
                hashes.Add(UsageSet.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing ReferenceMap", Command.fileName))
                hashes.Add(ReferenceMap.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing PreloadInfo", Command.fileName))
                hashes.Add(PreloadInfo.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing Info", Command.fileName))
                hashes.Add(Info.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing Objects", Command.fileName))
                hashes.Add(HashingMethods.Calculate(hashObjects).ToHash128());
            hashes.Add(new Hash128(0, 0, 0, (uint)QualitySettingsApi.GetNumberOfLODsStripped()));
            hashes.Add(DependencyHash);

            return(HashingMethods.Calculate(hashes, Scene, entry).ToHash128());
        }
Esempio n. 10
0
        private Hash128 CalculateInputHash(IWriteOperation operation, List <WriteCommand> dependencies, BuildSettings settings, BuildUsageTagGlobal globalUsage, BuildUsageTagSet buildUsage)
        {
            if (!UseCache)
            {
                return(new Hash128());
            }

            var empty       = new GUID();
            var assets      = new HashSet <GUID>();
            var assetHashes = new List <Hash128>();

            foreach (var objectId in operation.command.serializeObjects)
            {
                var guid = objectId.serializationObject.guid;
                if (guid == empty || !assets.Add(guid))
                {
                    continue;
                }

                var path = AssetDatabase.GUIDToAssetPath(guid.ToString());
                assetHashes.Add(AssetDatabase.GetAssetDependencyHash(path));
            }

            var sceneOp = operation as SceneDataWriteOperation;

            if (sceneOp != null)
            {
                assetHashes.Add(HashingMethods.CalculateFileMD5Hash(sceneOp.processedScene));
            }

            return(HashingMethods.CalculateMD5Hash(Version, operation, assetHashes, dependencies, globalUsage, buildUsage, settings));
        }
    public StreamHasher()
    {
        var hasher = HashingMethods.GetHashAlgorithm();

        m_Stream = new HashStream(hasher);
        Writer   = new BinaryWriter(m_Stream);
    }
Esempio n. 12
0
        internal void HandleDuplicateBundleNames(List <AssetBundleBuild> bundleInputDefs, Dictionary <string, string> bundleToAssetGroup, string assetGroupGuid, out List <string> generatedUniqueNames)
        {
            generatedUniqueNames = new List <string>();
            var handledNames = new HashSet <string>();

            for (int i = 0; i < bundleInputDefs.Count; i++)
            {
                AssetBundleBuild bundleBuild     = bundleInputDefs[i];
                string           assetBundleName = bundleBuild.assetBundleName;
                if (handledNames.Contains(assetBundleName))
                {
                    int count   = 1;
                    var newName = assetBundleName;
                    while (handledNames.Contains(newName) && count < 1000)
                    {
                        newName = assetBundleName.Replace(".bundle", string.Format("{0}.bundle", count++));
                    }
                    assetBundleName = newName;
                }

                string hashedAssetBundleName = HashingMethods.Calculate(assetBundleName) + ".bundle";
                generatedUniqueNames.Add(assetBundleName);
                handledNames.Add(assetBundleName);

                bundleBuild.assetBundleName = hashedAssetBundleName;
                bundleInputDefs[i]          = bundleBuild;

                bundleToAssetGroup.Add(hashedAssetBundleName, assetGroupGuid);
            }
        }
Esempio n. 13
0
        /// <inheritdoc />
        public Hash128 GetHash128(IBuildLogger log)
        {
            HashSet <CacheEntry> hashObjects = new HashSet <CacheEntry>();

            using (log.ScopedStep(LogLevel.Verbose, $"Gather Objects {GetType().Name}", Command.fileName))
            {
                if (Command.serializeObjects != null)
                {
                    foreach (var serializeObject in Command.serializeObjects)
                    {
                        hashObjects.Add(BuildCacheUtility.GetCacheEntry(serializeObject.serializationObject));
                    }
                }
            }

            List <Hash128> hashes = new List <Hash128>();

            using (log.ScopedStep(LogLevel.Verbose, $"Hashing Command", Command.fileName))
                hashes.Add(Command.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing UsageSet", Command.fileName))
                hashes.Add(UsageSet.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing ReferenceMap", Command.fileName))
                hashes.Add(ReferenceMap.GetHash128());
            using (log.ScopedStep(LogLevel.Verbose, $"Hashing Objects", Command.fileName))
                hashes.Add(HashingMethods.Calculate(hashObjects).ToHash128());
            hashes.Add(DependencyHash);

            return(HashingMethods.Calculate(hashes).ToHash128());
        }
 static int GetSortIndex(Type type)
 {
     // ContentBuildInterface.GetTypeForObjects returns null for some MonoBehaviours, this will fix it until the API is fixed.
     if (type == null)
     {
         return(Int32.MaxValue - 3);
     }
     if (type == typeof(MonoScript))
     {
         return(Int32.MinValue);
     }
     if (typeof(ScriptableObject).IsAssignableFrom(type))
     {
         return(Int32.MaxValue - 4);
     }
     if (typeof(MonoBehaviour).IsAssignableFrom(type))
     {
         return(Int32.MaxValue - 3);
     }
     if (typeof(TerrainData).IsAssignableFrom(type))
     {
         return(Int32.MaxValue - 2);
     }
     return(BitConverter.ToInt32(HashingMethods.Calculate(type.Name).ToBytes(), 0));
 }
Esempio n. 15
0
 public void CsMD4_Calcualte_FileIDs_IdenticalTo_CppMD4()
 {
     // Test ensures our C# implementation of MD4 matches our expected C++ MD4 for compatibility
     // Until which time we no longer care about compatibility with BuildPipeline.BuildAssetBundles
     Assert.AreEqual(-7588530676450950513, BitConverter.ToInt64(HashingMethods.Calculate <MD4>("fb3a9882e5510684697de78116693750", FileType.MetaAssetType, (long)21300000).ToBytes(), 0));
     Assert.AreEqual(-8666180608703991793, BitConverter.ToInt64(HashingMethods.Calculate <MD4>("library/atlascache/27/2799803afb660251e3b3049ba37cb15a", (long)2).ToBytes(), 0));
 }
Esempio n. 16
0
        private SerializedFileMetaData CalculateFileMetadata(ref WriteResult result)
        {
            List <object> contentHashObjects = new List <object>();
            List <object> fullHashObjects    = new List <object>();

            foreach (ResourceFile file in result.resourceFiles)
            {
                RawHash fileHash    = HashingMethods.CalculateFile(file.fileName);
                RawHash contentHash = fileHash;
                fullHashObjects.Add(fileHash);
                if (file.serializedFile && result.serializedObjects.Count > 0)
                {
                    using (var stream = new FileStream(file.fileName, FileMode.Open, FileAccess.Read))
                    {
                        stream.Position = (long)result.serializedObjects[0].header.offset;
                        contentHash     = HashingMethods.CalculateStream(stream);
                    }
                }
                contentHashObjects.Add(contentHash);
            }
            SerializedFileMetaData data = new SerializedFileMetaData();

            data.RawFileHash = HashingMethods.Calculate(fullHashObjects).ToHash128();
            data.ContentHash = HashingMethods.Calculate(contentHashObjects).ToHash128();
            return(data);
        }
        public void CreateAssetEntryForObjectIdentifiers(ObjectIdentifier[] includedObjects, string path, string bundleName, string address, Type mainAssetType)
        {
            AssetLoadInfo    assetInfo = new AssetLoadInfo();
            BuildUsageTagSet usageTags = new BuildUsageTagSet();

            assetInfo.asset = HashingMethods.Calculate(address).ToGUID();
            if (m_DependencyData.AssetInfo.ContainsKey(assetInfo.asset))
            {
                throw new ArgumentException(string.Format("Custom Asset '{0}' already exists. Building duplicate asset entries is not supported.", address));
            }

            assetInfo.includedObjects = new List <ObjectIdentifier>(includedObjects);
            var referencedObjects = ContentBuildInterface.GetPlayerDependenciesForObjects(includedObjects, m_Parameters.Target, m_Parameters.ScriptInfo);

            assetInfo.referencedObjects = new List <ObjectIdentifier>(referencedObjects);
            ContentBuildInterface.CalculateBuildUsageTags(referencedObjects, includedObjects, m_GlobalUsage, usageTags, m_DependencyData.DependencyUsageCache);

            List <GUID> assets;

            m_Content.BundleLayout.GetOrAdd(bundleName, out assets);
            assets.Add(assetInfo.asset);

            m_Content.Addresses[assetInfo.asset]  = address;
            m_Content.FakeAssets[assetInfo.asset] = path;
            SetOutputInformation(assetInfo.asset, assetInfo, usageTags);
        }
    static void CreateCatalog(AddressableAssetSettings aaSettings, ContentCatalogData contentCatalog, List <ResourceLocationData> locations, string playerVersion, string localCatalogFilename, FileRegistry registry, string localBuildPath)
    {
        //var localBuildPath = Addressables.BuildPath + "/" + localCatalogFilename;
        localBuildPath += "/" + localCatalogFilename;
        var localLoadPath = "{UnityEngine.AddressableAssets.Addressables.RuntimePath}/" + localCatalogFilename;

        var jsonText = JsonUtility.ToJson(contentCatalog);

        WriteFile(localBuildPath, jsonText, registry);

        string[] dependencyHashes = null;
        if (aaSettings.BuildRemoteCatalog)
        {
            var contentHash = HashingMethods.Calculate(jsonText).ToString();

            var versionedFileName = aaSettings.profileSettings.EvaluateString(aaSettings.activeProfileId, "/catalog_" + playerVersion);
            var remoteBuildFolder = aaSettings.RemoteCatalogBuildPath.GetValue(aaSettings);
            var remoteLoadFolder  = aaSettings.RemoteCatalogLoadPath.GetValue(aaSettings);

            if (string.IsNullOrEmpty(remoteBuildFolder) ||
                string.IsNullOrEmpty(remoteLoadFolder) ||
                remoteBuildFolder == AddressableAssetProfileSettings.undefinedEntryValue ||
                remoteLoadFolder == AddressableAssetProfileSettings.undefinedEntryValue)
            {
                Addressables.LogWarning("Remote Build and/or Load paths are not set on the main AddressableAssetSettings asset, but 'Build Remote Catalog' is true.  Cannot create remote catalog.  In the inspector for any group, double click the 'Addressable Asset Settings' object to begin inspecting it. '" + remoteBuildFolder + "', '" + remoteLoadFolder + "'");
            }
            else
            {
                var remoteJsonBuildPath = remoteBuildFolder + versionedFileName + ".json";
                var remoteHashBuildPath = remoteBuildFolder + versionedFileName + ".hash";

                WriteFile(remoteJsonBuildPath, jsonText, registry);
                WriteFile(remoteHashBuildPath, contentHash, registry);

                dependencyHashes = new string[((int)ContentCatalogProvider.DependencyHashIndex.Count)];
                dependencyHashes[(int)ContentCatalogProvider.DependencyHashIndex.Remote] = ResourceManagerRuntimeData.kCatalogAddress + "RemoteHash";
                dependencyHashes[(int)ContentCatalogProvider.DependencyHashIndex.Cache]  = ResourceManagerRuntimeData.kCatalogAddress + "CacheHash";

                var remoteHashLoadPath = remoteLoadFolder + versionedFileName + ".hash";
                locations.Add(new ResourceLocationData(
                                  new[] { dependencyHashes[(int)ContentCatalogProvider.DependencyHashIndex.Remote] },
                                  remoteHashLoadPath,
                                  typeof(TextDataProvider), typeof(string)));

                var cacheLoadPath = "{UnityEngine.Application.persistentDataPath}/com.unity.addressables" + versionedFileName + ".hash";
                locations.Add(new ResourceLocationData(
                                  new[] { dependencyHashes[(int)ContentCatalogProvider.DependencyHashIndex.Cache] },
                                  cacheLoadPath,
                                  typeof(TextDataProvider), typeof(string)));
            }
        }

        locations.Add(new ResourceLocationData(
                          new[] { ResourceManagerRuntimeData.kCatalogAddress },
                          localLoadPath,
                          typeof(ContentCatalogProvider),
                          typeof(ContentCatalogData),
                          dependencyHashes));
    }
        internal static Hash128 CalculateHashVersion(ArchiveWorkItem item, string[] dependencies)
        {
            List <Hash128> hashes = new List <Hash128>();

            hashes.AddRange(item.SeriliazedFileMetaDatas.Select(x => x.ContentHash));

            return(HashingMethods.Calculate(hashes, dependencies).ToHash128());
        }
Esempio n. 20
0
        public void HashingMethods_Has128x2Fast_SameAsGeneric()
        {
            // Test ensures the HashingMethods.Calculate(Hash128, Hash128) fast path produces the same results as the general HashingMethods.Calculate(params object[] objects) one does
            Hash128 hash1 = new Hash128(0x1122334455667788, 0x99AABBCCDDEEFF00);
            Hash128 hash2 = new Hash128(0x123456789ABCDEF0, 0x1967AbC487Df2F12);

            Assert.AreEqual(HashingMethods.Calculate(hash1, hash2), HashingMethods.Calculate(new object[] { hash1, hash2 }));
        }
#pragma warning restore 649

        CacheEntry GetCacheEntry(string bundleName, IEnumerable <ResourceFile> resources, BuildCompression compression)
        {
            var entry = new CacheEntry();

            entry.Type = CacheEntry.EntryType.Data;
            entry.Guid = HashingMethods.Calculate("ArchiveAndCompressBundles", bundleName).ToGUID();
            entry.Hash = HashingMethods.Calculate(Version, resources, compression).ToHash128();
            return(entry);
        }
Esempio n. 22
0
        public Hash128 CalculateInputHash(BuildCommandSet commands, BuildOutput output, uint[] crcs, string outputFolder)
        {
            if (!UseCache)
            {
                return(new Hash128());
            }

            return(HashingMethods.CalculateMD5Hash(Version, commands, output, crcs));
        }
        private Hash128 CalculateInputHash(AssetBundleBuild[] input)
        {
            if (!UseCache)
            {
                return(new Hash128());
            }

            return(HashingMethods.CalculateMD5Hash(Version, input));
        }
Esempio n. 24
0
#pragma warning restore 649

        CacheEntry GetCacheEntry(IWriteOperation operation, BuildSettings settings, BuildUsageTagGlobal globalUsage)
        {
            var entry = new CacheEntry();

            entry.Type = CacheEntry.EntryType.Data;
            entry.Guid = HashingMethods.Calculate("WriteSerializedFiles", operation.Command.internalName).ToGUID();
            entry.Hash = HashingMethods.Calculate(Version, operation.GetHash128(), settings.GetHash128(), globalUsage).ToHash128();
            return(entry);
        }
Esempio n. 25
0
        private Hash128 CalculateInputHash(BuildDependencyInfo input)
        {
            if (!UseCache)
            {
                return(new Hash128());
            }

            return(HashingMethods.CalculateMD5Hash(Version, input));
        }
        private Hash128 CalculateInputHash(BuildDependencyInformation buildInfo)
        {
            if (!UseCache)
            {
                return(new Hash128());
            }

            return(HashingMethods.CalculateMD5Hash(Version, buildInfo.assetLoadInfo, buildInfo.assetToBundles, buildInfo.bundleToAssets, buildInfo.sceneUsageTags));
        }
Esempio n. 27
0
 /// <inheritdoc />
 public virtual long SerializationIndexFromObjectIdentifier(ObjectIdentifier objectID)
 {
     RawHash hash;
     if (objectID.fileType == FileType.MetaAssetType || objectID.fileType == FileType.SerializedAssetType)
         hash = HashingMethods.Calculate<MD4>(objectID.guid.ToString(), objectID.fileType, objectID.localIdentifierInFile);
     else
         hash = HashingMethods.Calculate<MD4>(objectID.filePath, objectID.localIdentifierInFile);
     return BitConverter.ToInt64(hash.ToBytes(), 0);
 }
        /// <inheritdoc />
        public Hash128 GetHash128()
        {
#if UNITY_2019_3_OR_NEWER
            return(HashingMethods.Calculate(Command, UsageSet.GetHash128(), ReferenceMap.GetHash128(), Scene, PreloadInfo).ToHash128());
#else
            var processedSceneHash = HashingMethods.CalculateFile(ProcessedScene).ToHash128();
            return(HashingMethods.Calculate(Command, UsageSet.GetHash128(), ReferenceMap.GetHash128(), Scene, processedSceneHash, PreloadInfo).ToHash128());
#endif
        }
Esempio n. 29
0
        private Hash128 CalculateInputHash(AssetInfoMap assetLoadInfo, SpriteRefMap spriteRefCount)
        {
            if (!UseCache)
            {
                return(new Hash128());
            }

            return(HashingMethods.CalculateMD5Hash(Version, assetLoadInfo, spriteRefCount));
        }
Esempio n. 30
0
        internal static void PrepGroupBundlePacking(AddressableAssetGroup assetGroup, List <AssetBundleBuild> bundleInputDefs, BundledAssetGroupSchema.BundlePackingMode packingMode)
        {
            if (packingMode == BundledAssetGroupSchema.BundlePackingMode.PackTogether)
            {
                var allEntries = new List <AddressableAssetEntry>();
                foreach (var a in assetGroup.entries)
                {
                    a.GatherAllAssets(allEntries, true, true, false);
                }
                GenerateBuildInputDefinitions(allEntries, bundleInputDefs,
                                              HashingMethods.Calculate(new HashSet <string>(assetGroup.entries.Select(e => e.guid))).ToString(), "all");
            }
            else
            {
                if (packingMode == BundledAssetGroupSchema.BundlePackingMode.PackSeparately)
                {
                    foreach (var a in assetGroup.entries)
                    {
                        var allEntries = new List <AddressableAssetEntry>();
                        a.GatherAllAssets(allEntries, true, true, false);
                        GenerateBuildInputDefinitions(allEntries, bundleInputDefs,
                                                      HashingMethods.Calculate(new HashSet <string>(assetGroup.entries.Select(e => e.guid))).ToString(), a.address);
                    }
                }
                else
                {
                    var labelTable = new Dictionary <string, List <AddressableAssetEntry> >();
                    foreach (var a in assetGroup.entries)
                    {
                        var sb = new StringBuilder();
                        foreach (var l in a.labels)
                        {
                            sb.Append(l);
                        }
                        var key = sb.ToString();
                        List <AddressableAssetEntry> entries;
                        if (!labelTable.TryGetValue(key, out entries))
                        {
                            labelTable.Add(key, entries = new List <AddressableAssetEntry>());
                        }
                        entries.Add(a);
                    }

                    foreach (var entryGroup in labelTable)
                    {
                        var allEntries = new List <AddressableAssetEntry>();
                        foreach (var a in entryGroup.Value)
                        {
                            a.GatherAllAssets(allEntries, true, true, false);
                        }
                        GenerateBuildInputDefinitions(allEntries, bundleInputDefs,
                                                      HashingMethods.Calculate(new HashSet <string>(assetGroup.entries.Select(e => e.guid))).ToString(), entryGroup.Key);
                    }
                }
            }
        }