Exemple #1
0
        /// <summary>
        /// 读取配置
        /// </summary>
        /// <param name="data"></param>
        /// <param name="offset"></param>
        public void Read(byte[] data, ref int offset)
        {
            _cachedAssetInfos.Clear();
            _cachedAssetInfoMap.Clear();

            if (data == null)
            {
                return;
            }

            int dataLength = data.Length - offset;

            if (dataLength < 6)
            {
                return;
            }

            int storedDataLength = MemoryOperator.ReadInt(data, ref offset);

            if (storedDataLength < 6 || storedDataLength > dataLength)
            {
                return;
            }
            //
            int version = MemoryOperator.ReadShort(data, ref offset);

            if (version != Version)
            {
                return;
            }
            //信息数量
            int amount = MemoryOperator.ReadShort(data, ref offset);

            for (int i = 0; i < amount; i++)
            {
                NetAssetInfo info = new NetAssetInfo();
                info.Key       = MemoryOperator.ReadString(data, ref offset);
                info.AssetType = (NetAssetType)MemoryOperator.ReadShort(data, ref offset);
                if (info.AssetType == NetAssetType.Image)
                {
                    info.ImageWidth  = MemoryOperator.ReadShort(data, ref offset);
                    info.ImageHeight = MemoryOperator.ReadShort(data, ref offset);
                }
                //
                info.LastModifyTime = MemoryOperator.ReadDateTime(data, ref offset);
                //
                if (!_cachedAssetInfoMap.ContainsKey(info.Key))
                {
                    _cachedAssetInfoMap.Add(info.Key, info);
                    _cachedAssetInfos.Add(info);
                }
            }
            //排序
            _cachedAssetInfos.Sort();
        }
        public void Uninitialize()
        {
            StopAllCoroutines();

            _loadingResources.Clear();
            _loadingResources = null;
            _unbundledResources.Clear();
            _unbundledResources = null;
            _relatedResources.Clear();
            _relatedResources = null;
            _sInstance        = null;
        }
Exemple #3
0
 //反初始化
 public void UnInit()
 {
     if (m_kAudioList != null)
     {
         for (int i = 0; i < m_kAudioList.Count; i++)
         {
             Audio audio = m_kAudioList[i];
             audio.UnInit();
         }
         m_kAudioList.Clear();
         m_kAudioList = null;
     }
 }
        /// <summary>
        /// 反初始化
        /// </summary>
        public override void Uninitialize()
        {
            if (_forms != null)
            {
                //清理
                for (int i = 0; i < _forms.Count; i++)
                {
                    UIForm cur = _forms[i];
                    if (cur != null)
                    {
                        //转为关闭状态
                        if (cur.TurnToClosed(true))
                        {
                            cur.OnRemove();
                            _forms[i] = null;
                        }
                    }
                }
                _forms.Clear();
                _forms = null;
            }

            _formOpenOrder  = 1;
            _formSequence   = 0;
            sUGUIFrameCount = 0;
            if (_uiRoot != null)
            {
                GameObject.Destroy(_uiRoot);
                _uiRoot = null;
            }
            _formCamera         = null;
            _uiInputEventSystem = null;
        }
Exemple #5
0
 /// <summary>
 /// 清除菊花
 /// </summary>
 public void CleanWaiting()
 {
     _waitingKeyList.Clear();
     if (null != _waiting)
     {
         UIFormHelper.DisposeFormClass <UIWaiting>(ref _waiting);
         _waiting = null;
     }
 }
Exemple #6
0
 void OnDestroy()
 {
     EventHandler   = null;
     _isInitialized = false;
     if (_uiComponents != null)
     {
         _uiComponents.Clear();
         _uiComponents = null;
     }
     _fadeInAnimationCtr  = null;
     _fadeOutAnimationCtr = null;
     Controller           = null;
 }
