Пример #1
0
    public bool _RequestDownload(TsAudio.RequestData requestData, PostProcPerItem onEvent)
    {
        if (string.IsNullOrEmpty(this.m_assetBundleName))
        {
            return(false);
        }
        if (onEvent == null)
        {
            return(false);
        }
        if (TsAudio.IsDisableDownloadAudio(requestData.baseData.AudioType))
        {
            return(true);
        }
        if (TsAudio.IsDisableDownloadByTag(requestData.baseData.Tag))
        {
            return(true);
        }
        bool   unloadAfterPostProcess = false;
        string stackName;

        if (requestData.baseData.IsDontDestroyOnLoad)
        {
            stackName = Option.IndependentFromStageStackName;
            unloadAfterPostProcess = true;
        }
        else
        {
            stackName = TsAudio.AssetBundleStackName;
            if (requestData.baseData.AudioType == EAudioType.BGM || requestData.baseData.AudioType == EAudioType.AMBIENT || requestData.baseData.AudioType == EAudioType.ENVIRONMENT)
            {
                unloadAfterPostProcess = true;
            }
        }
        if (!this.m_bMuteAudio)
        {
            string text = string.Empty;
            if (requestData.baseData.AudioType == EAudioType.BGM_STREAM)
            {
                text = this.m_assetPathOfAudioClip.Replace("Assets/", string.Empty);
                text = text.Replace("wav", "mp3");
            }
            else
            {
                text = string.Format("{0}_mobile{1}", this.DownloadPath.Replace(TsAudioBundleInfo.Ext, string.Empty), TsAudioBundleInfo.Ext);
            }
            WWWItem wWWItem = Holder.TryGetOrCreateBundle(text, stackName);
            if (requestData.baseData.AudioType == EAudioType.BGM_STREAM)
            {
                wWWItem.SetItemType(ItemType.USER_AUDIO);
            }
            else
            {
                wWWItem.SetItemType(ItemType.AUDIO);
            }
            wWWItem.SetCallback(onEvent, requestData);
            wWWItem.SetLoadAll(true);
            TsImmortal.bundleService.RequestDownloadCoroutine(wWWItem, DownGroup.RUNTIME, unloadAfterPostProcess);
            this.IsRequestDownloaded = true;
        }
        return(true);
    }