Ejemplo n.º 1
0
    private void GetResources(string sceneName, string bundleName, string resName, bool isSingle, ushort backID)
    {
        if (!ILoaderManager.Instance.IsLoadingAssetBundle(sceneName, bundleName))                    // 没有加载
        // 加载并添加请求
        {
            ILoaderManager.Instance.LoadAsset(sceneName, bundleName, OnLoadProgress);

            string bundleFullName = ILoaderManager.Instance.GetBundleReflectName(sceneName, bundleName);
            if (bundleFullName != null)
            {
                NativeResCallBackNode tmpNode = new NativeResCallBackNode(isSingle, sceneName, bundleName, resName, backID, OnSendToBackMsg, null);

                CallBackMgr.AddBundle(bundleFullName, tmpNode);
            }
            else
            {
                Debug.LogWarning("don't contains bundle = " + bundleName);
            }
        }
        else if (ILoaderManager.Instance.IsLoadingBundleFinish(sceneName, bundleName))              // 有加载,并且加载完成
        // 直接返回
        {
            if (isSingle)
            {
                UnityEngine.Object tmpObj = ILoaderManager.Instance.GetSingleResources(sceneName, bundleName, resName);

                ResBackMsg.Change(backID, tmpObj);
                SendMsg(ResBackMsg);
            }
            else
            {
                UnityEngine.Object[] tmpObjs = ILoaderManager.Instance.GetMultiResources(sceneName, bundleName, resName);

                ResBackMsg.Change(backID, tmpObjs);
                SendMsg(ResBackMsg);
            }
        }
        else                                                                                        // 已经加载,但没有完成
        // 把命令存下来

        {
            string bundleFullName = ILoaderManager.Instance.GetBundleReflectName(sceneName, bundleName);
            if (bundleFullName != null)
            {
                NativeResCallBackNode tmpNode = new NativeResCallBackNode(isSingle, sceneName, bundleName, resName, backID, OnSendToBackMsg, null);

                CallBackMgr.AddBundle(bundleFullName, tmpNode);
            }
            else
            {
                Debug.LogWarning("don't contains bundle = " + bundleName);
            }
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// node 回调 回复上层消息
    /// </summary>
    /// <param name="node"></param>
    private void OnSendToBackMsg(NativeResCallBackNode node)
    {
        if (node.isSingle)
        {
            // 获取资源
            UnityEngine.Object tmpObj = ILoaderManager.Instance.GetSingleResources(node.sceneName, node.bundleName, node.resName);

            // 设置参数并发送
            ResBackMsg.Change(node.backMagID, tmpObj);
            SendMsg(ResBackMsg);
        }
        else
        {
            UnityEngine.Object[] tmpObj = ILoaderManager.Instance.GetMultiResources(node.sceneName, node.bundleName, node.resName);

            ResBackMsg.Change(node.backMagID, tmpObj);
            SendMsg(ResBackMsg);
        }
    }