Example #1
0
    public static void openNextScene(SceneBase scene)
    {
        Tools.Log("===> openNextScene!");
        if (m_busy)
        {
            Tools.Log("next scene is busy now!");
            return;
        }
        //MgrPanel.disposeAllPanel();

        if (m_curScene != null)
        {
            MgrResLoader.insertRemoving(m_curScene.getResList());
            m_curScene.onLeave();
            m_curScene = null;
        }

        m_busy = true;
        PanelLoading.open();

        MgrResLoader.insertLoading(scene.getResList());
        m_nextScene = scene;

        MgrPanel.disposeAllPanel();
        MgrRes.clearObjectCacheAll();
        Util.ClearMemory();

        MgrResLoader.start(executeSceneDown);
    }
Example #2
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();
        }
    }
Example #3
0
    public virtual void dispose()
    {
        bDisposed = true;

        if (bInited)
        {
            UObject.Destroy(gameObject);
            gameObject  = null;
            transform   = null;
            m_arguments = null;
            MgrRes.putPrefab(getAssetBundleName(), null);
            bInited = false;
        }
    }
Example #4
0
    void onLoadPrefab(UObject obj)
    {
        if (bDisposed)
        {
            MgrRes.putPrefab(getAssetBundleName(), null);
            return;
        }

        gameObject = UObject.Instantiate(obj) as GameObject;
        transform  = gameObject.transform;
        bInited    = true;

        onCreate(m_arguments);
    }
Example #5
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);
    }
Example #6
0
    static void preProcess()
    {
        calculatedLoadResList.Clear();
        foreach (var item in removingResList)
        {
            MgrRes.putPrefab(item.Key, null);
        }

        foreach (var item in loadingResList)
        {
            if (!MgrRes.loadReferencedPrefab(item.Key))
            {
                calculatedLoadResList[item.Key] = true;
            }
        }

        //--清空待卸载列表
        removingResList.Clear();
        loadingResList.Clear();
    }
Example #7
0
 public ResObject(SObject arguments, Action <ResObject> callback)
 {
     m_arguments = arguments;
     //m_callback = callback;
     MgrRes.loadPrefab(getAssetBundleName(), null, onLoadPrefab);
 }