public void Init(int width, int height, bool allowFlip, bool isTransparent, string atlasName) { mMaxRectsBinPack = new MaxRectsBinPack(width, height, allowFlip); Width = width; Height = height; AllowFlip = allowFlip; IsTransparent = isTransparent; AtlasPath = GetAtlasPath(isTransparent, atlasName); AssetPath = GetAssetPath(isTransparent, atlasName); }
/// <summary> /// 在TextureAtlas从Asset实例化出来时,MaxRectsBinPack里面的数据是空的,这时把ElementList中的数据反排布到MaxRectsBinPack中 /// </summary> public void Layout() { mMaxRectsBinPack = new MaxRectsBinPack(Width, Height, AllowFlip); for (int i = ElementList.Count - 1; i >= 0; --i) { TextureAtlasElement element = ElementList[i]; if (null != element && null != element.Tex) { mMaxRectsBinPack.Layout((int)element.Offset.x, (int)element.Offset.y, element.Size.x, element.Size.y); } else { ElementList.RemoveAt(i); } } bDirty = true; }