예제 #1
0
    static void LoadCSVConfig()
    {
        string patch = AssetBundleManager.GetUICSVConfigPatch();

        if (!File.Exists(patch))
        {
            return;
        }
        m_UIConfigTable.Clear();
        //m_UIPackageTable.Clear();
        string stSchemeAllText = DeCodeAssetFile(patch);

        //去掉\n,因为ScpReader以"\r"分割
        stSchemeAllText = stSchemeAllText.Replace("\n", "");
        //再干掉最后的"\r"
        stSchemeAllText = stSchemeAllText.Remove(stSchemeAllText.Length - 1, 1);
        AssetBundleConfigReader UIReader = new AssetBundleConfigReader(stSchemeAllText, "UIConfig", 2);

        // 遍歷整個表并存儲起來
        for (int i = 0; i < UIReader.GetRecordCount(); ++i)
        {
            ResConfigData data = new ResConfigData();
            //int id = UIReader.GetInt(i, (int)UIConfigCol.COL_ID, -1);
            data.AssetBundleName = UIReader.GetString(i, (int)AssetConfigCol.COL_AssetBundleName, string.Empty);
            data.AssetName       = UIReader.GetString(i, (int)AssetConfigCol.COL_AssetName, string.Empty);
            data.AssetGUID       = UIReader.GetString(i, (int)AssetConfigCol.COL_AssetGUID, string.Empty);
            data.AssetSize_X     = UIReader.GetFloat(i, (int)AssetConfigCol.COL_AssetSize_X, -1.0f);
            data.AssetSize_Y     = UIReader.GetFloat(i, (int)AssetConfigCol.COL_AssetSize_Y, -1.0f);
            if (data.AssetName.Equals(string.Empty))
            {
                Debug.LogError("包名为空!");
                continue;
            }
            ////ID与包名对应表
            //if (!m_UIPackageTable.ContainsKey(id))
            //{
            //    m_UIPackageTable.Add(id, data.AssetBundleName);
            //}

            //包名已经存在了
            if (m_UIConfigTable.ContainsKey(data.AssetBundleName))
            {
                Dictionary <string, ResConfigData> ta = m_UIConfigTable[data.AssetBundleName];
                if (ta.ContainsKey(data.AssetName))
                {
                    Debug.LogError("重复的资源名:" + data.AssetName + ",包:" + data.AssetBundleName);
                    continue;
                }
                ta.Add(data.AssetName, data);
            }
            else
            {
                Dictionary <string, ResConfigData> ta = new Dictionary <string, ResConfigData>();
                ta.Add(data.AssetName, data);
                m_UIConfigTable.Add(data.AssetBundleName, ta);
            }
        }
        UIReader.Dispose();
        UIReader = null;
    }
예제 #2
0
    static void ResLoadCallBack(ResConfigData cof, ResNode res, System.Object UserDataObj)
    {
        SkinModelInfo info = UserDataObj as SkinModelInfo;

        if (null == info)
        {
            Debug.LogError("皮肤异步加载严重错误--ResLoadCallBack");
            return;
        }

        Skin sk = null;

        if (m_SkinMap.TryGetValue(info.nSkinID, out sk))
        {
            //已经有这个皮肤,不加载了,这种情况是被同步冲掉了
            if (sk.isValid)
            {
                return;
            }
        }

        //if(null == res || !res.IsValid())
        //{
        //    RemoveAllCallBack(info.nSkinID);
        //}
        BuildSkin(info, res, true);
    }
