protected IEnumerator loadResourceCoroutine <T>(ResourceLoadInfo info) where T : Object { #if UNITY_EDITOR LIST(out List <string> fileNameList); ResourceManager.adjustResourceName <T>(info.mResouceName, fileNameList, false); int fileCount = fileNameList.Count; for (int i = 0; i < fileCount; ++i) { string filePath = FrameDefine.P_GAME_RESOURCES_PATH + fileNameList[i]; if (isFileExist(filePath)) { info.mObject = AssetDatabase.LoadAssetAtPath <T>(filePath); info.mSubObjects = AssetDatabase.LoadAllAssetsAtPath(filePath); break; } } UN_LIST(fileNameList); yield return(null); #else ResourceRequest request = Resources.LoadAsync <T>(info.mResouceName); yield return(request); info.mObject = request.asset; #endif info.mState = LOAD_STATE.LOADED; if (info.mObject != null) { mLoadedObjects.Add(info.mObject, info); } info.callbackAll(info.mObject, info.mSubObjects, null); }
// 卸载指定路径中的所有资源 public void unloadPath(string path) { LIST(out List <string> tempList); tempList.AddRange(mLoadedPath.Keys); int count = tempList.Count; for (int i = 0; i < count; ++i) { string item0 = tempList[i]; if (!startWith(item0, path)) { continue; } #if UNITY_EDITOR || DEVELOPMENT_BUILD log("unload path: " + item0); #endif var list = mLoadedPath[item0]; foreach (var item in list) { ResourceLoadInfo info = item.Value; if (info.mObject != null) { mLoadedObjects.Remove(info.mObject); if (!(info.mObject is GameObject)) { Resources.UnloadAsset(info.mObject); } info.mObject = null; } UN_CLASS(info); } mLoadedPath.Remove(item0); } UN_LIST(tempList); }
public int PlaySound(ResourceLoadInfo resourceLoadInfo, PlaySoundParams playSoundParams) { if (playSoundParams == null) { return(-1); } int serialId = Serial++; SoundGroup soundGroup = (SoundGroup)GetSoundGroup(playSoundParams.SoundGroupName); if (soundGroup == null) { Debuger.LogError(Utility.StringUtility.Format("Sound group '{0}' is not exist.", playSoundParams.SoundGroupName)); return(-1); } if (soundGroup.SoundCount <= 0) { Debuger.LogError(Utility.StringUtility.Format("Sound group '{0}' is have no sound agent.", playSoundParams.SoundGroupName)); return(-1); } playSoundParams.SerialId = serialId; soundBeingLoaded.Add(serialId); // resourceManager.LoadAsset<AudioClip>(resourceLoadInfo,loadCallback,playSoundParams);// todo txy resourceManager.RequestResource(resourceLoadInfo.AssetBundleName, LoadSoundCallback, resourceLoadInfo.ResourceLoadMode, resourceLoadInfo.ResourceLoadCache, resourceLoadInfo.ResourceLoadMethod, playSoundParams); return(serialId); }
public int PlayUISound(ResourceLoadInfo resourceLoadInfo) { PlaySoundParams playSoundParams = new PlaySoundParams { Priority = 0, Loop = false, VolumeInSoundGroup = 1f, FadeInSeconds = DefaultSoundDuration, SpatialBlend = 0f, SoundGroupName = "UISound", }; return(PlaySound(resourceLoadInfo, playSoundParams)); }
public int PlayFollowSound(ResourceLoadInfo resourceLoadInfo, Transform followPos) { PlaySoundParams playSoundParams = new PlaySoundParams { Priority = 0, Loop = false, VolumeInSoundGroup = 1f, FadeInSeconds = DefaultSoundDuration, SpatialBlend = 1f, FollowTransform = followPos, SoundGroupName = "Sound", }; return(PlaySound(resourceLoadInfo, playSoundParams)); }
public int PlayWorldSound(ResourceLoadInfo resourceLoadInfo, Vector3 worldPos) { PlaySoundParams playSoundParams = new PlaySoundParams { Priority = 0, Loop = false, VolumeInSoundGroup = 1f, FadeInSeconds = DefaultSoundDuration, SpatialBlend = 1f, WorldVector3 = worldPos, SoundGroupName = "Sound", }; return(PlaySound(resourceLoadInfo, playSoundParams)); }
public int PlayMusic(ResourceLoadInfo resourceLoadInfo) { StopMusic(); PlaySoundParams playSoundParams = new PlaySoundParams { Priority = 64, Loop = true, VolumeInSoundGroup = 1f, FadeInSeconds = DefaultSoundDuration, SpatialBlend = 0f, SoundGroupName = "Music" }; musicSerialId = PlaySound(resourceLoadInfo, playSoundParams); return(musicSerialId); }
/// <summary> /// 增加指定资源加载次数 /// </summary> /// <param name="abname"></param> public void addResourceLoadedTime(string abname) { if (ResourceLoadAnalyseMap.ContainsKey(abname)) { ResourceLoadAnalyseMap[abname].ResourceLoadTimeCount = ResourceLoadAnalyseMap[abname].ResourceLoadTimeCount + 1; } else { var abloadinfo = new ResourceLoadInfo(); abloadinfo.ABName = abname; abloadinfo.ResourceLoadTimeCount = 1; abloadinfo.ResourceUnloadTimeCount = 0; var now = DateTime.Now; abloadinfo.ResourceFirstLoadTime = string.Format("{0}-{1}-{2}", now.Hour, now.Minute, now.Second); ResourceLoadAnalyseMap.Add(abname, abloadinfo); } }
public int PlayFollowSound(ResourceLoadInfo resourceLoadInfo, Transform followPos) { return(soundManager.PlayFollowSound(resourceLoadInfo, followPos)); }
public int PlayWorldSound(ResourceLoadInfo resourceLoadInfo, Vector3 worldPos) { return(soundManager.PlayWorldSound(resourceLoadInfo, worldPos)); }
public int PlayUISound(ResourceLoadInfo resourceLoadInfo) { return(soundManager.PlayUISound(resourceLoadInfo)); }
public int PlayMusic(ResourceLoadInfo resourceLoadInfo) { return(soundManager.PlayMusic(resourceLoadInfo)); }
public int PlaySound(ResourceLoadInfo resourceLoadInfo, PlaySoundParams playSoundParams) { return(soundManager.PlaySound(resourceLoadInfo, playSoundParams)); }
public void LoadDataTable(ResourceLoadInfo resourceLoadInfo, LoadDataTableInfo loadDataTableInfo) { dataTableManager.LoadDataTable(resourceLoadInfo, loadDataTableInfo); }
/// <summary> /// 按卸载次数从高到低排序 /// </summary> /// <param name="a"></param> /// <param name="b"></param> private int sortUnloadTime(ResourceLoadInfo a, ResourceLoadInfo b) { return(b.ResourceUnloadTimeCount.CompareTo(a.ResourceUnloadTimeCount)); }
public void LoadDataTable(ResourceLoadInfo resourceLoadInfo, LoadDataTableInfo loadDataTableInfo) { resourceManager.RequestResource(resourceLoadInfo.AssetBundleName, LoadDataCallback, resourceLoadInfo.ResourceLoadMode, resourceLoadInfo.ResourceLoadCache, resourceLoadInfo.ResourceLoadMethod, loadDataTableInfo); }