Ejemplo n.º 1
0
        public override TaskStatus Update()
        {
            if (req == null)
            {
                if (queue.Count > 0)
                {
                    pendingData = queue.Dequeue();
                    req         = Resources.LoadAsync(System.IO.Path.Combine(pendingData.path, pendingData.name), pendingData.loadType);
                }
                else
                {
                    return(TaskStatus.Done);
                }
            }

            if (req.isDone)
            {
                var asset = req.asset;
                req       = null;
                progress += 1f;

                if (asset == null)
                {
                    if (pendingData.onFail != null)
                    {
                        pendingData.onFail(pendingData);
                    }

                    if (pendingData.abortIfFailed)
                    {
                        return(TaskStatus.Abort);
                    }
                }
                else
                {
                    pendingData.loadedAsset = asset;
                    if (pendingData.onSuccess != null)
                    {
                        pendingData.onSuccess(pendingData);
                    }
                }

                pendingData = null;
            }

            return(TaskStatus.Pending);
        }
Ejemplo n.º 2
0
 public TaskResourceLoad(TaskResourceLoadData data)
 {
     queue = new Queue <TaskResourceLoadData> ();
     queue.Enqueue(data);
     count = queue.Count;
 }
Ejemplo n.º 3
0
 public override void Reset()
 {
     pendingData = null;
     req         = null;
 }