예제 #3
0
 public static ResNode GetAssetsAsync(AssetType t, ResConfigData conf,
                                      IAsyncResLoadHandler callBack,
                                      System.Object userDataObj  = null,
                                      AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
 {
     return(GetAssetsAsync(t, conf, callBack.ResLoadCallBack, userDataObj, priority));
 }
예제 #4
0
    private static ResConfigData GetDependenicesConfig(string guid)
    {
        ResConfigData reslut = null;

        m_DependenciesResConfigTable.TryGetValue(guid, out reslut);
        return(reslut);
    }
예제 #5
0
 public void Clear()
 {
     userCallBck = null;
     userDataObj = null;
     assetType   = null;
     configData  = null;
 }
예제 #6
0
    /// <summary>
    /// 再调用之前必须调用isCanLoadLvel判断是否可以加载场景
    /// </summary>
    /// <param name="sceneName">场景名,区分大小写</param>
    /// <returns></returns>
    public static void LoadLevel(string sceneName)
    {
        /*
         * 用回旧的流程,走runtime,因为不走runtime会读取到材质球,导致每次都需要svn更新
         */

        if (!isCallisCanLoadLevel)
        {
            Debug.LogError("必须先调用isCanLoadLevel");
            return;
        }

        //场景已经被加载
        if (LoadedScene_AbTable.ContainsKey(sceneName))
        {
            return;
        }
        LoadSceneAssetBundle(sceneName);
        isCallisCanLoadLevel = false;

        if (isOnRunTimeMode)
        {
            UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName);
        }
        else
        {
            ResConfigData scenePath = GetScenePath(sceneName);
            if (null != scenePath)
            {
                LoadSceneOnEditorInstance(scenePath.AssetGUID, false, false);
            }
        }
    }
    private static void PrefabResourceCallBack(ResConfigData cof, ResNode nod, System.Object userDataObj)
    {
        List <AsyncLoadingObject> list = null;

        ////预制体依赖加载完了,预制体本身也加载完了,这时候发现,已经不需要这个预制体了
        //if (m_NeedToDeletePrefab.Contains(nod.instanceID))
        //{
        //    m_NeedToDeletePrefab.Remove(nod.instanceID);
        //    DeletePrefabResourceAsync(ref nod, PrefabResourceCallBack, true);
        //    return;
        //}



        //预制体加载失败的
        if (nod != null && !nod.IsValid())
        {
            UnLoadDependenicesAsync(nod.instanceID);
        }
        else
        {
            ReleaseDependenicesAssetBundleIfNeed(nod);
        }

        ReleaseAssetBundleIfNeed(nod);
        PushLoadedAssetInfo(nod, GetPrefabDependenciesResNode(nod.instanceID));
        if (m_PrefabRequestTable.TryGetValue(nod.instanceID, out list))
        {
            m_PrefabRequestTable.Remove(nod.instanceID);
            foreach (AsyncLoadingObject obj in list)
            {
                obj.callBack(cof, nod, obj.UserDataObj);
            }
        }
    }
예제 #8
0
    private static void LoadSceneConfig()
    {
        string patch           = FullAssetPackagePathRoot + SceneConfigPatch;
        string stSchemeAllText = DeCodeAssetFile(patch);

        if (stSchemeAllText.Equals(string.Empty))
        {
            Debug.LogError("加载场景配置失败!");
            return;
        }

        //去掉\n,因为ScpReader以"\r"分割
        stSchemeAllText = stSchemeAllText.Replace("\n", "");
        //再干掉最后的"\r"
        stSchemeAllText = stSchemeAllText.Remove(stSchemeAllText.Length - 1, 1);
        AssetBundleConfigReader SceneConfigReader = new AssetBundleConfigReader(stSchemeAllText, "SceneConfig", 2);

        // 遍歷整個表并存儲起來
        for (int i = 0; i < SceneConfigReader.GetRecordCount(); ++i)
        {
            ResConfigData cof = new ResConfigData();
            cof.AssetName       = SceneConfigReader.GetString(i, (int)SceneConfig.COL_SCENE_NAME, "");
            cof.AssetGUID       = SceneConfigReader.GetString(i, (int)SceneConfig.COL_GUID, "");
            cof.AssetBundleName = SceneConfigReader.GetString(i, (int)SceneConfig.COL_ASSETBUNDLENAME, "");
            SceneConfigTable.Add(cof.AssetName, cof);
        }

        SceneConfigReader.Dispose();
        SceneConfigReader = null;
    }
예제 #9
0
    /// <summary>
    /// 资源加载回调
    /// </summary>
    /// <param name="cof"></param>
    /// <param name="res"></param>
    /// <param name="UserDataObj"></param>
    public void ResLoadCallBack(ResConfigData cof, ResNode res, System.Object UserDataObj)
    {
        if (!m_Valid)
        {
            return;
        }
        SoundConfigData config = cof as SoundConfigData;
        Sound           ins    = UserDataObj as Sound;

        if (null == config ||
            !ins)
        {
            return;
        }

        m_ResNode = res;

        if (ApplyConfig())
        {
            isFinish = false;

            if (config.bPlayOnAwake || bPlay)
            {
                Play();
            }
        }
    }
