示例#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);
        }
        /// <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);
            }
        }
示例#3
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);
        }
示例#4
0
 /// <summary>
 /// 从路径中读取
 /// </summary>
 /// <param name="filePath"></param>
 public void readFromPath(string filePath)
 {
     using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
     {
         if (fs.Length > 4)
         {
             BinaryReader br = new BinaryReader(fs);
             if (br.ReadChar() == 'A' && br.ReadChar() == 'B' && br.ReadChar() == 'D')
             {
                 if (br.ReadChar() == 'T')
                 {
                     fs.Position = 0;
                     Read(fs, false);
                 }
                 else
                 {
                     fs.Position = 0;
                     Read(fs, true);
                 }
             }
             br.Close();
         }
         fs.Close();
         ReDebug.Log(ReLogType.System, "ABDataHelper", string.Format("Init dependency info success, file=", filePath));
     }
 }
示例#5
0
 public void UnloadBundle()
 {
     if (_bundle != null)
     {
         ReDebug.Log(ReLogType.System, "ABObject", "Unload : " + abData.compositeType + " >> " + abName + "(" + abData.debugName + ")");
         _bundle.Unload(false);
     }
     _bundle = null;
 }
示例#6
0
        public void Init()
        {
            string localPath = ABPathResolver.GetBundleSourceFile(ABPathResolver.DEPEND_FILE_NAME, false);
            string cachePath = string.Format("{0}/{1}", ABPathResolver.BundleCacheDir, ABPathResolver.DEPEND_FILE_NAME);

            ReDebug.Log(ReLogType.System, "ABDataHelper", "######## " + localPath);

            if (File.Exists(localPath))
            {
                readFromPath(localPath);
            }
            else if (File.Exists(cachePath))
            {
                readFromPath(cachePath);
            }
        }
示例#7
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);
        }
示例#8
0
 /// <summary>
 /// 当加载失败时
 /// </summary>
 private void OnError()
 {
     ReDebug.LogError(ReLogType.System, "ABLoader", string.Format("load fail abName = {0}", abData.debugName));
 }