Пример #1
0
    public static AudioAssetData GetAudioAssetNow(int templateId)
    {
        if (AudioAssetPool.mAudioClipCache.ContainsKey(templateId))
        {
            return(AudioAssetPool.mAudioClipCache.get_Item(templateId));
        }
        Audio audio = DataReader <Audio> .Get(templateId);

        string path = AudioAssetPool.GetPath(audio, templateId);

        if (string.IsNullOrEmpty(path))
        {
            return(null);
        }
        if (!AudioAssetPool.mAudioClipPaths.Contains(path))
        {
            AudioAssetPool.mAudioClipPaths.Add(path);
        }
        AudioClip iClip = AssetManager.AssetOfNoPool.LoadAssetNow(path, typeof(Object)) as AudioClip;

        return(AudioAssetPool.PushToPool(templateId, iClip, audio.mode == 1, audio.volumeSize));
    }
Пример #2
0
    public static void LoadAudioAsset(int templateId, Action <bool> finish_callback)
    {
        if (AudioAssetPool.mAudioClipCache.ContainsKey(templateId) && AudioAssetPool.mAudioClipCache.get_Item(templateId) != null)
        {
            if (finish_callback != null)
            {
                finish_callback.Invoke(true);
            }
            return;
        }
        Audio dataAudio = DataReader <Audio> .Get(templateId);

        string path = AudioAssetPool.GetPath(dataAudio, templateId);

        if (string.IsNullOrEmpty(path))
        {
            if (finish_callback != null)
            {
                finish_callback.Invoke(false);
            }
            return;
        }
        AssetManager.AssetOfNoPool.LoadAsset(path, typeof(Object), delegate(Object obj)
        {
            if (!AudioAssetPool.mAudioClipPaths.Contains(path))
            {
                AudioAssetPool.mAudioClipPaths.Add(path);
            }
            AudioClip iClip = obj as AudioClip;
            AudioAssetPool.PushToPool(templateId, iClip, dataAudio.mode == 1, dataAudio.volumeSize);
            if (finish_callback != null)
            {
                finish_callback.Invoke(true);
            }
        });
    }