Esempio n. 1
0
    private static void RLoadPlayAudioOneShot(string soundName, AudioSource audioSource, float volume = 1f, float gvolume = 1f)
    {
        AudioClip resource;

        ResourceMgr.Load(soundName, _object =>
        {
            resource = _object as AudioClip;
            if (resource != null)
            {
                if (!CachePool.ContainsKey(soundName))
                {
                    CachePool.Add(soundName, resource);
                }

                if (audioSource != null)
                {
                    PlayAudioOneShot(audioSource, resource, volume, gvolume);
                }
            }
            else
            {
                Debug.LogError(string.Format("The AudioClip[resource={0}] is null.", resource));
            }
        });
    }
Esempio n. 2
0
        public override void Set(CacheItem item, string key, object data, int second = 0)
        {
            if (data == null)
            {
                return;
            }
            var cacheKey = GenerateCacheKey(item, key);

            if (CachePool.Contains(cacheKey))
            {
                CachePool[cacheKey] = data;
            }
            else
            {
                CachePool.Add(cacheKey, data, GetPolicy(second));
            }
        }
Esempio n. 3
0
    private static void RLoadPlayAudio(string soundName, AudioSource audioSource, float volume, bool loop, Action playCallBack)
    {
        AudioClip resource;

        ResourceMgr.Load(soundName, _object =>
        {
            resource = _object as AudioClip;
            if (resource)
            {
                if (!CachePool.ContainsKey(soundName))
                {
                    CachePool.Add(soundName, resource);
                }

                DoPlayAudio(audioSource, resource, volume, loop, playCallBack);
            }
            else
            {
                Debug.LogError("加载声音失败:" + soundName);
            }
        });
    }
Esempio n. 4
0
 private void OnCurrentIndexChanged()
 {
     if (-1 == CurrentIndex)
     {
         pic.Image       = null;
         lblName.Text    = null;
         lblPage.Text    = @"0 / 0";
         btnPrev.Enabled = btnNext.Enabled = false;
     }
     else
     {
         string filePath = _photoFiles[CurrentIndex];
         Image  img      = _photoCaches[filePath]; // 尝试从缓存池中获取图片
         if (null == img)                          // 缓存池中没有
         {
             img = FileTool.ReadImageFile(filePath);
             _photoCaches.Add(filePath, img); // 添加该图片到缓存池
         }
         pic.Image       = img;
         lblName.Text    = Path.GetFileName(filePath);
         lblPage.Text    = string.Format(@"{0} / {1}", CurrentIndex + 1, PhotoCount);
         btnPrev.Enabled = true;
         btnNext.Enabled = true;
         if (CurrentIndex == 0)
         {
             btnPrev.Enabled = false;
         }
         if (CurrentIndex == PhotoCount - 1)
         {
             btnNext.Enabled = false;
         }
     }
     pnlMain.Invalidate(true);
     if (null != _currentIndexChanged)
     {
         _currentIndexChanged(this, EventArgs.Empty);
     }
 }