Exemple #1
0
        public static WWWLoader CreateInstance(string name, string originName, ELoadPriority priority, bool isRaw, bool isWeb)
        {
            WWWLoader loader = new WWWLoader();

            loader.mName        = name;
            loader.mOriginName  = originName;
            loader.mWWW         = WWWUtil.CreateWWW(name, isRaw, isWeb);
            loader.LoadPriority = priority;
            return(loader);
        }
Exemple #2
0
 public static int WWWLoaderSort(WWWLoader lhs, WWWLoader rhs)
 {
     if (lhs.LoadPriority > rhs.LoadPriority)
     {
         return(-1);
     }
     else
     {
         return(1);
     }
 }
Exemple #3
0
        public float GetProgress(string name)
        {
            WWWLoader loader = _GetWWWLoader(name);

            if (loader == null)
            {
                return(0);
            }
            else
            {
                return(loader.Progress);
            }
        }
Exemple #4
0
        private WWWLoader _GetWWWLoader(string name)
        {
            WWWLoader loader = null;

            WWWLoader[] loaders = mDownList.Where(ld => ld.Name.Equals(name)).ToArray();
            if (loaders.Length > 0)
            {
                loader = loaders[0];
            }
            loaders = mWaitList.Where(ld => ld.Name.Equals(name)).ToArray();
            if (loaders.Length > 0)
            {
                loader = loaders[0];
            }
            return(loader);
        }
Exemple #5
0
        public void LoadWWW(string name, string originName, Action <string, WWW> callback, ELoadPriority priority, bool isRaw, bool isWeb)
        {
            if (string.IsNullOrEmpty(name))
            {
                Debug.LogError("load www but name is empty or null.");
                return;
            }
            WWWLoader loader = _GetWWWLoader(name);

            if (loader == null)
            {
                loader = WWWLoader.CreateInstance(name, originName, priority, isRaw, isWeb);
                mWaitList.Add(loader);
            }
            loader.AddCallback(callback);
        }
Exemple #6
0
 public void Update()
 {
     for (int i = 0; i < mDownList.Count;)
     {
         WWWLoader loader = mDownList[i];
         loader.Update();
         if (loader.LoadState == EWWWState.Done)
         {
             mDownList.RemoveAt(i);
         }
         else
         {
             ++i;
         }
     }
     if (mDownList.Count < MAX_DOWN_COUNT && mWaitList.Count > 0)
     {
         mWaitList.Sort(WWWLoader.WWWLoaderSort);
         mDownList.Add(mWaitList[0]);
         mWaitList.RemoveAt(0);
     }
 }