예제 #1
0
 private static void DestroySubNodeByPool(LoaderGroupSubNode node)
 {
     if (node == null)
     {
         return;
     }
     node.Reset();
     InitPool();
     m_SubNodePool.Store(node);
 }
예제 #2
0
        public void AddSubNode(LoaderGroupSubNodeType type, UnityEngine.Object target, System.Object param)
        {
            if (m_SubNodeList == null)
            {
                m_SubNodeList = new LinkedList <LoaderGroupSubNode>();
            }

            // 防止重复加入
            if (IsFind(type, target))
            {
                return;
            }

            LoaderGroupSubNode subNode = CreateSubNodeByPool(type, target, param);

            m_SubNodeList.AddLast(subNode.LinkNode);
        }
예제 #3
0
        // 加载
        protected virtual void DoLoad(BaseResLoader loader, LoaderGroupSubNode node)
        {
            if (DoNGUILoad(loader, node))
            {
                return;
            }

            if (loader == null || node == null || !node.IsVaild)
            {
                return;
            }
            string fileName = this.FileName;

            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }

            switch (node.type)
            {
            case LoaderGroupSubNodeType.SpriteRenderer_Material:
                var sp1 = node.spriteRenderer;
                if (sp1 == null)
                {
                    return;
                }
                loader.LoadMaterial(sp1, fileName);
                break;

            case LoaderGroupSubNodeType.SpriteRenderer_SpriteData:
                var sp2 = node.spriteRenderer;
                if (sp2 == null)
                {
                    return;
                }
                string spriteName = node.Param as string;
                if (string.IsNullOrEmpty(spriteName))
                {
                    loader.LoadSprite(sp2, fileName);
                }
                else
                {
                    loader.LoadSprite(sp2, fileName, spriteName);
                }
                break;

            case LoaderGroupSubNodeType.MeshRenderer_Material:
                var mr1 = node.meshRenderer;
                if (mr1 == null)
                {
                    return;
                }
                loader.LoadMaterial(mr1, fileName);
                break;

            case LoaderGroupSubNodeType.MeshRenderer_MainTexture:
                var mr2 = node.meshRenderer;
                if (mr2 == null)
                {
                    return;
                }
                loader.LoadMainTexture(mr2, fileName);
                break;

            case LoaderGroupSubNodeType.MeshRenderer_Texture:
                var mr3 = node.meshRenderer;
                if (mr3 == null)
                {
                    return;
                }
                string matName = node.Param as string;
                if (!string.IsNullOrEmpty(matName))
                {
                    loader.LoadTexture(mr3, fileName, matName);
                }
                break;

            case LoaderGroupSubNodeType.TextMesh_Font:
                var tM1 = node.textMesh;
                if (tM1 == null)
                {
                    return;
                }
                loader.LoadFont(tM1, fileName);
                break;
            }
        }
예제 #4
0
        protected bool DoNGUILoad(BaseResLoader loader, LoaderGroupSubNode node)
        {
            if (loader == null || node == null || !node.IsVaild)
            {
                return(false);
            }

            string fileName = this.FileName;

            if (string.IsNullOrEmpty(fileName))
            {
                return(false);
            }

            var nguiLoader = loader as NGUIResLoader;

            if (nguiLoader == null)
            {
                return(false);
            }

            bool ret = true;
            LoaderGroupSubNodeType type = node.type;

            switch (type)
            {
            case LoaderGroupSubNodeType.UITexture_MainTexture:
                var t1 = node.uiTexture;
                if (t1 == null)
                {
                    return(true);
                }
                nguiLoader.LoadMainTexture(t1, fileName);
                break;

            case LoaderGroupSubNodeType.UITexture_Material:
                var t2 = node.uiTexture;
                if (t2 == null)
                {
                    return(true);
                }
                nguiLoader.LoadMaterial(t2, fileName);
                break;

            case LoaderGroupSubNodeType.UITexture_Texture:
                var t3 = node.uiTexture;
                if (t3 == null)
                {
                    return(true);
                }
                string matName = node.Param as string;
                if (string.IsNullOrEmpty(matName))
                {
                    return(true);
                }
                nguiLoader.LoadTexture(t3, fileName, matName);
                break;

            case LoaderGroupSubNodeType.UISprite_Atals:
                var sp1 = node.uiSprite;
                if (sp1 == null)
                {
                    return(true);
                }
                if (nguiLoader.LoadAltas(sp1, fileName))
                {
                    /*
                     * string spriteName = this.Param as string;
                     * if (!string.IsNullOrEmpty(spriteName))
                     *  sp1.spriteName = spriteName;
                     */
                    // 判断是否有SpriteAnimation
                    RefreshSpriteAnimiate(sp1);
                }
                break;

            case LoaderGroupSubNodeType.UISprite_Material:
                var sp2 = node.uiSprite;
                if (sp2 == null)
                {
                    return(true);
                }
                nguiLoader.LoadMaterial(sp2, fileName);
                break;

            case LoaderGroupSubNodeType.UISprite_MainTexture:
                var sp3 = node.uiSprite;
                if (sp3 == null)
                {
                    return(true);
                }
                nguiLoader.LoadMainTexture(sp3, fileName);
                break;

            case LoaderGroupSubNodeType.UI2DSprite_MainTexture:
                var sp4 = node.ui2DSprite;
                if (sp4 == null)
                {
                    return(true);
                }
                nguiLoader.LoadMainTexture(sp4, fileName);
                break;

            case LoaderGroupSubNodeType.UI2DSprite_SpriteData:
                var sp5 = node.ui2DSprite;
                if (sp5 == null)
                {
                    return(true);
                }
                string spName1 = node.Param as string;
                if (!string.IsNullOrEmpty(spName1))
                {
                    nguiLoader.LoadSprite(sp5, fileName, spName1);
                }
                break;

            case LoaderGroupSubNodeType.UI2DSprite_Material:
                var sp6 = node.ui2DSprite;
                if (sp6 == null)
                {
                    return(true);
                }
                nguiLoader.LoadMaterial(sp6, fileName);
                break;

            default:
                ret = false;
                break;
            }
            return(ret);
        }