Beispiel #1
0
    // 加载声音
    public static IEnumerator LoadSound(string soundPath, LoadSoundFinish delFinish, object param1 = null, object param2 = null, object param3 = null)
    {
        // 表里路径包含了Sounds文件夹名称
        string loadPath = GetBundleLoadUrl("", soundPath + ".data");
        WWW    www      = new WWW(loadPath);

        yield return(www);

        ProcessLoadSound(www, loadPath, soundPath, delFinish, param1, param2, param3);
    }
Beispiel #2
0
 public static void PrepareSoundResource(string soundFullName,
                                         LoadSoundFinish delFinish,
                                         object param1,
                                         object param2,
                                         object param3)
 {
     PrepareResource <AudioClip>(soundFullName, clip =>
     {
         if (null != delFinish)
         {
             delFinish(soundFullName, clip, param1, param2, param3);
         }
     }, true, false);
 }
Beispiel #3
0
    // 加载声音
    public static IEnumerator LoadSound(string soundPath, LoadSoundFinish delFinish, object param1 = null, object param2 = null, object param3 = null)
    {
        // 表里路径包含了Sounds文件夹名称
        string loadPath = GetBundleLoadUrl("", soundPath + ".data");

#if UNITY_WP8
        AudioClip retObj = null;

        while (m_bobDownloadingWWWs.Contains(loadPath))
        {
            yield return(null);
        }
        if (m_SoundBundleList.ContainsKey(loadPath))
        {
            retObj = m_SoundBundleList[loadPath].mainAsset as AudioClip;
        }
        else
        {
            WWW www = new WWW(loadPath);
            m_bobDownloadingWWWs.Add(loadPath);
            yield return(www);

            m_bobDownloadingWWWs.Remove(loadPath);
            if (null != www.assetBundle)
            {
                retObj = www.assetBundle.mainAsset as AudioClip;
                m_SoundBundleList.Add(loadPath, www.assetBundle);
            }
            else
            {
                LogModule.ErrorLog("load single assetbundle none :" + soundPath);
            }
        }
        if (null != delFinish)
        {
            delFinish(soundPath, retObj, param1, param2, param3);
        }
#else
        WWW www = new WWW(loadPath);
        yield return(www);

        ProcessLoadSound(www, loadPath, soundPath, delFinish, param1, param2, param3);
#endif
    }
Beispiel #4
0
    // 加载声音,不缓存
    private static void ProcessLoadSound(WWW www, string bundlePath, string bundleName, LoadSoundFinish delFinish, object param1, object param2, object param3)
    {
        AudioClip retObj = null;

        if (null != www.assetBundle)
        {
            retObj = www.assetBundle.mainAsset as AudioClip;
            CacheBundle(www);
        }
        else
        {
            LogModule.ErrorLog("load single assetbundle none :" + bundleName);
        }

        if (null != delFinish)
        {
            delFinish(bundleName, retObj, param1, param2, param3);
        }
    }