示例#1
0
        private void IncrementalLoad(string indexPath)
        {
            var loadTask = new Task("Read", $"Loading {name} index", (task, data) => Setup(), this);

            loadTask.RunThread(() =>
            {
                var step = 0;
                loadTask.Report($"Loading {indexPath}...");
                var fileBytes = File.ReadAllBytes(indexPath);

                loadTask.Report(++step, step + 1);
                if (!index.LoadBytes(fileBytes))
                {
                    Debug.LogError($"Failed to load {indexPath}.", this);
                }

                bytes = fileBytes;
                loadTask.Report($"Checking for changes...");
                loadTask.Report(++step, step + 1);
                Dispatcher.Enqueue(() =>
                {
                    var diff = AssetPostprocessorIndexer.GetDiff(index.timestamp, path => !index.SkipEntry(path, true));
                    if (!diff.empty)
                    {
                        IncrementalUpdate(diff);
                    }

                    loadTask.Resolve(new TaskData(fileBytes, index));
                });
            });
        }
示例#2
0
        internal void IncrementalUpdate()
        {
            var changeset = AssetPostprocessorIndexer.GetDiff(p => HasDocumentChanged(p));

            if (!changeset.empty)
            {
                Log($"IncrementalUpdate", changeset.all.ToArray());
                IncrementalUpdate(changeset);
            }
        }
示例#3
0
        private void IncrementalLoad(string indexPath)
        {
            var indexType = settings.type;
            var loadTask  = new Task("Read", $"Loading {name} index", (task, data) => Setup(), this);

            loadTask.RunThread(() =>
            {
                var step = 0;
                loadTask.Report($"Loading {indexPath}...");
                var fileBytes = File.ReadAllBytes(indexPath);

                loadTask.Report(++step, step + 1);
                if (!index.LoadBytes(fileBytes))
                {
                    Debug.LogError($"Failed to load {indexPath}.", this);
                }

                var deletedAssets = new HashSet <string>();
                if (indexType == IndexType.asset.ToString())
                {
                    foreach (var d in index.GetDocuments())
                    {
                        if (d != null && !File.Exists(d.id))
                        {
                            deletedAssets.Add(d.id);
                        }
                    }
                }

                bytes = fileBytes;
                loadTask.Report($"Checking for changes...");
                loadTask.Report(++step, step + 1);
                Dispatcher.Enqueue(() =>
                {
                    if (!this)
                    {
                        return;
                    }
                    var diff = AssetPostprocessorIndexer.GetDiff(index.timestamp, deletedAssets, path =>
                    {
                        if (index.SkipEntry(path, true))
                        {
                            return(false);
                        }

                        if (!index.TryGetHash(path, out var hash) || !hash.isValid)
                        {
                            return(true);
                        }

                        return(hash != index.GetDocumentHash(path));
                    });
                    if (!diff.empty)
                    {
                        IncrementalUpdate(diff);
                    }

                    loadTask.Resolve(new TaskData(fileBytes, index));
                });
            });
        }