예제 #1
0
        public void CreateLoaderGroupNode(UnityEngine.Object target, string fileName,
                                          LoaderGroupSubNodeType type,
                                          System.Object param = null)
        {
            if (target == null || string.IsNullOrEmpty(fileName))
            {
                return;
            }

            var nodeType = GetLoaderGroupNodeType(type);

            if (nodeType == LoaderGroupNodeType.None)
            {
                return;
            }

            var             loadMap = this.LoadMap;
            LoaderGroupKey  key     = new LoaderGroupKey(fileName, nodeType);
            LoaderGroupNode node;

            if (loadMap.TryGetValue(key, out node))
            {
                node.AddSubNode(type, target, param);
                return;
            }

            LoaderGroupNode ret = CreateNodeByPool(fileName, nodeType);

            ret.AddSubNode(type, target, param);

            AddLoadNode(key, ret);
        }
예제 #2
0
        /*
         * private void ClearLoader(int instanceId, LoaderGroupSubNodeType subType) {
         * if (m_LoadList == null || m_LoadMap == null)
         * return;
         * var loader = this.Loader;
         * if (loader == null)
         * return;
         * var node = m_LoadList.First;
         * while (node != null) {
         * var next = node.Next;
         * var n = node.Value;
         * if (n != null && n.ClearLoader(instanceId, loader, subType)) {
         *  m_LoadList.Remove(node);
         *  LoaderGroupKey key = new LoaderGroupKey(n.FileName, n.Type);
         *  m_LoadMap.Remove(key);
         *  DestroyNodeByPool(n);
         * }
         * node = next;
         * }
         * }
         */

        public void LoadAll(int instanceId, LoaderGroupSubNodeType subType)
        {
            if (m_LoadList == null || m_LoadMap == null)
            {
                return;
            }
            var loader = this.Loader;

            if (loader == null)
            {
                return;
            }
            var node = m_LoadList.First;

            while (node != null)
            {
                var next = node.Next;
                var n    = node.Value;
                if (n != null && n.LoadAll(instanceId, loader, subType))
                {
                    if (n.LoadCount <= 0)
                    {
                        m_LoadList.Remove(node);
                        LoaderGroupKey key = new LoaderGroupKey(n.FileName, n.Type);
                        m_LoadMap.Remove(key);
                        DestroyNodeByPool(n);
                    }
                }
                node = next;
            }
        }
예제 #3
0
        private void AddLoadNode(LoaderGroupKey key, LoaderGroupNode node)
        {
            if (node == null)
            {
                return;
            }

            var loadList = this.LoadList;
            var loadMap  = this.LoadMap;

            var checkNode    = loadList.First;
            var currentDepth = node.GetFirstDepth();

            while (checkNode != null)
            {
                var checkDepth = checkNode.Value.GetFirstDepth();
                if (currentDepth < checkDepth)
                {
                    break;
                }
                checkNode = checkNode.Next;
            }

            if (checkNode != null)
            {
                loadList.AddBefore(checkNode, node.LinkListNode);
            }
            else
            {
                loadList.AddLast(node.LinkListNode);
            }

            loadMap.Add(key, node);
        }
예제 #4
0
        // 更新加载
        protected virtual void Update()
        {
            if (m_LoadList == null)
            {
                return;
            }
            var loader = this.Loader;

            if (loader == null)
            {
                return;
            }

            var first  = m_LoadList.First;
            int curCnt = 1;

            while (first != null)
            {
                if (curCnt > m_MaxLoadCount)
                {
                    break;
                }

                var node = first.Value;
                if (node != null)
                {
                    node.Load(loader);
                }
                LoaderGroupKey key = new LoaderGroupKey(node.FileName, node.Type);
                m_LoadMap.Remove(key);
                m_LoadList.RemoveFirst();
                DestroyNodeByPool(node);

                first = m_LoadList.First;
                ++curCnt;
            }
        }