コード例 #1
0
        /**
         * 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);
        }
コード例 #2
0
        public static int GetNodeSize(bool own, bool tree, string id, string type, HashSet <string> traversedNodes,
                                      NodeDependencyLookupContext stateContext, Dictionary <string, int> ownSizeCache = null)
        {
            if (ownSizeCache == null)
            {
                ownSizeCache = new Dictionary <string, int>();
            }

            string key = GetNodeKey(id, type);

            if (traversedNodes.Contains(key) || !stateContext.NodeHandlerLookup.ContainsKey(type))
            {
                return(0);
            }

            traversedNodes.Add(key);

            int size = 0;

            INodeHandler nodeHandler = stateContext.NodeHandlerLookup[type];

            if (own && (!tree || nodeHandler.ContributesToTreeSize()))
            {
                if (!ownSizeCache.ContainsKey(key))
                {
                    ownSizeCache[key] = nodeHandler.GetOwnFileSize(id, type, stateContext);
                }

                size += ownSizeCache[key];
            }

            if (tree)
            {
                Node node = stateContext.RelationsLookup.GetNode(id, type);

                if (node != null)
                {
                    foreach (Connection connection in node.GetRelations(RelationType.DEPENDENCY))
                    {
                        if (stateContext.ConnectionTypeLookup.GetDependencyType(connection.Type).IsHard)
                        {
                            Node childNode = connection.Node;
                            size += GetNodeSize(true, true, childNode.Id, childNode.Type, traversedNodes, stateContext, ownSizeCache);
                        }
                    }
                }
            }

            return(size);
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        /// <summary>
        /// Right now this only works if the asset or one of its parents (referencers) are in a packaged scene or in a resources folder.
        /// If the asset is just in a bundle this is currently not tracked. Trying to find a solution for this.
        /// </summary>
        public static bool IsNodePackedToApp(string id, string type, NodeDependencyLookupContext stateContext,
                                             HashSet <string> visitedKeys)
        {
            if (visitedKeys.Contains(id))
            {
                return(false);
            }

            visitedKeys.Add(id);

            Node node = stateContext.RelationsLookup.GetNode(id, type);

            if (node == null)
            {
                return(false);
            }

            foreach (KeyValuePair <string, INodeHandler> pair in stateContext.NodeHandlerLookup)
            {
                INodeHandler nodeHandler = pair.Value;

                if (nodeHandler.GetHandledNodeTypes().Contains(type) && nodeHandler.IsNodePackedToApp(id, type))
                {
                    return(true);
                }
            }

            foreach (Connection connection in node.Referencers)
            {
                Node refNode = connection.Node;

                if (!stateContext.ConnectionTypeLookup.GetDependencyType(connection.Type).IsIndirect&&
                    IsNodePackedToApp(refNode.Id, refNode.Type, stateContext, visitedKeys))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #5
0
 public void InitContext(NodeDependencyLookupContext nodeDependencyLookupContext)
 {
     // nothing to do
 }
コード例 #6
0
 public int GetOwnFileSize(string id, string type, NodeDependencyLookupContext stateContext)
 {
     return(NodeDependencyLookupUtility.GetPackedAssetSize(id));
 }
コード例 #7
0
 public int GetOwnFileSize(string id, string type, NodeDependencyLookupContext stateContext)
 {
     return(0);
 }
コード例 #8
0
 public static void ClearCachedContexts()
 {
     NodeDependencyLookupContext.ResetContexts();
 }
コード例 #9
0
 /// <summary>
 /// Right now this only works if the asset or one of its parents (referencers) are in a packaged scene or in a resources folder.
 /// If the asset is just in a bundle this is currently not tracked. Trying to find a solution for this.
 /// </summary>
 public static bool IsNodePackedToApp(string id, string type, NodeDependencyLookupContext stateContext)
 {
     return(IsNodePackedToApp(id, type, stateContext, new HashSet <string>()));
 }