protected UnityEngine.Object GetObjectByAssetBundle(int assetType, string assetId, bool isAutoUnload = true) { string assetTypePath = AssetPathUtility.GetTypePath(assetType); assetTypePath = AssetBundleIdPrefix + assetTypePath; string assetBundleName = PathUtility.Combine(true, assetTypePath, assetId); assetBundleName = assetBundleName + ".assetbundle"; UnityEngine.Object obj = AssetBundleManager.LoadAssetSync(assetBundleName, assetId); AssetBundleManager.UnloadAssetBundle(assetBundleName); return(obj); }
public UnityEngine.Object LoadAsset(int assetType, string assetId, bool isCache = false, bool detiledLog = false) { if (detiledLog) { LoggerManager.Instance.Info("log reload " + assetType + ", " + assetId); } assetId = assetId.Trim(); var assetPath = AssetPathUtility.GetAssetPath(assetType, assetId); if (detiledLog) { LoggerManager.Instance.Info("log reload: " + assetPath); } UnityEngine.Object ob = null; bool matchDic = false; if (cacheDic.ContainsKey(assetPath)) { ob = cacheDic[assetPath]; if (detiledLog) { LoggerManager.Instance.Info("log reload: ob is null ? " + ((ob == null) ? "true" : "false")); } if (ob != null) { matchDic = true; return(ob); } else { cacheDic.Remove(assetPath); } } if (!matchDic) { if (assetType != AssetType.Shader) { ob = GetObjectByAssetBundle(assetType, assetId); } if (ob == null) { ob = Resources.Load(assetPath); if (detiledLog) { LoggerManager.Instance.Info(" after reload: ob is null ? " + ((ob == null || ob.IsNull()) ? "true" : "false")); } } if (ob != null) { if (isCache) { cacheDic[assetPath] = ob; } } } return(ob); }