/// <summary> /// 通过预存的资源路径判断是否存在,丢失资源的情况无法判断 /// </summary> /// <param name="assetPath">资源路径</param> /// <returns></returns> public bool CheckAssetExist(string assetPath) { if (!IsRuntime()) { return(File.Exists(AssetBundlePath.GetFullPath(assetPath))); } return(AssetBundleManager.Instance.CheckAssetExist(assetPath)); }
/// <summary> /// 编辑器下加载Asset /// </summary> /// <typeparam name="T"></typeparam> /// <param name="assetName"></param> /// <returns></returns> private T EditorLoadAsset <T>(string assetName) where T : Object { #if UNITY_EDITOR string path = AssetBundlePath.PackagePathToAssetsPath(assetName); T asset = UnityEditor.AssetDatabase.LoadAssetAtPath <T>(path.ToLower()); return(asset); #else return(null); #endif }
public void Start() { string path = AssetBundlePath.PackagePathToAssetsPath(this.assetName); #if UNITY_EDITOR //这里一开始就把资源请求到,先缓存下来,单当模拟延时结束才赋给“asset” this.targetAsset = AssetDatabase.LoadAssetAtPath(path.ToLower(), assetType); #endif if (targetAsset == null) { AssetBundleManager.Instance.AddToLoadFaildCatch(path); Debug.LogError(string.Format("EditorAssetAsynRequester Error : No Asset At Path{0}!", path)); isOver = true; return; } this.totalWaitTime = this.GetRandomWaitTime(); this.remainWaitTime = this.totalWaitTime; }
public void Start() { int bundleIndex = AssetBundleManager.Instance.CurBundleManifest.GetAssetBundleIndex(bundleName); AssetBundle curAssetBundle = AssetBundleManager.Instance.GetAssetBundleCache(bundleIndex); if (curAssetBundle == null) { Debug.LogError("AssetBundle:" + bundleName + "is Null!!!"); isOver = true; return; } var assetPath = AssetBundlePath.PackagePathToAssetsPath(assetName); request = curAssetBundle.LoadAssetAsync(assetPath); if (request == null) { Debug.LogError("New LoadAssetAsync failed !!!"); isOver = true; } }
public AssetsPathMapping() { AssetName = AssetBundlePath.PackagePathToAssetsPath(AssetBundleConfig.AssetsPathMapFileName); AssetbundleName = AssetBundlePath.AssetBundlePathToAssetBundleName(AssetName); }