示例#1
0
    public static void process(Action callback)
    {
        float total   = 0;
        float current = 0;

        LinkedList <string>         loadTaskQueue = new LinkedList <string>();
        Action <UnityEngine.Object> onloaded      = null;

        onloaded = uobj =>
        {
            current += 1;
            EventDispatcher.getInstance().dispatchEvent(EventId.UI_UPDATE_LOADING, current / total);
            if (current >= total)
            {
                EventDispatcher.getInstance().dispatchEvent(EventId.UI_CLOSE_LOADING);
                callback.Invoke();
                return;
            }

            var abNode = loadTaskQueue.Last;
            if (abNode != null)
            {
                MgrRes.loadPrefab(abNode.Value, null, onloaded);
                loadTaskQueue.RemoveLast();
            }
        };


        foreach (var item in calculatedLoadResList)
        {
            total += 1;
            loadTaskQueue.AddLast(item.Key);
        }


        for (int i = 0; i < MAX_LOAD_TASK; i++)
        {
            var abNode = loadTaskQueue.Last;
            if (abNode != null)
            {
                MgrRes.loadPrefab(abNode.Value, null, onloaded);
                loadTaskQueue.RemoveLast();
            }
        }

        calculatedLoadResList.Clear();

        if (total == 0)
        {
            Tools.Log("MgrResLoader process : no calculatedLoadResList");
            EventDispatcher.getInstance().dispatchEvent(EventId.UI_CLOSE_LOADING);
            callback.Invoke();
        }
    }
示例#2
0
    public static void setSpriteForContainer(SpriteRenderer render, string spriteName, ResObject container)
    {
        if (render == null || container == null || container.isDisposed())
        {
            return;
        }
        var objs = spriteName.Split('/');

        MgrRes.loadPrefab(objs[0], objs[1], obj =>
        {
            if (container.isDisposed())
            {
                return;
            }

            render.sprite = obj as Sprite;
        }, true);
    }
示例#3
0
 public ResObject(SObject arguments, Action <ResObject> callback)
 {
     m_arguments = arguments;
     //m_callback = callback;
     MgrRes.loadPrefab(getAssetBundleName(), null, onLoadPrefab);
 }