コード例 #1
0
ファイル: MonsterSkinControl.cs プロジェクト: zwong91/Titan
        /// <summary>
        /// 修改皮肤
        /// </summary>
        /// <param name="nSkinID">皮肤ID</param>
        /// <param name="nPart">哪个部位</param>
        public override SkinChangedReslut ChangeSkin(int nSkinID, int nPart, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
        //public override SkinChangedReslut ChangeSkin(int nSkinID, int nPart)
        {
            if (currentSkinId == nSkinID)
            {
                return(SkinChangedReslut.SameSkin);
            }
            //if (nSkinID == InvalidSkinID)
            //{
            //    ClearMonsterSkinDataFromMachine(m_machine);
            //    SkinInstance.DisableSkinInstance(m_currentSkinInstance);
            //    SkinManager.DeleteSkinAsync(currentSkinId, OnSkinLoadFinish);
            //    RemoveCallBack(currentSkinId);
            //    m_currentSkinInstance = null;
            //    currentSkinId = nSkinID;


            //    return true;
            //}
            RemoveCallBack(currentSkinId);
            currentSkinId = nSkinID;

            if (SkinManager.GetSkinAsync(nSkinID, OnSkinLoadFinish, priority))
            //if (SkinManager.GetSkinAsync(nSkinID, OnSkinLoadFinish))
            {
                PushToCallBack(nSkinID, nPart);
                return(SkinChangedReslut.Succes);
            }
            return(SkinChangedReslut.Faild);
        }
コード例 #2
0
 public static ResNode GetAssetsAsync(AssetType t, string assetBundleName, string assetName,
                                      IAsyncResLoadHandler callBack,
                                      System.Object userDataObj  = null,
                                      AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
 {
     return(GetAssetsAsync(t, assetBundleName, assetName, callBack.ResLoadCallBack, userDataObj, priority));
 }
コード例 #3
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="mod">The mod applying the edit.</param>
 /// <param name="priority">If there are multiple loads that apply to the same asset, the priority with which this one should be applied.</param>
 /// <param name="onBehalfOf">The content pack on whose behalf the asset is being loaded, if any.</param>
 /// <param name="getData">Load the initial value for an asset.</param>
 public AssetLoadOperation(IModMetadata mod, AssetLoadPriority priority, IModMetadata onBehalfOf, Func <IAssetInfo, object> getData)
 {
     this.Mod        = mod;
     this.Priority   = priority;
     this.OnBehalfOf = onBehalfOf;
     this.GetData    = getData;
 }
コード例 #4
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));
 }
