Ejemplo n.º 1
0
        /// <summary>
        /// 更新子贴图内容.
        /// </summary>
        public void UpdateSubTexture(SubTextureAgent agent, Texture subTexture, Action onSuccess)
        {
            if (agent == null || agent.textureAtlas != this)
            {
                Debug.LogWarning("UpdateSubTexture参数错误!");
                return;
            }

            TextureUtil.DrawTexture(subTexture, texture, agent.position);
            onSuccess?.Invoke();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 生成新的子贴图.
        /// </summary>
        public void NewSubTexture(SubTextureAgent agent, Texture subtexture, int width, int height, Action <TextureAtlas, RectInt> onSuccess)
        {
            if (agent == null || subtexture == null)
            {
                Debug.LogWarning("NewSubTexture参数错误!");
                return;
            }

            // 分配空间
            var rect = packer.Insert(width, height);

            if (rect.x < 0)
            {
                return;
            }

            // 将子贴图内容复制到图集贴图
            TextureUtil.DrawTexture(subtexture, texture, rect);

            // 回调
            onSuccess?.Invoke(this, rect);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 销毁子贴图
 /// </summary>
 public void ReleaseSubTexture(SubTextureAgent agent)
 {
     packer.Remove(agent.position);
 }
 /// <summary>
 /// 为图集生成新的子贴图.
 /// </summary>
 public void NewSubTexture(SubTextureAgent agent, Texture texture, int width, int height, Action <TextureAtlas, RectInt> onSuccess)
 {
     textureAtlas.NewSubTexture(agent, texture, width, height, onSuccess);
 }