Example #1
0
    //-------------------------------------------------------------------------------------------------------------------------------------
    protected IEnumerator loadAssetsFromUrl(string url, Type assetsType, AssetLoadDoneCallback callback, object userData)
    {
        WWW www = new WWW(url);

        yield return(www);

        if (www.error != null)
        {
            // 下载失败
            UnityUtility.logInfo("下载失败 : " + url, LOG_LEVEL.LL_FORCE);
            callback(null, userData);
        }
        else
        {
            UnityEngine.Object obj = null;
            if (assetsType == typeof(AudioClip))
            {
#if UNITY_5_3_5
                obj = www.audioClip;
#else
                obj = WWWAudioExtensions.GetAudioClip(www);
#endif
            }
            else if (assetsType == typeof(Texture2D) || assetsType == typeof(Texture))
            {
                obj = www.texture;
            }
            else if (assetsType == typeof(MovieTexture))
            {
#if UNITY_5_3_5
                obj = www.movie;
#else
                obj = WWWAudioExtensions.GetMovieTexture(www);
#endif
            }
            else if (assetsType == typeof(AssetBundle))
            {
                obj = www.assetBundle;
            }
            obj.name = url;
            callback(obj, userData);
        }
        www.Dispose();
        www = null;
    }
Example #2
0
    IEnumerator DownloadMovie()
    {
        WWW www = new WWW("file://D://ScreenDisplay//123.ogv");

        movieTexture = WWWAudioExtensions.GetMovieTexture(www);

        while (!movieTexture.isReadyToPlay)
        {
            yield return(www);
        }

        image.texture    = movieTexture;           //视频纹理
        audioPlayer.clip = movieTexture.audioClip; //音频

        yield return(new WaitForSeconds(1));

        Play();
    }