예제 #10
0
    public void ResLoadCallBack(ResConfigData cof, ResNode res, System.Object UserDataObj)
    {
        if (!IsValidSpiteSettings())
        {
            return;
        }

        if (null != res)
        {
            int index = (int)UserDataObj;
            if (index < currSpriteResNode.Count)
            {
                currSpriteResNode[index] = res;
                m_SpriteList[index]      = (res.ConvertRes <Sprite>());

                currLoadingSprite.Remove(index);
                int temp = Mathf.Max(0, SpriteCount - realyPreLoadCount);
                if (temp <= 0)
                {
                    m_LoadingProgress = 1.01f;
                }
                else
                {
                    float fTemp1 = currLoadingSprite.Count;
                    m_LoadingProgress = (1 - (fTemp1 / temp)) + 0.01f;
                }
            }
        }
    }
예제 #11
0
    /// <summary>
    /// 不能获取预制体
    /// </summary>
    /// <param name="t"></param>
    /// <param name="conf"></param>
    /// <returns></returns>
    public static ResNode GetAssets(AssetType t, ResConfigData conf)
    {
        ResNode res = null;

        if (null == conf)
        {
            return(res);
        }

        switch (t)
        {
        case AssetType.Asset_Prefab:
            UnionResConfigData unionCof = conf as UnionResConfigData;
            if (null == unionCof)
            {
                Debug.LogWarning("预制体参数转换失败,请确认参数2是否是UnionResConfigData类型");
                return(null);
            }
            res = GetPrefab(unionCof);
            break;

        case AssetType.Asset_FBX:
            res = GetFBXResource(conf);
            break;

        case AssetType.Asset_AnimationClip:
            res = GetAnimationClipResource(conf);
            break;

        case AssetType.Asset_AnimatorController:
            res = GetAnimatorControllerResource(conf);
            break;

        case AssetType.Asset_Audio:
            res = GetAudioResource(conf);
            break;

        case AssetType.Asset_Font:
            res = GetFont(conf.AssetBundleName, conf.AssetName);
            break;

        case AssetType.Asset_Material:
            res = GetMaterialResource(conf);
            break;

        case AssetType.Asset_Texture:
            res = GetTextureResource(conf);
            break;

        case AssetType.Asset_Sprite:
            res = GetSprite(conf.AssetBundleName, conf.AssetName);
            break;

        default:
            Debug.LogWarning(StringHelper.BuildString("无效的资源类型:", t));
            break;
        }
        return(res);
    }
예제 #12
0
 private static void AsyncLoadDependenicesCallBack(ResConfigData config, ResNode res,
                                                   System.Object userData)
 {
     if (null != res && !res.IsValid())
     {
         Debug.LogWarning(config.AssetName + "-预制体依赖资源加载失败,类型:" + res.assetType.ToString() + ",资源路径:" + config.AssetBundleName + "--" + config.AssetName);
     }
 }
    private static ResNode GetAnimationClipPackgeAsync(ResConfigData config, System.Action <ResourcePackageCallBackObj> resourcePackageCallBack,
                                                       System.Action <ResConfigData, ResNode, System.Object> UserCallBack, System.Object userDataObj)
    {
        ResNode res = null;

        BuildPacakgeAsync(ref res, m_AnimationClipResTable, config, resourcePackageCallBack, UserCallBack, userDataObj);
        return(res);
    }
