Exemple #1
0
 //播放
 public void Play(float currentTime)
 {
     m_fStartTime = currentTime;
     m_fEndTime   = currentTime;
     //
     if (_audioAsset != null)
     {
         AssetService.GetInstance().Unload(_audioAsset);
         _audioAsset = null;
     }
     //
     if (_isNetAudioAsset)
     {
         NetAssetInfo info = NetAssetService.GetInstance().GetCachedNetAssetInfoByUrl(m_kAudioResName);
         if (info != null)
         {
             string filePath = info.GetCachedFilePath();
             string url      = string.Format("file://{0}", filePath);
             _audioWWW = new WWW(url);
             //给1秒钟去加载
             m_fEndTime = m_fStartTime + 1.0f;
         }
     }
     else
     {
         _audioAsset = AssetService.GetInstance().LoadAudioAsset(m_kAudioResName);
         if (null != _audioAsset)
         {
             m_kClip = _audioAsset.Clip;
         }
         else
         {
             JW.Common.Log.LogE("Load Audio File Error:" + m_kAudioResName);
             m_kClip = null;
         }
     }
     //
     if (m_kClip != null)
     {
         if (m_kClip.length < 0.2f)
         {
             m_fEndTime = m_fStartTime + 0.2f;
         }
         else
         {
             m_fEndTime = m_fStartTime + m_kClip.length;
         }
         if (m_kSource != null)
         {
             m_kSource.clip = m_kClip;
             m_kSource.Play();
         }
     }
 }
Exemple #2
0
        private void LoadTexture(string url)
        {
            if (_httpImageState == UIHttpImageState.Loaded)
            {
                return;
            }

            if (IsCacheTexture)
            {
                Texture2D texture2D;
                if (CachedNetAssetWidth != 0 && CachedNetAssetHeight != 0)
                {
                    texture2D = NetAssetService.GetInstance().GetCachedNetImage(url, CachedTextureValidDays, CachedNetAssetWidth, CachedNetAssetHeight);
                }
                else
                {
                    texture2D = NetAssetService.GetInstance().GetCachedNetImage(url, CachedTextureValidDays);
                }
                //
                if (texture2D != null)
                {
                    if (_image != null)
                    {
                        _image.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), new Vector2(0.5f, 0.5f));

                        if (IsSetNativeSize)
                        {
                            SetNativeSize();
                        }

                        _httpImageState = UIHttpImageState.Loaded;

                        if (LoadingCover != null)
                        {
                            LoadingCover.SetActive(false);
                        }
                    }
                }
                else
                {
                    StartCoroutine(DownloadImage(url));
                }
            }
            else
            {
                StartCoroutine(DownloadImage(url));
            }
        }
Exemple #3
0
 /// <summary>
 /// 初始化框架层
 /// </summary>
 /// <param name="initialize">初始化/反初始化</param>
 public static void InitFramework(bool initialize)
 {
     if (initialize)
     {
         NativeService.GetInstance();
         IFSService.GetInstance();
         AssetService.GetInstance();
         ScheduleService.GetInstance();
         EventService.GetInstance();
         StateService.GetInstance();
         HttpService.GetInstance();
         UGUIRoot.GetInstance();
         UIStateService.GetInstance();
         SceneService.GetInstance();
         UICommonService.GetInstance();
         AudioService.GetInstance();
         QualityService.GetInstance();
         NetworkService.GetInstance();
         NetAssetService.GetInstance();
     }
     else
     {
         IFSService.DestroyInstance();
         EventService.DestroyInstance();
         StateService.DestroyInstance();
         HttpService.DestroyInstance();
         UIStateService.DestroyInstance();
         SceneService.DestroyInstance();
         UICommonService.DestroyInstance();
         UGUIRoot.DestroyInstance();
         AudioService.DestroyInstance();
         NetworkService.DestroyInstance();
         NativeService.DestroyInstance();
         NetAssetService.DestroyInstance();
         QualityService.DestroyInstance();
         //最后
         ScheduleService.DestroyInstance();
         AssetService.GetInstance().Destroy();
         AssetService.DestroyInstance();
     }
 }
Exemple #4
0
        private IEnumerator DownloadImage(string url)
        {
            _httpImageState = UIHttpImageState.Loading;

            float startTime = Time.realtimeSinceStartup;

            WWW www = new WWW(url);

            yield return(www);

            _httpImageState = UIHttpImageState.Loaded;

            if (LoadingCover != null)
            {
                LoadingCover.SetActive(false);
            }

            if (string.IsNullOrEmpty(www.error))
            {
                string contentType = null;
                www.responseHeaders.TryGetValue("CONTENT-TYPE", out contentType);

                if (contentType != null)
                {
                    contentType = contentType.ToLower();
                }

                if (string.IsNullOrEmpty(contentType) || !contentType.Contains("image/"))
                {
                    JW.Common.Log.LogE("UIHttpImage Download Image Content Error:" + ImageUrl);
                }
                else
                {
                    bool isGif = string.Equals(contentType, "image/gif");

                    Texture2D texture2D = null;

                    if (isGif)
                    {
                        JW.Common.Log.LogE("ToDO Support Gif");
                    }
                    else
                    {
                        texture2D = www.texture;
                    }

                    if (texture2D != null)
                    {
                        if (_image != null)
                        {
                            _image.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), new Vector2(0.5f, 0.5f));

                            if (IsSetNativeSize)
                            {
                                SetNativeSize();
                            }
                        }

                        if (IsCacheTexture)
                        {
                            NetAssetService.GetInstance().AddCachedNetImage(url, texture2D.width, texture2D.height, www.bytes);
                        }
                    }
                }
            }
            else
            {
                JW.Common.Log.LogE("UIHttpImage Download Image Error:" + ImageUrl);
            }
        }
 public static NetAssetService GetNetAssetService()
 {
     return(NetAssetService.GetInstance());
 }