public List <AssetUnit> mDirectUpperDependences; //直接上层依赖,用于判定assetbundle加载后是否可以马上删除 #endregion #region 构造方法 public AssetUnit(string path) { mPath = path; mName = BuildCommon.getFileName(mPath, true); //获取文件名带后缀 mSuffix = BuildCommon.getFileSuffix(mName); //获取文件的后缀名 switch (mSuffix) { case "shader": mType = EnumAssetType.eAssetType_AssetBundleShader; break; case "prefab": mType = EnumAssetType.eAssetType_AssetBundlePrefab; break; case "tex": break; } mLevel = BuildCommon.getAssetLevel(mPath); mAllDependencies = new List <string>(); mNextLevelDependencies = new List <AssetUnit>(); //获取这个资源的所有引用 string[] deps = AssetDatabase.GetDependencies(new string[] { mPath }); //循环遍历所有引用,加入到allDependencies foreach (var file in deps) { string suffix = BuildCommon.getFileSuffix(file); if (file == mPath || suffix == "cs" || suffix == "dll") { continue; } mAllDependencies.Add(file); } mDirectUpperDependences = new List <AssetUnit>(); }
public static GameObject LoadPrefab(string path, EnumAssetType assetType, System.Action <Object> callBack) { GameObject obj = LoadAsset(path, typeof(GameObject), ".prefab", assetType, callBack) as GameObject; if (obj == null) { Debug.LogError("load prefab is null --path: " + path); } return(obj); }
/// <summary> /// 创建资源 /// </summary> /// <param name="name"></param> /// <param name="path"></param> /// <param name="size"></param> /// <param name="eResourceType"></param> /// <returns>资源对象实例</returns> public static ResourceData Create(string name, string path, int size, EnumAssetType eResourceType) { return(new ResourceData { mResourceName = name, mPath = path, mSize = size, mType = eResourceType, mRefCount = 1, mHasCheckRef = false }); }
public static string GetPath(EnumAssetType type) { string path = AssetConfig.ResRoot; switch (type) { case EnumAssetType.Default: return(path); case EnumAssetType.UIPrefab: return(path + "UGUI/Prefab/"); } return(string.Empty); }
private static Object LoadAsset(string path, System.Type type, string ext, EnumAssetType assetType = EnumAssetType.Default, System.Action <Object> callBack = null) { string tempPath = ResPathTool.GetPath(assetType); if (string.IsNullOrEmpty(tempPath))//完整路径 { tempPath = path; } else { tempPath += path; } Object obj = ResourceVessel.LoadAsset(tempPath, type, ext, callBack); return(obj); }
public static GameObject LoadPrefab(string path, EnumAssetType assetType, LuaInterface.LuaFunction callBack) { GameObject obj = LoadAsset(path, typeof(GameObject), ".prefab", assetType, callBack) as GameObject; if (obj == null) { Debug.LogError("load prefab is null --path: " + path); } else { GameObject go = GameObject.Instantiate(obj); go.name = path; return(go); } return(obj); }
/// <summary> /// 创建资源数据,如果已经存在就直接从中取得 /// </summary> /// <param name="name"></param> /// <param name="path"></param> /// <param name="size"></param> /// <param name="eAssetType"></param> /// <returns>资源</returns> public static ResourceData RefResource(string name, string path, int size, EnumAssetType eAssetType) { ResourceData resourceData = null; if (!CollectDepResourceDataMap.s_dicAllResourceData.TryGetValue(name, out resourceData)) { resourceData = ResourceData.Create(name, path, size, eAssetType); resourceData.mHasCheckRef = true; CollectDepResourceDataMap.s_dicAllResourceData[name] = resourceData; } else { if (!resourceData.mHasCheckRef) { resourceData.mHasCheckRef = true; resourceData.mRefCount++; } } return(resourceData); }
public IAssetRequest CreateAssetRequest(string strCompleteUrl, AssetRequestFinishedEventHandler callBackFun, AssetPRI assetPRIType, EnumAssetType eAssetType) { if (this.m_resourceManager == null) { AssetLogger.Error("null == m_resourceManager"); return(null); } IAssetRequest result = null; try { result = this.m_resourceManager.CreateAssetRequest(strCompleteUrl, callBackFun, assetPRIType, eAssetType); } catch (Exception ex) { AssetLogger.Fatal(ex.ToString()); } return(result); }
public IAssetRequest CreateAssetRequest(string assetUrl, List <string> dependes, AssetRequestFinishedEventHandler callBackFun, AssetPRI assetPRIType, EnumAssetType eAssetType) { if (string.IsNullOrEmpty(assetUrl)) { Debug.LogError("string.IsNullOrEmpty(assetUrl) == true"); return(null); } assetUrl = string.Format("{0}/{1}", this.m_strBaseResDir, assetUrl); assetUrl = GameResourceManager.StandardlizePath(assetUrl); GameAssetResource assetResource = this.GetAssetResource(assetUrl, assetPRIType, true); return(new GameAssetRequest(assetResource, callBackFun)); }
public IAssetRequest CreateAssetRequest(string url, AssetRequestFinishedEventHandler callBackFun, AssetPRI assetPRIType, EnumAssetType eAssetType) { return(this.CreateAssetRequest(url, null, callBackFun, assetPRIType, eAssetType)); }
public IAssetRequest CreateAssetRequest(string path, AssetRequestFinishedEventHandler callback, AssetPRI assetPRI, EnumAssetType assetType) { if (string.IsNullOrEmpty(path)) { AssetLogger.Error("string.IsNullOrEmpty(path) == true"); return(null); } string arg = Path.GetDirectoryName(path).ToLower(); string text = LocalResourceManager.ChangePathToFilenameWithoutExtension(path); path = string.Format("data/{0}/{1}.ab", arg, text); ResourceData resourceData = CollectDepResourceDataMap.RefResource(text, path, 0, assetType); return(this.CreateAssetRequest(resourceData, null, callback, assetPRI)); }
public static Sprite LoadSprite(string path, EnumAssetType assetType, System.Action <Object> callBack) { Sprite sp = LoadAsset(path, typeof(Sprite), ".png", assetType, callBack) as Sprite; return(sp); }