Example #1
0
        private bool GetNeedsUpdate(string[] pathes, long[] timestamps)
        {
            Dictionary <string, FileToAssetsMapping> list = RelationLookup.RelationLookupBuilder.ConvertToDictionary(_fileToAssetsMappings);

            for (int i = 0; i < pathes.Length; ++i)
            {
                string path = pathes[i];
                string guid = AssetDatabase.AssetPathToGUID(path);

                if (list.ContainsKey(guid))
                {
                    FileToAssetsMapping fileToAssetsMapping = list[guid];
                    long timeStamp = timestamps[i];

                    if (fileToAssetsMapping.Timestamp != timeStamp)
                    {
                        return(true);
                    }
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
        public static FileToAssetsMapping[] Deserialize(byte[] bytes)
        {
            int offset = 0;
            int numAssetToFileNodes = CacheSerializerUtils.DecodeShort(ref bytes, ref offset);

            FileToAssetsMapping[] assetToFileMappings = new FileToAssetsMapping[numAssetToFileNodes];

            for (int n = 0; n < numAssetToFileNodes; ++n)
            {
                FileToAssetsMapping mapping = new FileToAssetsMapping();

                mapping.Timestamp = CacheSerializerUtils.DecodeLong(ref bytes, ref offset);
                mapping.FileId    = CacheSerializerUtils.DecodeString(ref bytes, ref offset);

                int numFileNodes = CacheSerializerUtils.DecodeShort(ref bytes, ref offset);

                mapping.FileNodes = new List <FileToAssetMappingNode>();

                for (int i = 0; i < numFileNodes; ++i)
                {
                    FileToAssetMappingNode fileNode = new FileToAssetMappingNode();

                    fileNode.AssetId      = CacheSerializerUtils.DecodeString(ref bytes, ref offset);
                    fileNode.Dependencies = CacheSerializerUtils.DecodeDependencies(ref bytes, ref offset);

                    mapping.FileNodes.Add(fileNode);
                }

                assetToFileMappings[n] = mapping;
            }

            string eof = CacheSerializerUtils.DecodeString(ref bytes, ref offset);

            if (!eof.Equals(EOF))
            {
                Debug.LogError("AssetToFileDependencyCache cache file to be corrupted. Rebuilding cache required");
                return(new FileToAssetsMapping[0]);
            }

            return(assetToFileMappings);
        }
Example #3
0
        private HashSet <string> GetChangedAssetIds(string[] pathes, long[] timestamps, FileToAssetsMapping[] fileToAssetMappings)
        {
            HashSet <string> result = new HashSet <string>();
            Dictionary <string, FileToAssetsMapping> list = RelationLookup.RelationLookupBuilder.ConvertToDictionary(fileToAssetMappings);

            float lastDisplayedPercentage = 0;

            for (int i = 0; i < pathes.Length; ++i)
            {
                float progressPercentage = (float)i / pathes.Length;

                if (progressPercentage - lastDisplayedPercentage > 0.01f)
                {
                    EditorUtility.DisplayProgressBar("AssetToFileDependencyCache", $"Finding changed assets {result.Count}", (float)i / pathes.Length);
                    lastDisplayedPercentage = progressPercentage;
                }

                string path = pathes[i];
                string guid = AssetDatabase.AssetPathToGUID(path);

                if (list.ContainsKey(guid))
                {
                    FileToAssetsMapping fileToAssetsMapping = list[guid];
                    fileToAssetsMapping.SetExisting();

                    long timeStamp = timestamps[i];

                    if (fileToAssetsMapping.Timestamp != timeStamp)
                    {
                        NodeDependencyLookupUtility.AddAssetsToList(result, path);
                    }
                }
                else
                {
                    NodeDependencyLookupUtility.AddAssetsToList(result, path);
                }
            }

            return(result);
        }
Example #4
0
        private void GetDependenciesForAssetsInResolver(HashSet <string> changedAssets, IAssetToFileDependencyResolver resolver, Dictionary <string, FileToAssetsMapping> resultList, ProgressBase progress)
        {
            foreach (string assetId in changedAssets)
            {
                string fileId = NodeDependencyLookupUtility.GetGuidFromAssetId(assetId);

                if (!resultList.ContainsKey(fileId))
                {
                    resultList.Add(fileId, new FileToAssetsMapping {
                        FileId = fileId
                    });
                }

                FileToAssetsMapping    fileToAssetsMapping    = resultList[fileId];
                FileToAssetMappingNode fileToAssetMappingNode = fileToAssetsMapping.GetFileNode(assetId);

                fileToAssetMappingNode.Dependencies.Clear();
                resolver.GetDependenciesForId(assetId, fileToAssetMappingNode.Dependencies);

                fileToAssetsMapping.Timestamp = NodeDependencyLookupUtility.GetTimeStampForFileId(fileId);
            }
        }