コード例 #5
0
ファイル: SkinManager_Async.cs プロジェクト: zwong91/Titan
 public static bool GetSkinAsync(int SkinID, System.Action <Skin> CallBack, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
 {
     if (!currentActiveSkinList.Contains(SkinID))
     {
         currentActiveSkinList.Add(SkinID);
     }
     return(GetSkinAsyncImpl(SkinID, CallBack, priority));
 }
コード例 #6
0
ファイル: SceneEffectManager.cs プロジェクト: zwong91/Titan
 public SceneEffectParamAsync(int _eAttachEffectID, Transform _tfAttachParent, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal,
                              string _strAttachChildName           = null, bool _bAutoPlay = true, int _nDelaySpawnTime = 0, Vector3 _vecPositionOffset = new Vector3()
                              , Action <object> _onResLoadFinished = null, object _resLoadUserObject = null) : base(_eAttachEffectID, _tfAttachParent, _strAttachChildName, _bAutoPlay, _nDelaySpawnTime, _vecPositionOffset)
 {
     onResLoadFinished = _onResLoadFinished;
     ResLoadUserObject = _resLoadUserObject;
     IsCanBeInstance   = true;
     this.priority     = priority;
 }
コード例 #7
0
 /// <summary>Provide the initial instance for the asset from a file in your mod folder, instead of trying to load it from the game's <c>Content</c> folder.</summary>
 /// <typeparam name="TAsset">The expected data type. The main supported types are <see cref="Map"/>, <see cref="Texture2D"/>, dictionaries, and lists; other types may be supported by the game's content pipeline.</typeparam>
 /// <param name="relativePath">The relative path to the file in your mod folder.</param>
 /// <param name="priority">If there are multiple loads that apply to the same asset, the priority with which this one should be applied.</param>
 /// <remarks>
 /// Usage notes:
 /// <list type="bullet">
 ///   <item>The asset doesn't need to exist in the game's <c>Content</c> folder. If any mod loads the asset, the game will see it as an existing asset as if it was in that folder.</item>
 ///   <item>Each asset can logically only have one initial instance. If multiple loads apply at the same time, SMAPI will raise an error and ignore all of them. If you're making changes to the existing asset instead of replacing it, you should use <see cref="Edit"/> instead to avoid those limitations and improve mod compatibility.</item>
 /// </list>
 /// </remarks>
 public void LoadFromModFile <TAsset>(string relativePath, AssetLoadPriority priority)
 {
     this.LoadOperations.Add(
         new AssetLoadOperation(
             mod: this.Mod,
             priority: priority,
             onBehalfOf: null,
             _ => this.Mod.Mod.Helper.Content.Load <TAsset>(relativePath))
         );
 }
コード例 #8
0
 /// <summary>Provide the initial instance for the asset, instead of trying to load it from the game's <c>Content</c> folder.</summary>
 /// <param name="load">Get the initial instance of an asset.</param>
 /// <param name="priority">If there are multiple loads that apply to the same asset, the priority with which this one should be applied.</param>
 /// <param name="onBehalfOf">The content pack ID on whose behalf you're applying the change. This is only valid for content packs for your mod.</param>
 /// <remarks>
 /// Usage notes:
 /// <list type="bullet">
 ///   <item>The asset doesn't need to exist in the game's <c>Content</c> folder. If any mod loads the asset, the game will see it as an existing asset as if it was in that folder.</item>
 ///   <item>Each asset can logically only have one initial instance. If multiple loads apply at the same time, SMAPI will use the <paramref name="priority"/> parameter to decide what happens. If you're making changes to the existing asset instead of replacing it, you should use <see cref="Edit"/> instead to avoid those limitations and improve mod compatibility.</item>
 /// </list>
 /// </remarks>
 public void LoadFrom(Func <object> load, AssetLoadPriority priority, string onBehalfOf = null)
 {
     this.LoadOperations.Add(
         new AssetLoadOperation(
             mod: this.Mod,
             priority: priority,
             onBehalfOf: this.GetOnBehalfOf(this.Mod, onBehalfOf, "load assets"),
             getData: _ => load()
             )
         );
 }
コード例 #9
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);
    }
