Example #1
0
        static bool HasAssetOrDependencyChanged(CachedAssetState cachedInfo)
        {
            CachedAssetState newCachedInfo;

            if (!GetCachedAssetStateForData(cachedInfo.asset.guid, cachedInfo.bundleFileId, cachedInfo.groupGuid, cachedInfo.data, cachedInfo.dependencies.Select(x => x.guid), out newCachedInfo))
            {
                return(true);
            }
            return(!cachedInfo.Equals(newCachedInfo));
        }
Example #2
0
        static bool GetCachedAssetStateForData(GUID asset, string bundleFileId, string groupGuid, object data, IEnumerable <GUID> dependencies, out CachedAssetState cachedAssetState)
        {
            cachedAssetState = null;

            AssetState assetState;

            if (!GetAssetState(asset, out assetState))
            {
                return(false);
            }

            var visited = new HashSet <GUID>();

            visited.Add(asset);
            var dependencyStates = new List <AssetState>();

            foreach (var dependency in dependencies)
            {
                if (!visited.Add(dependency))
                {
                    continue;
                }

                AssetState dependencyState;
                if (!GetAssetState(dependency, out dependencyState))
                {
                    continue;
                }
                dependencyStates.Add(dependencyState);
            }

            cachedAssetState              = new CachedAssetState();
            cachedAssetState.asset        = assetState;
            cachedAssetState.dependencies = dependencyStates.ToArray();
            cachedAssetState.groupGuid    = groupGuid;
            cachedAssetState.bundleFileId = bundleFileId;
            cachedAssetState.data         = data;

            return(true);
        }