예제 #14
0
    private static ResourcePackage GetResourcePackge(ResConfigData config)
    {
        ResourcePackage pkg = AllocResourcePackage(config.AssetBundleName);

        if (m_LoadedResourcePackage.Contains(pkg.instanceID))
        {
            pkg.AddRef();
        }
        else
        {
            string abName = config.AssetBundleName;
            string patch  = AssetBundleManager.FullAssetPackagePathRoot + config.AssetBundleName;

            UnionResConfigData unionRes = config as UnionResConfigData;
            if (unionRes != null)
            {
                patch  = unionRes.UnionFilePath;
                abName = unionRes.ShortUnionFilePath;
            }

            if (!m_RespackageTable.ContainsKey(abName))
            {
                AssetBudleLog("AssetBundle文件不存在!,路径:" + patch);
                return(pkg);
            }
            RemoveNeedToUnLoadPackage(pkg.instanceID);
            //异步加载的列表里有他,那么要强制同步加载了
            if (m_ResourcePackageRequestTable.Contains(pkg.instanceID))
            {
                m_ResourcePackageRequestTable.Remove(pkg.instanceID);
                if (pkg.isUpLoadToLoadingThread)
                {
                    pkg.AssetBundleInstance = pkg.fileRequest.assetBundle;
                }
                else
                {
                    pkg.isUpLoadToLoadingThread = true;
                    pkg.AssetBundleInstance     = LoadAssetBundle(patch, config);
                }
                RemoveFromAssetsFileUpLoadQueue(pkg.instanceID);
                RemoveAssetsFileProcessingList(pkg.instanceID);
                PushToResourcePackageCallBackList(pkg.instanceID);
            }
            else
            {
                AssetBundle pAssetBundle = LoadAssetBundle(patch, config);
                pkg.AssetBundleInstance = pAssetBundle;
            }
            pkg.filePatch = patch;
            pkg.AddRef();
            m_LoadedResourcePackage.Add(pkg.instanceID);
        }

        return(pkg);
    }
예제 #15
0
        public ResConfigData ConvertToResConfigData()
        {
            ResConfigData instance = new ResConfigData();

            instance.AssetBundleName = FullAssetBundleName;
            instance.AssetName       = assetName;
            instance.AssetGUID       = guid;
            instance.AssetSize_X     = Asset_X;
            instance.AssetSize_Y     = Asset_Y;
            return(instance);
        }
예제 #16
0
 public static void PushDependenicesRes(ResConfigData res)
 {
     if (m_DependenciesResConfigTable.ContainsKey(res.AssetGUID))
     {
         m_DependenciesResConfigTable[res.AssetGUID] = res;
     }
     else
     {
         m_DependenciesResConfigTable.Add(res.AssetGUID, res);
     }
 }
        /// <summary>
        /// 异步加载回调
        /// </summary>
        /// <param name="cof"></param>
        /// <param name="res"></param>
        /// <param name="UserDataObj"></param>
        public void ResLoadCallBack(ResConfigData cof, ResNode res, object UserDataObj)
        {
            UEffectPrefabAsyncParam _effectParam = UserDataObj as UEffectPrefabAsyncParam;

            if (_effectParam != null && _effectParam.EffectRes != null)
            {
                InstantiateEffectPrefab(_effectParam);

                InitEffectPrefabRefParam(_effectParam);
            }
        }
예제 #18
0
    private static void LoadDependenciesResConfig(Dictionary <string, ResConfigData> Result = null)
    {
        string patch = AssetBundleManager.GetDependenicesResConfigPath();

        if (!File.Exists(patch))
        {
            if (Application.isPlaying)
            {
                Debug.LogError("找不到预制体资源表!!!-" + patch);
            }
            return;
        }

        string stSchemeAllText = DeCodeAssetFile(patch);

        if (stSchemeAllText.Equals(string.Empty))
        {
            return;
        }

        if (null == Result)
        {
            Result = m_DependenciesResConfigTable;
        }

        ////去掉\n,因为ScpReader以"\r"分割
        //stSchemeAllText = stSchemeAllText.Replace("\n", "");
        ////再干掉最后的"\r"
        //stSchemeAllText = stSchemeAllText.Remove(stSchemeAllText.Length - 1, 1);
        AssetBundleConfigReader ResReader = new AssetBundleConfigReader(stSchemeAllText, "DependenicesResConfig", 0);

        for (int i = 0; i < ResReader.GetRecordCount(); ++i)
        {
            ResConfigData depconf = new ResConfigData();
            depconf.AssetBundleName = StringHelper.CopyString(ResReader.GetString(i, (int)AssetConfigCol.COL_AssetBundleName, string.Empty));
            depconf.AssetName       = StringHelper.CopyString(ResReader.GetString(i, (int)AssetConfigCol.COL_AssetName, string.Empty));
            depconf.AssetGUID       = StringHelper.CopyString(ResReader.GetString(i, (int)AssetConfigCol.COL_AssetGUID, string.Empty));
            depconf.AssetSize_X     = ResReader.GetFloat(i, (int)AssetConfigCol.COL_AssetSize_X, -1.0f);
            depconf.AssetSize_Y     = ResReader.GetFloat(i, (int)AssetConfigCol.COL_AssetSize_Y, -1.0f);
            if (m_DependenciesResConfigTable.ContainsKey(depconf.AssetGUID))
            {
                Debug.LogWarning(StringHelper.BuildString("依赖资源表有重复的配置:", depconf.AssetGUID, depconf.AssetName, depconf.AssetBundleName));
                continue;
            }
            else
            {
                m_DependenciesResConfigTable.Add(StringHelper.CopyString(depconf.AssetGUID), depconf);
            }
        }

        ResReader.Dispose();
        ResReader = null;
    }
