Ejemplo n.º 1
0
        internal static List <AddressableAssetEntry> GatherModifiedEntries(AddressableAssetSettings settings, string cacheDataPath)
        {
            var cacheData = LoadContentState(cacheDataPath);

            if (cacheData == null)
            {
                return(null);
            }

            var allEntries = new List <AddressableAssetEntry>();

            settings.GetAllAssets(allEntries, g => g.HasSchema <BundledAssetGroupSchema>() && g.GetSchema <ContentUpdateGroupSchema>().StaticContent);

            var entryToCacheInfo = new Dictionary <string, CachedAssetState>();

            foreach (var cacheInfo in cacheData.cachedInfos)
            {
                if (cacheInfo != null)
                {
                    entryToCacheInfo[cacheInfo.asset.guid.ToString()] = cacheInfo;
                }
            }
            var modifiedEntries = new List <AddressableAssetEntry>();

            foreach (var entry in allEntries)
            {
                CachedAssetState cachedInfo;
                if (!entryToCacheInfo.TryGetValue(entry.guid, out cachedInfo) || HasAssetOrDependencyChanged(cachedInfo))
                {
                    modifiedEntries.Add(entry);
                }
            }
            return(modifiedEntries);
        }
Ejemplo n.º 2
0
    /// <summary>
    /// 获取所有资源
    /// </summary>
    /// <param name="includeSubObjects"></param>
    /// <returns></returns>
    public static List <AddressableAssetEntry> FindAllAsset(bool includeSubObjects = false)
    {
        AddressableAssetSettings     Settings = AddressableAssetSettingsDefaultObject.Settings;
        List <AddressableAssetEntry> listData = new List <AddressableAssetEntry>();

        Settings.GetAllAssets(listData, includeSubObjects);
        return(listData);
    }
Ejemplo n.º 3
0
    List <string> GetAllAddresses()
    {
        string guid = AssetDatabase.FindAssets("t:AddressableAssetSettings").FirstOrDefault();
        string path = AssetDatabase.GUIDToAssetPath(guid);
        AddressableAssetSettings     settings = AssetDatabase.LoadAssetAtPath <AddressableAssetSettings>(path);
        List <AddressableAssetEntry> entries  = new List <AddressableAssetEntry>();

        settings.GetAllAssets(entries, true);
        Regex regex = new Regex(@"(.*)\[.*\]");

        return(entries.Select(c => c.address).Select(c => regex.Replace(c, "$1")).GroupBy(c => c).Select(c => c.Key).ToList());
    }
 public static AssetReference FindReferenceByAddress(this AddressableAssetSettings settings,string address)
 {
     var entries = new List<AddressableAssetEntry>();
     settings.GetAllAssets(entries,true,null,x => x.address == address);
     var asset = entries.FirstOrDefault();
     
     if (asset == null) {
         Debug.LogWarning($"Not found asset with address :: {address}");
         return null;
     }
     return new AssetReference(asset.guid);
 }
Ejemplo n.º 5
0
        private static void SetLabelToAsset(List <string> assetGuidList, string label, bool flag)
        {
            AddressableAssetSettings assetSettings = GetSettings();

            //ラベルを追加するように呼んでおく。追加されていないと設定されない。
            assetSettings.AddLabel(label);
            List <AddressableAssetEntry> assetList = new List <AddressableAssetEntry>();

            assetSettings.GetAllAssets(assetList, true);
            foreach (AddressableAssetEntry asset in assetGuidList.Select(assetGuid =>
                                                                         assetList.Find((a) => a.guid == assetGuid)))
            {
                asset?.SetLabel(label, flag);
            }
        }
Ejemplo n.º 6
0
        public static void CheckAllAddress()
        {
            AddressableAssetSettings assetSettings = GetSettings();

            List <AddressableAssetEntry> entries = new List <AddressableAssetEntry>();

            assetSettings.GetAllAssets(entries, true);
            List <string> checkedAddress = new List <string>();

            foreach (var e in from e in entries
                     where !checkedAddress.Contains(e.address)
                     let ret = CheckAddress(entries, e.address)
                               where !ret
                               select e)
            {
                checkedAddress.Add(e.address);
            }
        }
Ejemplo n.º 7
0
        private static void AddAssetToGroup(string assetGuid, string groupName, string address = null)
        {
            AddressableAssetSettings settings   = GetSettings();
            AddressableAssetGroup    assetGroup = CreateGroup(groupName);
            AddressableAssetEntry    assetEntry = settings.CreateOrMoveEntry(assetGuid, assetGroup);

            if (address == null)
            {
                return;
            }

            List <AddressableAssetEntry> entries = new List <AddressableAssetEntry>();

            settings.GetAllAssets(entries, true);
            if (CheckAddress(entries, address))
            {
                assetEntry.SetAddress(address);
            }
            else
            {
                Debug.LogAssertion("Duplicate Address");
            }
        }
Ejemplo n.º 8
0
        internal static void GatherExplicitModifiedEntries(AddressableAssetSettings settings, ref Dictionary <AddressableAssetEntry, List <AddressableAssetEntry> > dependencyMap, AddressablesContentState cacheData)
        {
            List <string> noBundledAssetGroupSchema = new List <string>();
            List <string> noStaticContent           = new List <string>();

            var allEntries = new List <AddressableAssetEntry>();

            settings.GetAllAssets(allEntries, false, g =>
            {
                if (g == null)
                {
                    return(false);
                }

                if (!g.HasSchema <BundledAssetGroupSchema>())
                {
                    noBundledAssetGroupSchema.Add(g.Name);
                    return(false);
                }

                if (!g.HasSchema <ContentUpdateGroupSchema>())
                {
                    noStaticContent.Add(g.Name);
                    return(false);
                }

                if (!g.GetSchema <ContentUpdateGroupSchema>().StaticContent)
                {
                    noStaticContent.Add(g.Name);
                    return(false);
                }

                return(true);
            });

            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("Skipping Prepare for Content Update on {0} group(s):\n\n",
                                 noBundledAssetGroupSchema.Count + noStaticContent.Count);


            AddInvalidGroupsToLogMessage(builder, noBundledAssetGroupSchema, "Group Did Not Contain BundledAssetGroupSchema");
            AddInvalidGroupsToLogMessage(builder, noStaticContent, "Static Content Not Enabled In Schemas");

            Debug.Log(builder.ToString());

            var entryToCacheInfo = new Dictionary <string, CachedAssetState>();

            foreach (var cacheInfo in cacheData.cachedInfos)
            {
                if (cacheInfo != null)
                {
                    entryToCacheInfo[cacheInfo.asset.guid.ToString()] = cacheInfo;
                }
            }
            var modifiedEntries = new List <AddressableAssetEntry>();

            foreach (var entry in allEntries)
            {
                CachedAssetState cachedInfo;
                if (!entryToCacheInfo.TryGetValue(entry.guid, out cachedInfo) || HasAssetOrDependencyChanged(cachedInfo))
                {
                    modifiedEntries.Add(entry);
                }
            }

            AddAllDependentScenesFromModifiedEntries(modifiedEntries);
            foreach (var entry in modifiedEntries)
            {
                if (!dependencyMap.ContainsKey(entry))
                {
                    dependencyMap.Add(entry, new List <AddressableAssetEntry>());
                }
            }
        }