public R GetAsset(string assetName, string groupName = "") { IMappingAsset <R> mappingAsset; //find assetbundle name string abName = m_AssetBundleMappingAsset.GetAassetBundleName(assetName); if (string.IsNullOrEmpty(abName)) { #if UNITY_EDITOR Debug.LogWarningFormat("{1} doesn't contains asset {0}.", assetName, typeof(IMappingAsset <R>)); #endif return(null); } int refCount = AddRefer(abName); if (!string.IsNullOrEmpty(groupName)) { AddGroup(groupName, abName); } if (m_MappingAssetCache.TryGetValue(abName, out mappingAsset)) { return(mappingAsset.GetAsset(assetName)); } else { mappingAsset = ResourcesLoader.LoadAsset <IMappingAsset <R> >(abName, Utils.CUtils.GetAssetName(abName)); m_MappingAssetCache.Add(abName, mappingAsset); return(mappingAsset.GetAsset(assetName)); } }
/// <summary> /// Load the specified localization dictionary. /// </summary> static bool LoadDictionary(string value) { if (value.Equals(SystemLanguage.ChineseSimplified.ToString())) { value = SystemLanguage.Chinese.ToString(); } string assetName = Common.LANGUAGE_PREFIX + value.ToLower(); string abName = CUtils.GetRightFileName(assetName + Common.CHECK_ASSETBUNDLE_SUFFIX); var main = ResourcesLoader.LoadAsset <BytesAsset>(abName, assetName); if (main != null) { byte[] txt = main.bytes; #if UNITY_EDITOR Debug.Log(mLanguage + " is loaded " + txt.Length + " " + Time.frameCount); #endif if (txt != null) { Load(txt); } CacheManager.Subtract(abName); localizationHasBeenSet = true; } else { if (!value.ToLower().Equals(SystemLanguage.English.ToString().ToLower())) { language = SystemLanguage.English.ToString(); } } return(false); }
public object Convert(object target, Type targetType) { string rawImageUrl = target.ToString(); Texture tex = ResourcesLoader.LoadAsset <Texture> (rawImageUrl.ToLower() + Common.CHECK_ASSETBUNDLE_SUFFIX, rawImageUrl); return(tex); }
public AssetBundleMappingManager() { string mappingAssetName = GetMappingAssetName(); m_AssetBundleMappingAsset = ResourcesLoader.LoadAsset <AssetBundleMappingAsset>(mappingAssetName + Common.CHECK_ASSETBUNDLE_SUFFIX, mappingAssetName); m_MappingAssetCache = new Dictionary <string, IMappingAsset <R> >(); m_AssetRefer = new Dictionary <string, int>(); m_ABCacheSubCount = new Dictionary <string, int>(); m_ABGroups = new Dictionary <string, Dictionary <string, int> >(); }
/// <summary> /// 同步加载动更资源 /// </summary> /// <returns>资源内容</returns> /// <param name="fileName">文件名称</param> /// <typeparam name="T">资源类型</typeparam> public T LoadAsset <T> (string fileName) where T : UnityEngine.Object { T rtn = m_assetLoader.LoadAsset <T>(fileName); if (null != rtn) { return(rtn); } return(m_resourceLoader.LoadAsset <T>(fileName)); }
//开始加载场景 public static void BeginLoadScene() { ResourcesLoader.OnAssetBundleComplete = OnSharedComplete; CUtils.DebugCastTime("LoadingFirst.BeginLoadScene"); var req = CRequest.Get(); req.relativeUrl = CUtils.GetRightFileName(sceneAssetBundleName); req.assetName = sceneName; req.OnComplete = OnSceneAbLoaded; req.OnEnd = OnSceneAbError; req.assetType = CacheManager.Typeof_ABScene; CacheManager.Unload(req.keyHashCode); ResourcesLoader.LoadAsset(req); }
/// <summary> /// Load the specified localization dictionary. /// </summary> static bool LoadDictionary(string value) { if (value.Equals(SystemLanguage.ChineseSimplified.ToString())) { value = SystemLanguage.Chinese.ToString(); } string assetName = Common.LANGUAGE_PREFIX + value.ToLower(); string abName = CUtils.GetRightFileName(assetName + Common.CHECK_ASSETBUNDLE_SUFFIX); CRequest req = CRequest.Get(); req.relativeUrl = abName; req.assetName = assetName; req.assetType = typeof(BytesAsset); req.async = false; var uri = new UriGroup(); uri.Add(CUtils.GetRealPersistentDataPath(), true); uri.Add(CUtils.GetRealStreamingAssetsPath()); req.uris = uri; req.OnComplete += delegate(CRequest req1) { BytesAsset main = req1.data as BytesAsset; //www.assetBundle.mainAsset as TextAsset; byte[] txt = main.bytes; #if UNITY_EDITOR Debug.Log(mLanguage + " is loaded " + txt.Length + " " + Time.frameCount); #endif if (txt != null) { Load(txt); } SelectLanguage(mLanguage); CacheManager.Unload(req1.keyHashCode); localizationHasBeenSet = true; }; req.OnEnd += delegate(CRequest req1) { if (!value.ToLower().Equals(SystemLanguage.English.ToString().ToLower())) { language = SystemLanguage.English.ToString(); } }; ResourcesLoader.LoadAsset(req); return(false); }
//开始加载场景 internal static void BeginLoadScene(string beginLua) { ManifestManager.LoadUpdateFileManifest(null); PLua.DestoryLua(); PLua.enterLua = beginLua; CUtils.DebugCastTime("LoadingFirst"); var req = CRequest.Get(); req.relativeUrl = CUtils.GetRightFileName(sceneAssetBundleName); req.assetName = sceneName; req.OnComplete = OnSceneAbLoaded; req.OnEnd = OnSceneAbError; req.assetType = CacheManager.Typeof_ABScene; req.async = true; ResourcesLoader.LoadAsset(req); ResourcesLoader.OnAssetBundleComplete = OnSharedComplete; }
public override bool Load(Priority priority, out bool process) { process = this.process; if (loadStatus == LoadStatus.UNLOAD) { process = this.process; Action <UnityEngine.Object> onLoadCallBack = (abObject) => { this.loadStatus = LoadStatus.LOADEND; this.process = true; onLoadFinishCallBack.Invoke(abObject); }; switch (GameSetting.Instance.runType) { case RunType.PATCHER_SA_PS: AssetBundleLoader.LoadAsset(name, assetType, onLoadCallBack); break; case RunType.NOPATCHER_SA: AssetBundleLoader.LoadAsset(name, assetType, onLoadCallBack); break; case RunType.NOPATCHER_RES: ResourcesLoader.LoadAsset(name, assetType, onLoadCallBack); break; } loadStatus = LoadStatus.LOADING; } else if (loadStatus == LoadStatus.LOADING) { process = this.process; } else if (loadStatus == LoadStatus.LOADEND) { process = this.process; } return(true); }
public T LoadAsset <T>(string assetName) where T : Object { return(mLoader.LoadAsset <T>(assetName)); }