예제 #19
0
 private static AssetBundle LoadAssetBundle(string bundleName, ResConfigData data)
 {
     if (null != data && data.GetType() == typeof(UnionResConfigData))
     {
         UnionResConfigData unionData = data as UnionResConfigData;
         return(LoadAssetBundleFromFile(unionData.UnionFilePath, unionData.startIndex));
     }
     else
     {
         return(LoadAssetBundleFromFile(bundleName));
     }
 }
예제 #20
0
    /// <summary>
    /// 相对路径
    /// </summary>
    /// <param name="patch"></param>
    /// <returns></returns>
    public static ResConfigData GetResConfigDataFromPatch(string path)
    {
        ResConfigData         conf = null;
        AssetBundleEditorInfo info = GetAssetBundleEditorInfo(path);

        if (null == info)
        {
            return(conf);
        }
        conf = info.ConvertToResConfigData();
        return(conf);
    }
예제 #21
0
    private void OnHandleResLoadFinish(ResConfigData cof, ResNode res, System.Object UserDataObj)
    {
        LightingEffectResHandle node = UserDataObj as LightingEffectResHandle;

        if (null == node)
        {
            Debug.LogError("光效异步加载致命bug---UserDataObj not match");
            return;
        }
        m_LightEffectHandleTable.Add(node.EffectID);
        node.OnLoadFinish(EffectCacheRoot.transform, res);
    }
    private static ResNode GetCacheAnimatorControllerResource(ResConfigData cof)
    {
        ResNode res        = null;
        int     InstanceID = GUIDToInstanceID(cof.AssetGUID);

        if (m_AnimatorControllerCacheResTable.TryGetValue(InstanceID, out res))
        {
            res.cacheTime = 0.0f;
            m_AnimatorControllerCacheResTable.Remove(InstanceID);
        }
        return(res);
    }
예제 #23
0
    /// <summary>
    /// 加载预制体的资源依赖
    /// </summary>
    /// <param name="pefabConfig"></param>
    /// <returns></returns>
    private static bool LoadDependenices(ResConfigData pefabConfig)
    {
        PrefabDependenciesResNode dependenciesRes;

        if (LoadDependenicesResource(pefabConfig, out dependenciesRes))
        {
            int InstanceID = GUIDToInstanceID(pefabConfig.AssetGUID);
            m_PrefabDependenciesResNodeTable.Add(InstanceID, dependenciesRes);
            return(true);
        }
        UnLoadDependenicesResource(dependenciesRes);
        return(false);
    }
예제 #24
0
    static ResNode GetCacheSpriteResource(ResConfigData cofing)
    {
        ResNode res        = null;
        int     InstanceID = GUIDToInstanceID(cofing.AssetGUID);

        if (m_UISpriteCacheTable.TryGetValue(InstanceID, out res))
        {
            res.cacheTime = 0.0f;
            m_UISpriteCacheTable.Remove(InstanceID);
        }

        return(res);
    }
