IEnumerator SetResrouceTableAsync(AssetStep?step = null, AssetLanguage?language = null) { if (step.HasValue) { this.Step = step.Value; } if (language.HasValue) { this.Languate = language.Value; } string resourceTablePath = $"{ConstAssetBundle.ResrouceTablePathHead}{GetLanguagePart(this.Languate)}{GetStepPart(this.Step)}{ConstAssetBundle.ResrouceTablePathTail}"; bool forciblyDownload = #if UNITY_EDITOR !localMode; #else false; #endif IAssetEntry newAssetEntry = director.LoadTable(resourceTablePath, forciblyDownload); while (!newAssetEntry.IsTableLoaded) { yield return(null); } this.Resource = newAssetEntry; loadTableCoroutine = null; }
public AssetBundlePreloader Preload(IAssetEntry assetEntry) { if (assetEntry == null) { string message = "asset entry is null"; (this as IErrorReceiver).OnError(AssetBundleErrorCode.NullAssetEntry, message); return(null); } if (!assetEntry.IsTableLoaded) { string message = "wait for loading table"; (this as IErrorReceiver).OnError(AssetBundleErrorCode.NullAssetBundleTable, message); return(null); } return(Preload(assetEntry.Table.AssetBundleRecordMap.Values)); }
internal void AddEntry(IAssetEntry entry, string enumName) { var provider = CodeDomProvider.CreateProvider("C#"); bool IsValidIdentifier(string id) => provider.IsValidIdentifier(id); var addressableNameSlices = entry.Address.Split('/', '\\'); var itemGroupName = addressableNameSlices.First(); Assert.IsTrue(addressableNameSlices.Length < 3, ADDRESS_PARTS_MSG); if (addressableNameSlices.Length == 1) { Debug.LogWarning( $"Addressable item did not have a group name, this is attempting to be automatically corrected. Was {entry.Address} will have {enumName} prepended."); itemGroupName = enumName; } if (itemGroupName != enumName) { Debug.LogWarning( $"Addressable item groupname did not match, this is attempting to be automatically corrected. Was {itemGroupName} should be {enumName}."); itemGroupName = enumName; } var itemName = addressableNameSlices.Last(); if (!IsValidIdentifier(itemName)) { // remove spaces and dots var safeItemName = string.Join("_", itemName.Split(' ', '.')); Assert.IsTrue(IsValidIdentifier(safeItemName), $"Addressable {itemName} did not have a valid identifier for a name and could not be automatically correctled."); Debug.LogWarning( $"Addressable item name is not a valid indentifier. Was {itemName} will be {safeItemName}."); itemName = safeItemName; } entry.Address = $"{itemGroupName}/{itemName}"; AddEntry(itemGroupName, itemName); }
public void SetResrouceTable(AssetStep?step = null, AssetLanguage?language = null) { if (this.Resource?.IsTableLoaded == false) { Debug.LogError("wait for loading table"); return; } if (step.HasValue) { this.Step = step.Value; } if (language.HasValue) { this.Languate = language.Value; } string resourceTablePath = $"{Const.Asset.ResrouceTablePathHead}{GetLanguagePart(this.Languate)}{GetStepPart(this.Step)}{Const.Asset.ResrouceTablePathTail}"; this.Resource = director.LoadTable(resourceTablePath, true); }