Beispiel #1
0
        /// <summary>
        /// 获取Loader
        /// </summary>
        /// <param name="hash"></param>
        /// <returns></returns>
        public static ABLoader GetLoader(uint hash, ABLoadContext _loadContext)
        {
            //如果已经存在Laoder则返回loader
            if (_loadContext.loadingLoaderDict.ContainsKey(hash))
            {
                return(_loadContext.loadingLoaderDict[hash]);
            }

            ABData data = _loadContext.dataHelper.GetABData(hash);

            if (data == null)
            {
                ReDebug.LogError(ReLogType.System, "ABManager",
                                 string.Format("ABData is null, abName={0}", hash));
                return(null);
            }

            //创建Loader并且加入表中
            ABLoader loader = ReusableObjectPool <ABLoader> .Get();

            loader.abName = data.fullName;
            loader.abData = data;
            _loadContext.loadingLoaderDict[hash] = loader;
            loader._loadContext = _loadContext;

            return(loader);
        }
Beispiel #2
0
        /// <summary>
        /// 同步加载Bundle
        /// </summary>
        /// <param name="hash"></param>
        /// <param name="location"></param>
        /// <param name="suffix"></param>
        /// <returns></returns>
        public ABObject LoadSync(uint hash, string location, string suffix)
        {
            //从缓存中寻找
            ABObject abObject = _loadContext.FindABObjectCache(hash);

            if (abObject != null)
            {
                return(abObject);
            }

            var loader = ABLoader.GetLoader(hash, _loadContext);

            #region 异常情况处理
            if (loader == null)
            {
                ReDebug.LogError(ReLogType.System, "ABManager", string.Format("Cannot create ABLoader, location={0}{1}, name={2}", location, suffix, hash));
                return(null);
            }

            //如果已经加载完成
            if (loader.isComplete)
            {
                ReDebug.LogError(ReLogType.System, "ABManager", String.Format("Cannot be here, name={0}", hash));
                return(loader.abObject);
            }
            #endregion 异常情况处理

            loader.Load(true);

            return(loader.abObject);
        }
        /// <summary>
        /// 添加新的GUI子对象
        /// </summary>
        /// <param name="parent">Bahavior.</param>
        public void SetParent(EditorWindowRect parent)
        {
            if (parent == this)
            {
                ReDebug.LogError(ReLogType.System, "EditorWIndowBehavior", "不能将自己作为自己的子对象");
                return;
            }

            if (this is EditorWindowPanel && !(parent is EditorWindowPanel))
            {
                ReDebug.LogError(ReLogType.System, "EditorWIndowBehavior", "Panel只能放入Panel下");
                return;
            }

            if (this.parent == parent)
            {
                return;
            }

            if (this.parent != null)
            {
                this.parent.behaviorList.Remove(this);
            }

            this.parent = parent;
            if (this.parent != null)
            {
                this.parent.behaviorList.Add(this);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 异步加载Bundle
        /// </summary>
        /// <param name="hash"></param>
        /// <param name="location"></param>
        /// <param name="suffix"></param>
        /// <param name="callBack"></param>
        public void LoadAsync(uint hash, string location, string suffix, Action <ABObject> callBack = null)
        {
            //从缓存中寻找
            ABObject abObject = _loadContext.FindABObjectCache(hash);

            if (abObject != null)
            {
                if (callBack != null)
                {
                    callBack(abObject);
                }
                return;
            }

            var loader = ABLoader.GetLoader(hash, _loadContext);

            #region 异常情况处理
            if (loader == null)
            {
                ReDebug.LogError(ReLogType.System, "ABManager", string.Format("Cannot create ABLoader, location={0}{1}, name={2}", location, suffix, hash));

                if (callBack != null)
                {
                    callBack(null);
                }

                return;
            }

            //如果已经加载完成
            if (loader.isComplete)
            {
                ReDebug.LogError(ReLogType.System, "ABManager", String.Format("Cannot be here, name={0}", hash));
                if (callBack != null)
                {
                    callBack(loader.abObject);
                }

                return;
            }
            #endregion 异常情况处理

            loader.Load(false, callBack);
        }
Beispiel #5
0
 /// <summary>
 /// 当加载失败时
 /// </summary>
 private void OnError()
 {
     ReDebug.LogError(ReLogType.System, "ABLoader", string.Format("load fail abName = {0}", abData.debugName));
 }