예제 #25
0
 private static AssetBundleCreateRequest LoadAssetBundleAsync(string bundleName, ResConfigData data)
 {
     if (null != data && data.GetType() == typeof(UnionResConfigData))
     {
         //return LoadAssetBundleFromMenory(bundleName, data);
         UnionResConfigData unionData = data as UnionResConfigData;
         return(LoadAssetBundleFromFileAsync(unionData.UnionFilePath, unionData.startIndex));
     }
     else
     {
         return(LoadAssetBundleFromFileAsync(bundleName));
     }
 }
예제 #26
0
    /// <summary>
    /// 本函数不能获取预制体和字体
    /// </summary>
    /// <param name="t"></param>
    /// <param name="conf"></param>
    /// <param name="callBack"></param>
    /// <param name="userDataObj"></param>
    /// <returns></returns>
    public static ResNode GetAssetsAsync(AssetType t, ResConfigData conf,
                                         System.Action <ResConfigData, ResNode, System.Object> callBack,
                                         System.Object userDataObj  = null,
                                         AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
    {
        ResNode res = null;

        if (null == conf)
        {
            return(res);
        }

        switch (t)
        {
        case AssetType.Asset_Prefab:
            UnionResConfigData unionCof = conf as UnionResConfigData;
            if (null == unionCof)
            {
                Debug.LogWarning("预制体参数转换失败,请确认参数2是否是UnionResConfigData类型");
                return(null);
            }
            return(GetPrefabAsync(unionCof, callBack, userDataObj, priority));

        case AssetType.Asset_FBX:
            return(GetFBXResourceAsync(conf, callBack, userDataObj, priority));

        case AssetType.Asset_AnimationClip:
            return(GetAnimationClipResourceAsync(conf, callBack, userDataObj, priority));

        case AssetType.Asset_AnimatorController:
            return(GetAnimatorControllerResourceAsync(conf, callBack, userDataObj, priority));

        case AssetType.Asset_Audio:
            return(GetAudioResourceAsync(conf, callBack, userDataObj, priority));

        case AssetType.Asset_Font:
            Debug.LogWarning("字体属于通用资源,不支持异步加载");
            return(res);

        case AssetType.Asset_Material:
            return(GetMaterialResourceAsync(conf, callBack, userDataObj, priority));

        case AssetType.Asset_Texture:
            return(GetTextureResourceAsync(conf, callBack, userDataObj, priority));

        case AssetType.Asset_Sprite:
            return(GetSpriteAsync(conf.AssetBundleName, conf.AssetName, callBack, userDataObj, priority));
        }
        Debug.LogWarning("无效的资源类型:" + t.ToString());
        return(res);
    }
예제 #27
0
    private static ResNode BuildTextureResNode(ResConfigData config)
    {
        ResNode res = null;

        if (!isOnRunTimeMode)
        {
            BuildResNodeOnEditor <Texture>(ref res, config);
        }
        else
        {
            BuildResNodeOnRunTime <Texture>(ref res, config);
        }
        return(res);
    }
    private static ResNode BuildAnimatorControllerResNode(ResConfigData config)
    {
        ResNode res = null;

        if (!isOnRunTimeMode)
        {
            BuildResNodeOnEditor <RuntimeAnimatorController>(ref res, config);
        }
        else
        {
            BuildResNodeOnRunTime <RuntimeAnimatorController>(ref res, config);
        }
        return(res);
    }
예제 #29
0
    private static ResNode BuildAudioResNode(ResConfigData config)
    {
        ResNode res = null;

        if (!isOnRunTimeMode)
        {
            BuildResNodeOnEditor <AudioClip>(ref res, config);
        }
        else
        {
            BuildResNodeOnRunTime <AudioClip>(ref res, config);
        }
        return(res);
    }
예제 #30
0
    public void ResLoadCallBack(ResConfigData cof, ResNode res, object UserDataObj)
    {
        SceneEffectParamAsync param = UserDataObj as SceneEffectParamAsync;
        ResNode resNodeInfo         = null;

        if (param != null && m_dicEffectIDResNodeUsed.ContainsKey(param.AttachEffectID) && param.IsCanBeInstance)
        {
            resNodeInfo = m_dicEffectIDResNodeUsed[param.AttachEffectID];
            if (resNodeInfo != null)
            {
                InitEffectParam(resNodeInfo, param);
            }
        }
    }