Пример #1
0
        public bool RemoveAtlas(UIAtlasType t)
        {
            int aid = (int)t;

            if (mGlobalAtlasTexName.Contains(aid))
            {
                return(false);
            }
            if (!mAtlasRefCounts.ContainsKey(aid))
            {
                Debug.LogError("尝试检索不存在的图包[" + t.ToString() + "]的引用计数");
                return(false);
            }
            if (--mAtlasRefCounts[aid] <= 0)
            {
                if (!mAtlasList.ContainsKey(aid))
                {
                    Debug.LogError("尝试移除不存在的图包:" + t.ToString());
                    return(false);
                }
                UIAtlas atlas = mAtlasList[aid].Bgein;
                DestroyImmediate(atlas.texture, true);
                Resources.UnloadAsset(atlas.texture);
                atlas.spriteMaterial.mainTexture = null;
                mAtlasRefCounts.Remove(aid);
                //LogSys.Debug("成功移除UI图包:" + atlasList[i]);
            }
            return(true);
        }
Пример #2
0
        bool DoAddImageAnim(string p, string n, string m, int fps)
        {
            if (NextTextIsNotShow)
            {
                return(true);
            }
            if (行数限制 > 0 && mNowLineCount >= 行数限制)
            {
                return(true);
            }
            UIAtlasType at = UIAtlasType.max;

            for (UIAtlasType i = UIAtlasType.公用数字图包1; i < UIAtlasType.max; ++i)
            {
                if (p == i.ToString())
                {
                    at = i;
                    break;
                }
            }
            if (at < UIAtlasType.公用数字图包1 || at >= UIAtlasType.max)
            {
                return(false);
            }
            //Color color = mFontColorTagStack.Peek();
            UISprite sp = UIViewHelper.AddUISprite(底板.gameObject, at, n + m, null);

            if (null == sp)
            {
                return(false);
            }
            float canUseSpace = CalcNowLineCanUsedSpace();

            if (sp.width > canUseSpace)
            {
                Destroy(sp.gameObject);
                if (DoChangeLine())
                {
                    DoAddImageAnim(p, n, m, fps);
                }
                return(true);
            }
            int depth = 0;

            if (!mHasedAtlas.Contains(at))
            {
                mHasedAtlas.Add(at);
                depth = mHasedAtlas.Count - 1;
            }
            else
            {
                depth = mHasedAtlas.IndexOf(at);
            }
            UISpriteAnimation spanim = sp.gameObject.AddComponent <UISpriteAnimation>();

            spanim.namePrefix      = n;
            spanim.framesPerSecond = fps;
            sp.depth = 层级 + depth;
//			if(sp is UISprite)
//				(sp as UISprite).OnAtlasLoadOvered0 += new UISpriteEx.EventHandler0(spanim.RebuildSpriteList);
            OnUnitAddBefore();
            Vector3 pos = new Vector3(mNowWritePos.x - (视图尺寸.x - (float)sp.width) * 0.5f, mNowWritePos.y - sp.height * 0.5f);

            sp.transform.localPosition = pos;
            OnUnitAdded(sp);
            return(true);
        }
Пример #3
0
        bool DoAddImage(string p, string n)
        {
            if (NextTextIsNotShow)
            {
                return(true);
            }
            if (行数限制 > 0 && mNowLineCount >= 行数限制)
            {
                return(true);
            }
            UIAtlasType at = UIAtlasType.max;

            for (UIAtlasType i = UIAtlasType.公用数字图包1; i < UIAtlasType.max; ++i)
            {
                if (p == i.ToString())
                {
                    at = i;
                    break;
                }
            }
            if (at < UIAtlasType.公用数字图包1 || at >= UIAtlasType.max)
            {
                return(false);
            }
            //Color color = mFontColorTagStack.Peek();
            UISprite sp = UIViewHelper.AddUISprite(底板.gameObject, at, n, null);

            if (null == sp)
            {
                return(false);
            }
            float canUseSpace = CalcNowLineCanUsedSpace();

            if (sp.width > canUseSpace)
            {
                Destroy(sp.gameObject);
                if (DoChangeLine())
                {
                    DoAddImage(p, n);
                }
                return(true);
            }
            int depth = 0;

            if (!mHasedAtlas.Contains(at))
            {
                mHasedAtlas.Add(at);
                depth = mHasedAtlas.Count - 1;
            }
            else
            {
                depth = mHasedAtlas.IndexOf(at);
            }
            float size_w = mTransSizeWStack.Peek();
            float size_h = mTransSizeHStack.Peek();
            bool  sliced = false;

            if (size_w > 0)
            {
                sp.width = (int)size_w;
                sliced   = true;
            }
            if (size_h > 0)
            {
                sp.height = (int)size_h;
                sliced    = true;
            }
            if (sliced)
            {
                sp.type = UISprite.Type.Sliced;
            }
            else
            {
                sp.MakePixelPerfect();
            }
            sp.depth = 层级 + depth;
            OnUnitAddBefore();
            Vector3 pos = new Vector3(mNowWritePos.x - (视图尺寸.x - (float)sp.width) * 0.5f, mNowWritePos.y - sp.height * 0.5f);

            sp.transform.localPosition = pos;
            OnUnitAdded(sp);
            return(true);
        }