Exemple #7
0
        //同步
        public void Update(float fCurrentTime)
        {
            m_kAudioTempList.Clear();

            for (int i = m_kAudioList.Count - 1; i >= 0; i--)
            {
                Audio audio = m_kAudioList[i];
                if (audio.IsFadeOutEnd)
                {
                    audio.Stop();
                    m_kAudioList.RemoveAt(i);
                    continue;
                }
                else
                {
                    if ((!audio.IsLoop) && (audio.EndTime < fCurrentTime))
                    {
                        audio.Stop();
                        m_kAudioList.RemoveAt(i);
                        continue;
                    }
                    else
                    {
                        m_kAudioTempList.Add(audio);
                    }
                }
            }

            m_kAudioList.Clear();
            //
            for (int i = 0; i < m_kAudioTempList.Count; i++)
            {
                Audio audio2 = m_kAudioTempList[i];
                m_kAudioList.Add(audio2);
            }

            for (int i = 0; i < m_kAudioList.Count; i++)
            {
                Audio audio3 = m_kAudioList[i];
                audio3.Update(fCurrentTime);
            }
        }
 /// <summary>
 /// 反初始化
 /// </summary>
 public void UnInitialize()
 {
     if (_eventData != null)
     {
         for (int i = 0; i < _eventData.Count; i++)
         {
             if (_eventData[i].ID > 0)
             {
                 JW.Common.Log.LogE("LuaEvent.Uninitialize error : event data is not empty");
                 _eventData[i].Destroy(null);
             }
         }
         _eventData.Clear();
         _eventData = null;
     }
     if (_eventDataCache != null)
     {
         _eventDataCache.Clear();
         _eventDataCache = null;
     }
     _onUIEvent = null;
 }
        /// <summary>
        /// 加载状态相关bundle
        /// </summary>
        /// <param name="resourceList">资源路径列表</param>
        /// <param name="complete">加载完成回调</param>
        /// <param name="progress">加载进度回调</param>
        /// <param name="loaded">单个bundle加载完成回调</param>
        /// <param name="singleSync">true:当只有一个bundle时,使用同步加载;否则使用并发异步加载</param>
        /// <returns></returns>
        public IEnumerator LoadBundle(JWObjList <string> resourceList, Action complete = null, BundleBatchLoadingDelegate progress = null, BundleLoadedOneDelegate loaded = null, bool singleSync = true)
        {
            bool record = loaded != null;

            // 剔除已有资源
            for (int i = 0; i < resourceList.Count;)
            {
                string path = resourceList[i];
                if (ResService.GetInstance().Exists(path))
                {
                    if (record)
                    {
                        _unbundledResources.Add(path);
                    }

                    resourceList.RemoveAt(i);
                    continue;
                }

                i++;
            }

            // bundle list
            JWObjList <BundlePackInfo> bundleList = GetBundlePackInfoListForResources(resourceList, record);

            // 异步返回,在处理完源数据之后避免resourceList被reset
            yield return(null);

            // 未打包资源
            if (_unbundledResources.Count > 0)
            {
                if (loaded != null)
                {
                    loaded(_unbundledResources, true);
                }

                _unbundledResources.Clear();
            }

            // load
            if (bundleList != null && bundleList.Count > 0)
            {
                if (singleSync && bundleList.Count == 1)
                {
                    // 只有一个bundle,使用同步加载方式
                    BundleService.GetInstance().LoadSync(bundleList[0]);

                    if (progress != null)
                    {
                        progress(1f);
                    }

                    if (loaded != null)
                    {
                        AssetBundle        bundle           = BundleService.GetInstance().GetBundle(bundleList[0].Path);
                        JWObjList <string> relatedResources = GetLoadedBundleResources(bundleList[0].Path);
                        if (relatedResources != null && relatedResources.Count > 0)
                        {
                            loaded(relatedResources, bundle != null);
                            relatedResources.Clear();
                        }

                        BundleService.GetInstance().Unload(bundleList[0]);
                    }

                    if (complete != null)
                    {
                        complete();
                    }
                }
                else
                {
                    // 多个bundle,使用并发加载
                    yield return(StartCoroutine(BundleService.GetInstance().BatchLoadAsync(bundleList, delegate()
                    {
                        if (complete != null)
                        {
                            complete();
                        }
                    }, progress, delegate(BundleRef bundle)
                    {
                        if (bundle != null)
                        {
                            if (loaded != null)
                            {
                                JWObjList <string> relatedResources = GetLoadedBundleResources(bundle.Path);
                                if (relatedResources != null && relatedResources.Count > 0)
                                {
                                    loaded(relatedResources, true);
                                    relatedResources.Clear();
                                }

                                BundleService.GetInstance().Unload(bundle.PackInfo);
                            }
                        }
                    }, delegate(BundlePackInfo pi, string error)
                    {
                        if (loaded != null)
                        {
                            JWObjList <string> relatedResources = GetLoadedBundleResources(pi.Path);
                            if (relatedResources != null && relatedResources.Count > 0)
                            {
                                //bool succ = (pi.IsNoBundle());

                                //loaded(relatedResources, succ);
                                //relatedResources.Clear();
                            }
                        }
                    })));
                }
            }
            else
            {
                if (complete != null)
                {
                    complete();
                }
            }
        }
Exemple #10
0
        private IEnumerator AsynchronousLoad_LoadAssetBundle(JWObjList <string> stringList, JWArrayList <AssetData> assetDataList)
        {
            while (true)
            {
                stringList.Clear();
                assetDataList.Clear();
                for (int i = 0; i < _data.Count;)
                {
                    AssetData data = _data[i];
                    if (data.Priority != _loadAssetBundlePriority)
                    {
                        ++i;
                        continue;
                    }

                    _data.RemoveAt(i);

                    if (_assetManager.GetCacheCount(data.Name) >= data.Count)
                    {
                        if (data.Callback != null)
                        {
                            assetDataList.Add(data);
                        }
                        continue;
                    }

                    LoadData loadData;
                    loadData.Data            = data;
                    loadData.LoadBundleState = LoadStateLoading;
                    loadData.Request         = null;

                    bool insert = false;
                    for (int j = _resourceRequesting.Count - 1; j >= 0; --j)
                    {
                        if (_resourceRequesting[j].Data.Priority <= data.Priority)
                        {
                            _resourceRequesting.Insert(j + 1, loadData);
                            insert = true;
                            break;
                        }
                    }

                    if (!insert)
                    {
                        _resourceRequesting.Insert(0, loadData);
                    }

                    stringList.Add(data.Filename);

                    if (_loadAssetBundlePriority >= LoadPriority.Preprocess)
                    {
                        break;
                    }
                }

                yield return(null);

                if (stringList.Count > 0)
                {
#if USE_PACK_RES
                    BundleMediator.GetInstance().LoadBundle(stringList, OnBundleLoadCompleted);
#else
                    OnBundleLoadCompleted(stringList, true);
#endif
                }

                yield return(null);

                for (int i = 0; i < assetDataList.Count; i++)
                {
                    AssetData data = assetDataList[i];
                    if (data.Callback != null)
                    {
                        data.Callback.OnLoadAssetCompleted(data.Name, AssetLoadResult.Success, null);
                        yield return(null);
                    }
                }

                yield return(InstructionEnd);
            }
        }