public void Update(ProgressBase progress) { Lookup.Clear(); Stack <PathSegment> stack = new Stack <PathSegment>(); TraverseValues traverseValues = new TraverseValues(); traverseValues.SceneObjects = new HashSet <UnityEngine.Object>(); GameObject[] rootGameObjects = GetRootGameObjects(); foreach (GameObject gameObject in rootGameObjects) { FindAllGameObjects(gameObject, traverseValues); } foreach (GameObject gameObject in rootGameObjects) { TraverseGameObject(gameObject, stack, traverseValues); } Nodes = new IResolvedNode[Lookup.Count]; int count = 0; foreach (KeyValuePair <string, InSceneDependencyMappingNode> pair in Lookup) { Nodes[count++] = pair.Value; } }
public bool NeedsUpdate(ProgressBase progress) { string[] assetIds = NodeDependencyLookupUtility.GetAllAssetPathes(progress, true); long[] timeStampsForFiles = NodeDependencyLookupUtility.GetTimeStampsForFiles(assetIds); return(GetNeedsUpdate(assetIds, timeStampsForFiles)); }
public ProgressBase(ProgressBase parent = null) { m_parent = parent; if (parent != null) { parent.m_children.Add(this); } }
/** * Return the dependency lookup for Objects using the ObjectDependencyResolver */ public static void BuildDefaultAssetLookup(NodeDependencyLookupContext stateContext, bool loadFromCache, string savePath, ProgressBase progress) { ResolverUsageDefinitionList usageDefinitionList = new ResolverUsageDefinitionList(); usageDefinitionList.Add <AssetDependencyCache, ObjectSerializedDependencyResolver>(); LoadDependencyLookupForCaches(stateContext, usageDefinitionList, progress, loadFromCache, true, false, savePath); }
public static string[] GetAllAssetPathes(ProgressBase progress, bool unityBuiltin) { string[] pathes = AssetDatabase.GetAllAssetPaths(); pathes = AssetDatabase.GetAllAssetPaths(); List <string> pathList = new List <string>(); foreach (string path in pathes) { pathList.Add(path); } return(pathList.ToArray()); }
public bool NeedsUpdate(ProgressBase progress) { string[] assetIds = NodeDependencyLookupUtility.GetAllAssetPathes(progress, true); long[] timeStampsForFiles = NodeDependencyLookupUtility.GetTimeStampsForFiles(assetIds); foreach (CreatedResolver resolverUsage in _createdDependencyCache.ResolverUsages) { IAssetDependencyResolver assetDependencyResolver = resolverUsage.Resolver as IAssetDependencyResolver; assetDependencyResolver.SetValidGUIDs(); } foreach (CreatedResolver resolverUsage in _createdDependencyCache.ResolverUsages) { IAssetDependencyResolver assetDependencyResolver = resolverUsage.Resolver as IAssetDependencyResolver; if (CheckNeedsUpdateForResolver(assetDependencyResolver, assetIds, timeStampsForFiles, _fileToAssetNodes)) { return(true); } } return(false); }
public bool NeedsUpdate(ProgressBase progress) { return(true); }
public void Initialize(AssetDependencyCache cache, HashSet <string> changedAssets, ProgressBase progress) { TraverserSubSystem.Clear(); foreach (string assetId in changedAssets) { string guid = NodeDependencyLookupUtility.GetGuidFromAssetId(assetId); if (!_inValidGuids.Contains(guid)) { cache._hierarchyTraverser.AddAssetId(assetId, TraverserSubSystem); } } }
public void Initialize(AssetToFileDependencyCache cache, HashSet <string> changedAssets, ProgressBase progress) { Progress = new ResolverProgress(progress, changedAssets.Count, 0.5f); }
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); } }
private FileToAssetsMapping[] GetDependenciesForAssets(FileToAssetsMapping[] fileToAssetsMappings, CreatedDependencyCache createdDependencyCache, ProgressBase progress) { string[] pathes = NodeDependencyLookupUtility.GetAllAssetPathes(progress, true); long[] timestamps = NodeDependencyLookupUtility.GetTimeStampsForFiles(pathes); List <AssetResolverData> data = new List <AssetResolverData>(); foreach (CreatedResolver resolverUsage in createdDependencyCache.ResolverUsages) { if (!(resolverUsage.Resolver is IAssetToFileDependencyResolver)) { continue; } IAssetToFileDependencyResolver resolver = (IAssetToFileDependencyResolver)resolverUsage.Resolver; HashSet <string> changedAssets = GetChangedAssetIds(pathes, timestamps, fileToAssetsMappings); data.Add(new AssetResolverData { ChangedAssets = changedAssets, Resolver = resolver }); resolver.Initialize(this, changedAssets, progress); } Dictionary <string, FileToAssetsMapping> nodeDict = RelationLookup.RelationLookupBuilder.ConvertToDictionary(fileToAssetsMappings); foreach (AssetResolverData resolverData in data) { GetDependenciesForAssetsInResolver(resolverData.ChangedAssets, resolverData.Resolver as IAssetToFileDependencyResolver, nodeDict, progress); } return(nodeDict.Values.ToArray()); }
public void Update(ProgressBase progress) { _fileToAssetsMappings = GetDependenciesForAssets(_fileToAssetsMappings, _createdDependencyCache, progress); }
public static void LoadDependencyLookupForCaches(NodeDependencyLookupContext stateContext, ResolverUsageDefinitionList resolverUsageDefinitionList, ProgressBase progress, bool loadCache = true, bool updateCache = true, bool saveCache = true, string fileDirectory = DEFAULT_CACHE_SAVE_PATH) { stateContext.UpdateFromDefinition(resolverUsageDefinitionList); List <CreatedDependencyCache> caches = stateContext.GetCaches(); foreach (CreatedDependencyCache cacheUsage in caches) { if (cacheUsage.ResolverUsages.Count == 0) { continue; } IDependencyCache cache = cacheUsage.Cache; if (loadCache && !cacheUsage.IsLoaded) { cache.Load(fileDirectory); cacheUsage.IsLoaded = true; } if (updateCache && cache.NeedsUpdate(progress)) { if (cache.CanUpdate()) { cache.Update(progress); if (saveCache) { cache.Save(fileDirectory); } } else { Debug.LogErrorFormat("{0} could not be updated", cache.GetType().FullName); } } } RelationLookup.RelationsLookup lookup = new RelationLookup.RelationsLookup(); lookup.Build(caches); stateContext.RelationsLookup = lookup; }
public void Initialize(ProgressBase progress) { Progress = new ResolverProgress(progress, m_assetIdToResolver.Count, 10); }
private void GetDependenciesForAssetsInResolver(HashSet <string> changedAssets, IAssetDependencyResolver resolver, Dictionary <string, FileToAssetNode> resultList, ProgressBase progress) { string resolverId = resolver.GetId(); foreach (string assetId in changedAssets) { string fileId = NodeDependencyLookupUtility.GetGuidFromAssetId(assetId); if (!resultList.ContainsKey(fileId)) { resultList.Add(fileId, new FileToAssetNode { FileId = fileId }); } FileToAssetNode fileToAssetNode = resultList[fileId]; AssetNode assetNode = fileToAssetNode.GetAssetNode(assetId); List <Dependency> dependencies = new List <Dependency>(); resolver.GetDependenciesForId(assetId, dependencies); AssetNode.ResolverData resolverData = assetNode.GetResolverData(resolverId); resolverData.Dependencies = dependencies; fileToAssetNode.GetResolverTimeStamp(resolverId).TimeStamp = NodeDependencyLookupUtility.GetTimeStampForFileId(fileId); } }
private FileToAssetNode[] GetDependenciesForAssets(FileToAssetNode[] fileToAssetNodes, CreatedDependencyCache createdDependencyCache, ProgressBase progress) { string[] pathes = NodeDependencyLookupUtility.GetAllAssetPathes(progress, true); long[] timestamps = NodeDependencyLookupUtility.GetTimeStampsForFiles(pathes); List <AssetResolverData> data = new List <AssetResolverData>(); _hierarchyTraverser.Clear(); foreach (CreatedResolver resolverUsage in createdDependencyCache.ResolverUsages) { if (!(resolverUsage.Resolver is IAssetDependencyResolver)) { continue; } IAssetDependencyResolver resolver = (IAssetDependencyResolver)resolverUsage.Resolver; HashSet <string> changedAssets = GetChangedAssetIdsForResolver(resolver, pathes, timestamps, _fileToAssetNodes); data.Add(new AssetResolverData { ChangedAssets = changedAssets, Resolver = resolver }); resolver.Initialize(this, changedAssets, progress); } // Execute the searcher for all registered subsystems here to find hierarchy and property pathes _hierarchyTraverser.Initialize(progress); _hierarchyTraverser.Search(); Dictionary <string, FileToAssetNode> nodeDict = RelationLookup.RelationLookupBuilder.ConvertToDictionary(fileToAssetNodes); foreach (AssetResolverData resolverData in data) { GetDependenciesForAssetsInResolver(resolverData.ChangedAssets, resolverData.Resolver as IAssetDependencyResolver, nodeDict, progress); } return(nodeDict.Values.ToArray()); }