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);
    }
Example #3
0
        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);
        }
Example #4
0
        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));
        }
Example #5
0
        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));
        }
Example #6
0
        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));
        }
Example #7
0
        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);
     }
 }
Example #9
0
 public int PlayFollowSound(ResourceLoadInfo resourceLoadInfo, Transform followPos)
 {
     return(soundManager.PlayFollowSound(resourceLoadInfo, followPos));
 }
Example #10
0
 public int PlayWorldSound(ResourceLoadInfo resourceLoadInfo, Vector3 worldPos)
 {
     return(soundManager.PlayWorldSound(resourceLoadInfo, worldPos));
 }
Example #11
0
 public int PlayUISound(ResourceLoadInfo resourceLoadInfo)
 {
     return(soundManager.PlayUISound(resourceLoadInfo));
 }
Example #12
0
 public int PlayMusic(ResourceLoadInfo resourceLoadInfo)
 {
     return(soundManager.PlayMusic(resourceLoadInfo));
 }
Example #13
0
 public int PlaySound(ResourceLoadInfo resourceLoadInfo, PlaySoundParams playSoundParams)
 {
     return(soundManager.PlaySound(resourceLoadInfo, playSoundParams));
 }
Example #14
0
 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));
 }
Example #16
0
 public void LoadDataTable(ResourceLoadInfo resourceLoadInfo, LoadDataTableInfo loadDataTableInfo)
 {
     resourceManager.RequestResource(resourceLoadInfo.AssetBundleName, LoadDataCallback,
                                     resourceLoadInfo.ResourceLoadMode, resourceLoadInfo.ResourceLoadCache,
                                     resourceLoadInfo.ResourceLoadMethod, loadDataTableInfo);
 }