Esempio n. 1
0
 public void GetAudio(string url, AudioClipLoadType loadType, Action <AudioClip> callback, string alias = null)
 {
     VerifyUrl(url);
     if (!url.IsEmpty())
     {
         AudioClip c = assetCache.Get(url) as AudioClip;
         if (c != null)
         {
             callback(c);
         }
         else
         {
             if (url.Is(FileType.Asset))
             {
                 GetAsset <AudioClip>(url, callback, false);
             }
             else
             {
                 callbacks.Add(url, callback);
                 if (callbacks.GetCount(url) == 1)
                 {
                     log.Debug("Loading {0}", url);
                     loader.GetAudio(pathConverter(url), loadType, clip =>
                     {
                         if (clip != null)
                         {
                             AddToCache(alias, url, clip);
                         }
                         List <Delegate> slot = callbacks.GetSlot(url);
                         foreach (Delegate d in slot)
                         {
                             ((Action <AudioClip>)d)(clip);
                         }
                         callbacks.Remove(url);
                     });
                 }
             }
         }
     }
     else
     {
         callback(null);
     }
 }