コード例 #10
0
ファイル: USpriteManager.cs プロジェクト: zwong91/Titan
    /// <summary>
    /// 异步通过assetBundleName和AssetName获取资源节点 (不太建议这种方法)
    /// </summary>
    /// <param name="strAssetBundleName"></param>
    /// <param name="strAssetName"></param>
    /// <param name="callBack"></param>
    /// <param name="userDataObj"></param>
    /// <param name="priority"></param>
    /// <returns></returns>
    public Sprite GetSprite(string strAssetBundleName, string strAssetName, out ResNode resNodeData,
                            System.Action <ResConfigData, ResNode, System.Object> callBack,
                            System.Object userDataObj, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
    {
        ResNode resData = GetSpriteRes(strAssetBundleName, strAssetName, callBack, userDataObj, priority);

        resNodeData = resData;

        if (resData == null)
        {
            Trace.LogWarning("无法获取Sprite:" + strAssetName + " ,在包" + strAssetBundleName);
            return(null);
        }

        return(resData.ConvertRes <Sprite>());
    }
コード例 #11
0
    /// <summary>
    /// 获取资源,资源内部使用引用计数来管理资源,切勿乱调用,一个get,一个delete
    /// 返回的值仅仅是一个标示,没有资源~
    /// </summary>
    /// <param name="config">资源配置</param>
    /// <param name="callBack">回调</param>
    /// <param name="userDataObj">用户数据,这个会出现在资源回调里,不需要可以填null</param>
    /// <param name="priority">加载优先级</param>
    /// <returns></returns>
    private static ResNode GetFBXResourceAsync(ResConfigData config, System.Action <ResConfigData, ResNode, System.Object> callBack,
                                               System.Object userDataObj = null, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
    {
        if (!isVaild || !isVaild)
        {
            return(null);
        }
        if (string.IsNullOrEmpty(config.AssetBundleName))
        {
            return(null);
        }
        ResNode res = null;

        //先看看是不是通用资源
        GetCommonRes(ref res, config);
        if (null != res)
        {
            PushToResDelayCallBackList(res, config, callBack, userDataObj);
            return(res);
        }


        //编辑器下无异步加载
        if (!isOnRunTimeMode)
        {
            res = GetFBXResource(config);
            PushToResDelayCallBackList(res, config, callBack, userDataObj);
            return(res);
        }

        if (IsUnionDependenicesAssetBundle(config.AssetBundleName))
        {
            if (!config.fromReference)
            {
                AssetBudleLog(StringHelper.BuildString("资源错误--uniondepndenices不能单独加载!:", config.AssetName));
                return(res);
            }
        }

        config.priority = priority;
        res             = BuildFBXResNodeAsync(config, callBack, userDataObj);
        if (res != null)
        {
            res.assetType = AssetType.Asset_FBX;
        }
        return(res);
    }
コード例 #12
0
    /// <summary>
    /// 异步取得Prefab
    /// </summary>
    /// <param name="assetBundeName">包名</param>
    /// <param name="assetName">资源名</param>
    /// <returns></returns>
    private static ResNode GetPrefabAsync(string assetBundleName, string assetName,
                                          System.Action <ResConfigData, ResNode, System.Object> callBack,
                                          System.Object userDataObj = null, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
    {
        Dictionary <string, UnionResConfigData> assetTable = null;

        if (m_PrefabConfigTable.TryGetValue(assetBundleName, out assetTable))
        {
            UnionResConfigData cof = null;
            if (assetTable.TryGetValue(assetName, out cof))
            {
                return(GetPrefabAsync(cof, callBack, userDataObj, priority));
            }
        }
        Debug.LogWarning("在预制体配置中找不到:" + assetBundleName + "-" + assetName);
        return(null);
    }
コード例 #13
0
 /// <summary>
 /// 取得sprite
 /// </summary>
 /// <param name="assetbudleName">包名</param>
 /// <param name="assetName">资源名</param>
 /// <param name="callBack">回调</param>
 /// <param name="userDataObj">用户数据,这个会出现在资源回调里,不需要可以填null</param>
 /// <param name="priority">加载优先级</param>
 /// <returns></returns>
 private static ResNode GetSpriteAsync(string assetbudleName, string assetName,
                                       System.Action <ResConfigData, ResNode, System.Object> callBack,
                                       System.Object userDataObj, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
 {
     if (!isVaild)
     {
         return(null);
     }
     if (m_UIConfigTable.ContainsKey(assetbudleName))
     {
         Dictionary <string, ResConfigData> co = m_UIConfigTable[assetbudleName];
         ResConfigData da;
         if (co.TryGetValue(assetName, out da))
         {
             return(GetSpriteResourceAsync(da, callBack, userDataObj, priority));
         }
     }
     return(null);
 }
コード例 #14
0
    /// <summary>
    /// 获取资源,资源内部使用引用计数来管理资源,切勿乱调用,一个get,一个delete
    /// 返回的值仅仅是一个标示,没有资源~
    /// </summary>
    /// <param name="config">资源配置</param>
    /// <param name="callBack">回调</param>
    /// <param name="userDataObj">用户数据,这个会出现在资源回调里,不需要可以填null</param>
    /// <param name="priority">加载优先级</param>
    /// <returns></returns>
    private static void GetPrefabResourceAsync(ref ResNode res, UnionResConfigData config, System.Action <ResConfigData, ResNode, System.Object> callBack,
                                               System.Object userDataObj = null, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
    {
        if (!isVaild)
        {
            return;
        }

        if (string.IsNullOrEmpty(config.AssetBundleName))
        {
            return;
        }

        config.priority = priority;
        BuildPrefabResNodeAsync(ref res, config, callBack, userDataObj);
        if (res != null)
        {
            res.assetType = AssetType.Asset_Prefab;
        }
        return;
    }
コード例 #15
0
    /// <summary>
    /// 异步取得Prefab,返回值只是一个标示,没有资源,资源在回调中,相对于Prefabs路径
    /// </summary>
    /// <param name="patch">路径,如:EntityPrefab/MonsterPrefab ,Skin/Hero</param>
    /// <returns></returns>
    private static ResNode GetPrefabAsync(string strParam, bool isGuid,
                                          System.Action <ResConfigData, ResNode, System.Object> callBack,
                                          System.Object userDataObj = null, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
    {
        if (null == strParam || strParam.Equals(string.Empty))
        {
            return(null);
        }

        if (!isGuid)
        {
            string assetName       = System.IO.Path.GetFileName(strParam);
            string assetBundleName = System.IO.Path.GetDirectoryName(strParam).ToLower();

            if (assetBundleName.Equals(string.Empty))
            {
                assetBundleName = "default";
            }

            assetBundleName = assetBundleName + "/" + assetName.ToLower() + "." + AssetBundleManager.PrefabVariant;;
            string FullAssetBundleName = "gameobject/" + assetBundleName;

            return(GetPrefabAsync(FullAssetBundleName, assetName, callBack, userDataObj, priority));
        }
        else
        {
            UnionResConfigData data = null;
            int InstanceID          = GUIDToInstanceID(strParam);
            if (m_PrefabGUIDConfigTable.TryGetValue(InstanceID, out data))
            {
                return(GetPrefabAsync(data, callBack, userDataObj, priority));
            }
            else
            {
                Debug.LogWarning("加载预制体失败,资源数据库中找不到GUID:" + strParam);
            }
            return(null);
        }
    }
コード例 #16
0
    public static ResNode GetAssetsAsync(AssetType t, string assetBundleName, string assetName,
                                         System.Action <ResConfigData, ResNode, System.Object> callBack,
                                         System.Object userDataObj  = null,
                                         AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
    {
        ResNode res = null;

        if (assetBundleName.Equals(string.Empty) || assetName.Equals(string.Empty))
        {
            return(res);
        }

        switch (t)
        {
        case AssetType.Asset_Sprite:
            return(GetSpriteAsync(assetBundleName, assetName, callBack, userDataObj, priority));

        case AssetType.Asset_Prefab:
            return(GetPrefabAsync(assetBundleName, assetName, callBack, userDataObj, priority));
        }
        Debug.LogWarning("类型:" + t.ToString() + "不支持通过assetbundlename和assetName来获取");
        return(res);
    }
コード例 #17
0
    /// <summary>
    /// 获取资源,资源内部使用引用计数来管理资源,切勿乱调用,一个get,一个delete
    /// 返回的值仅仅是一个标示,没有资源~
    /// </summary>
    /// <param name="config">资源配置</param>
    /// <param name="callBack">回调</param>
    /// <param name="userDataObj">用户数据,这个会出现在资源回调里,不需要可以填null</param>
    /// <param name="priority">加载优先级</param>
    /// <returns></returns>
    private static ResNode GetAudioResourceAsync(ResConfigData config, System.Action <ResConfigData, ResNode, System.Object> callBack,
                                                 System.Object userDataObj = null, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
    {
        if (!isVaild)
        {
            return(null);
        }

        if (string.IsNullOrEmpty(config.AssetBundleName))
        {
            return(null);
        }
        ResNode res = null;

        //先看看是不是通用资源
        GetCommonRes(ref res, config);
        if (null != res)
        {
            PushToResDelayCallBackList(res, config, callBack, userDataObj);
            return(res);
        }

        //编辑器下无异步加载
        if (!isOnRunTimeMode)
        {
            res = GetAudioResource(config);
            PushToResDelayCallBackList(res, config, callBack, userDataObj);
            return(res);
        }
        config.priority = priority;
        res             = BuildAudioResNodeAsync(config, callBack, userDataObj);
        if (res != null)
        {
            res.assetType = AssetType.Asset_Audio;
        }
        return(res);
    }
コード例 #18
0
 public override AssetAsyncLoad LoadAssetAsync(string assetName, UnityAction <Object> loadedCallback, AssetLoadPriority priority = AssetLoadPriority.Normal)
 {
     return(LoadAssetAsync(assetName, loadedCallback, null, priority));
 }
コード例 #19
0
 public override AssetAsyncLoad LoadAssetAsync(string assetName, UnityAction <Object> loadedCallback, UnityAction <float> progressCallback, AssetLoadPriority priority = AssetLoadPriority.Normal)
 {
     if (m_CurrentLoadTask != null)
     {
         if (m_AssetLoadList[(int)priority].ContainsKey(assetName))
         {
             var loadTask = m_AssetLoadList[(int)priority][assetName];
             loadTask.AssetName = assetName;
             var asyncLoad = new AssetAsyncLoad(assetName);
             loadTask.AddCallback(asyncLoad, loadedCallback, progressCallback);
             return(asyncLoad);
         }
         else
         {
             var loadTask = AssetLoadTask.GetAssetLoadTask();
             loadTask.AssetName = assetName;
             var asyncLoad = new AssetAsyncLoad(assetName);
             loadTask.AddCallback(asyncLoad, loadedCallback, progressCallback);
             m_AssetLoadList[(int)priority].Add(assetName, loadTask);
             return(asyncLoad);
         }
     }
     else
     {
         var loadTask = AssetLoadTask.GetAssetLoadTask();
         loadTask.AssetName = assetName;
         var asyncLoad = new AssetAsyncLoad(assetName);
         loadTask.AddCallback(asyncLoad, loadedCallback, progressCallback);
         m_CurrentLoadTask = loadTask;
         StartLoadAsset();
         return(asyncLoad);
     }
 }
コード例 #20
0
    public static ResNode GetAssetsAsync(AssetType t, System.Action <ResConfigData, ResNode, System.Object> callBack,
                                         string strParam, bool isGuid = false, System.Object userDataObj = null, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
    {
        ResNode res = null;

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

        if (strParam.Equals(string.Empty))
        {
            return(res);
        }

        if (isGuid && t != AssetType.Asset_Prefab)
        {
            Debug.LogWarning("类型:" + t.ToString() + "不支持通过guid来获取");
            return(null);
        }


        switch (t)
        {
        case AssetType.Asset_Prefab:
            res = GetPrefabAsync(strParam, isGuid, callBack, userDataObj, priority);
            return(res);
        }
        Debug.LogWarning("类型:" + t.ToString() + "不支持通过assetbundlename和assetName来获取");
        return(res);
    }
コード例 #21
0
        public override AssetAsyncLoad LoadAssetAsync(string assetName, UnityAction <Object> loadedCallback, UnityAction <float> progressCallback, AssetLoadPriority priority = AssetLoadPriority.Normal)
        {
            var assetNode = LoadAsset(assetName, loadedCallback);

            if (assetNode == null)
            {
                return(m_AssetLoader.LoadAssetAsync(assetName, loadedCallback, progressCallback, priority));
            }
            return(null);
        }
コード例 #22
0
 public static ResNode GetAssetsAsync(AssetType t, IAsyncResLoadHandler callBack,
                                      string strParam, bool isGuid = false, System.Object userDataObj = null, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
 {
     return(GetAssetsAsync(t, callBack.ResLoadCallBack, strParam, isGuid, userDataObj, priority));
 }
コード例 #23
0
    /// <summary>
    /// 异步取得Prefab,返回值只是一个标示,没有资源,资源在回调中
    /// </summary>
    /// <param name="config">资源配置</param>
    /// <param name="callBack">回调</param>
    /// <param name="userDataObj">用户数据</param>
    private static ResNode GetPrefabAsync(UnionResConfigData config,
                                          System.Action <ResConfigData, ResNode, System.Object> callBack,
                                          System.Object userDataObj = null, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
    {
        if (!isVaild)
        {
            return(null);
        }
        ResNode reslut = null;

        config.priority = priority;
        //编辑器下无异步加载
        if (!isOnRunTimeMode)
        {
            reslut = GetPrefab(config);
            PushToResDelayCallBackList(reslut, config, callBack, userDataObj);
            return(reslut);
        }

        if (config.unionIndx < 0 || config.startIndex < 0 || config.dataLength <= 0)
        {
            Debug.LogWarning("confing is invalid:" + config.AssetName);
            return(null);
        }

        GetCommonRes(ref reslut, config);
        if (null != reslut)
        {
            PushToResDelayCallBackList(reslut, config, callBack, userDataObj);
            return(reslut);
        }
        int InstanceID = GUIDToInstanceID(config.AssetGUID);

        reslut = GetResNodeFromNeedToUnLoadAsset(InstanceID);
        if (null != reslut)//表里面有这个预制体的话,说明依赖已经加载完毕
        {
            reslut.AddRef();
            m_PrefabResTable.Add(InstanceID, reslut);

            GeneratePrefabCallBack(reslut, config, callBack, userDataObj);
            reslut.config = config;
            return(reslut);
        }


        reslut = GetCachePrefabResource(config);
        if (null != reslut)//表里面有这个预制体的话,说明依赖已经加载完毕
        {
            reslut.AddRef();
            m_PrefabResTable.Add(InstanceID, reslut);
            if (!reslut.isLoadFinish)
            {
                GeneratePrefabCallBack(reslut, config, callBack, userDataObj);
            }
            else
            {
                PushToResDelayCallBackList(reslut, config, callBack, userDataObj);
            }

            reslut.config = config;
            return(reslut);
        }

        //先看看表中是否有这个配置
        m_PrefabResTable.TryGetValue(InstanceID, out reslut);
        if (null == reslut)
        {
            m_AsyncLoadingDependicensPrefabResNode.TryGetValue(InstanceID, out reslut);
            if (null == reslut)
            {
                reslut           = AllocResNode(config.AssetGUID);
                reslut.config    = config;
                reslut.assetType = AssetType.Asset_Prefab;
                reslut.status    = ResNodeStatus.WatingForLoad;
                reslut.isAsync   = true;
                bool b = LoadDependenicesAsync(config);
                //依赖加载失败
                if (!b)
                {
                    reslut = null;
                    return(null);
                }
                m_AsyncLoadingDependicensPrefabResNode.Add(InstanceID, reslut);
            }
            reslut.AddRef();
            GeneratePrefabCallBack(reslut, config, callBack, userDataObj);
            reslut.config = config;
        }
        else
        {
            //再看看加载列表中是否有这个配置,有就等待回调
            if (m_PrefabRequestTable.ContainsKey(InstanceID))
            {
                reslut.AddRef();
                GeneratePrefabCallBack(reslut, config, callBack, userDataObj);
            }
            else
            {
                PushToResDelayCallBackList(reslut, config, callBack, userDataObj);
            }
            reslut.AddRef();
            reslut.config = config;
        }
        return(reslut);
    }
コード例 #24
0
 public abstract AssetAsyncLoad LoadAssetAsync(string assetName, UnityAction <Object> loadedCallback, UnityAction <float> progressCallback, AssetLoadPriority priority = AssetLoadPriority.Normal);
コード例 #25
0
    public static ResNode GetResNodeAsync(IResNodeHandle _handle, ResNodeHandleParamBase _param, IAsyncResLoadHandler callBack, System.Object userDataObj = null, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
    {
        if (_handle == null || _param == null)
        {
            return(null);
        }

        ResNode returnNode = null;

        #region 分类型
        if (_param is ResNodeHandleParam_Path)
        {
            ResNodeHandleParam_Path pathParam = _param as ResNodeHandleParam_Path;

            returnNode = GetAssetsAsync(_param.AssetType, callBack, pathParam.StrResPath, pathParam.IsGuid, userDataObj, priority);
        }
        else if (_param is ResNodeHandleParam_Bundle)
        {
            ResNodeHandleParam_Bundle bundleParam = _param as ResNodeHandleParam_Bundle;

            returnNode = GetAssetsAsync(_param.AssetType, bundleParam.StrBundleName, bundleParam.StrAssetName, callBack, userDataObj, priority);
        }
        else if (_param is ResNodeHandleParam_ResConfigData)
        {
            ResNodeHandleParam_ResConfigData resConfigData = _param as ResNodeHandleParam_ResConfigData;

            returnNode = GetAssetsAsync(_param.AssetType, resConfigData.ConfigData, callBack, userDataObj, priority);
        }
        #endregion

        if (returnNode != null)
        {
            if (m_dicResNodeHandle.ContainsKey(_handle))
            {
                m_dicResNodeHandle[_handle].Add(returnNode);
            }
            else
            {
                m_dicResNodeHandle.Add(_handle, new List <ResNode>()
                {
                    returnNode
                });
            }
        }

        return(returnNode);
    }
コード例 #26
0
ファイル: SkinManager_Async.cs プロジェクト: zwong91/Titan
    /// <summary>
    /// 异步取得Skin
    /// </summary>
    /// <param name="SkinID"></param>
    /// <param name="CallBack"></param>
    /// <returns></returns>
    private static bool GetSkinAsyncImpl(int SkinID, System.Action <Skin> CallBack, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
    {
        SkinModelInfo info = null;

        if (!m_SkinConfigMap.TryGetValue(SkinID, out info))
        {
            Debug.LogWarning("找不到皮肤配置,ID:" + SkinID);
            return(false);
        }
        Skin sk = null;
        SkinAsyncLoadingObj loadingObj = null;

        sk = GetSkinFromCache(SkinID);
        if (sk != null)
        {
            sk.AddRef();
            m_SkinMap.Add(sk.nSkinID, sk);

            if (m_AsyncLoadSkinRequestTable.TryGetValue(SkinID, out loadingObj))
            {
                loadingObj.callbackList.Add(CallBack);
            }
            else
            {
                loadingObj = new SkinAsyncLoadingObj();
                loadingObj.callbackList.Add(CallBack);
                m_AsyncLoadSkinRequestTable.Add(SkinID, loadingObj);
            }

            return(true);
        }


        if (m_SkinMap.TryGetValue(SkinID, out sk))
        {
            if (m_AsyncLoadSkinRequestTable.TryGetValue(SkinID, out loadingObj))
            {
                sk.AddRef();
                loadingObj.callbackList.Add(CallBack);
            }
            else
            {
                loadingObj = new SkinAsyncLoadingObj();
                loadingObj.callbackList.Add(CallBack);
                sk.AddRef();
                m_AsyncLoadSkinRequestTable.Add(SkinID, loadingObj);
            }
            return(true);
        }


        if (m_AsyncLoadSkinRequestTable.TryGetValue(SkinID, out loadingObj))
        {
            loadingObj.ReferenceCount++;
            loadingObj.callbackList.Add(CallBack);
        }
        else
        {
            ResNode obj = AssetBundleManager.GetAssetsAsync(AssetType.Asset_Prefab, ResLoadCallBack, info.strPatch, false, info, priority);
            if (obj != null)
            {
                loadingObj = new SkinAsyncLoadingObj();
                loadingObj.callbackList.Add(CallBack);
                loadingObj.ReferenceCount++;
                loadingObj.loadingResNode = obj;
                m_AsyncLoadSkinRequestTable.Add(SkinID, loadingObj);
            }
            else
            {
                Trace.Warning("加载皮肤模型失败,ID:" + info.nSkinID + ",路径:" + info.strPatch + ",请[--策划--]检查配置");
                return(false);
            }
        }
        return(true);
    }
コード例 #27
0
ファイル: USpriteManager.cs プロジェクト: zwong91/Titan
 /// <summary>
 /// 异步直接通过assetBundleName和AssetName获取资源节点
 /// </summary>
 /// <param name="strAssetBundleName"></param>
 /// <param name="strAssetName"></param>
 /// <param name="callBack"></param>
 /// <param name="userDataObj"></param>
 /// <param name="priority"></param>
 /// <returns></returns>
 public ResNode GetSpriteRes(string strAssetBundleName, string strAssetName,
                             System.Action <ResConfigData, ResNode, System.Object> callBack,
                             System.Object userDataObj, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
 {
     return(AssetBundleManager.GetAssetsAsync(AssetType.Asset_Sprite, strAssetBundleName, strAssetName, callBack, userDataObj, priority));
 }
コード例 #28
0
ファイル: USpriteManager.cs プロジェクト: zwong91/Titan
 /// <summary>
 /// 异步获取非模板ID Sprite
 /// <para>请自行调用USpriteManager.DeleteSprite()移除异步Sprite方法</para>
 /// </summary>
 /// <param name="_eType">图片类型</param>
 /// <param name="callBack">回调</param>
 /// <param name="userDataObj">用户数据,这个会出现在资源回调里</param>
 /// <param name="priority">加载优先级</param>
 /// <returns></returns>
 public Sprite GetSprite(ESpriteType _eType, string _strAssetName, out ResNode _resNodeData, System.Action <ResConfigData, ResNode, System.Object> callBack = null,
                         System.Object userDataObj = null, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal)
 {
     return(GetSprite(dicSpriteType[_eType].AssetBundleName(), _strAssetName, out _resNodeData,
                      callBack, userDataObj, priority));
 }
コード例 #29
0
ファイル: USpriteManager.cs プロジェクト: zwong91/Titan
 /// <summary>
 /// 异步获取带模板ID Sprite
 /// <para>请自行调用USpriteManager.DeleteSprite()移除异步Sprite方法</para>
 /// </summary>
 /// <param name="_eType">图片类型</param>
 /// <param name="callBack">回调</param>
 /// <param name="userDataObj">用户数据,这个会出现在资源回调里</param>
 /// <param name="priority">加载优先级</param>
 /// <param name="_nIDArray">模板ID顺序(A,B,C,...)</param>
 /// <returns></returns>
 public Sprite GetSprite(ESpriteType _eType, out ResNode _resNodeData, System.Action <ResConfigData, ResNode, System.Object> callBack = null,
                         System.Object userDataObj = null, AssetLoadPriority priority = AssetLoadPriority.Priority_Normal, params int[] _nIDArray)
 {
     return(GetSprite(dicSpriteType[_eType].AssetBundleName(_nIDArray),
                      dicSpriteType[_eType].AssetName(_nIDArray), out _resNodeData, callBack, userDataObj, priority));
 }
コード例 #30
0
 public void ResetPriority()
 {
     m_Priority = AssetLoadPriority.Priority_Normal;
 }