---
title: "UI在使用SpriteAtlas时的原理，以及打AB包的时候SpriteAtlas的“冗余”问题"
author: "石心.Yong"
published_by: "Perrin Yong"
canonical: https://www.pystone.net/notes/uwa-answer-sprite-atlas-asset-bundle-duplication/
type: note
content_role: source
source_type: "source"
visibility: public
id_stability: rename-stable
source_path: "10-计算机、信息技术与工程/05-游戏图形与运行时/我的UWA问答/2021-04-30 - UI在使用SpriteAtlas时的原理，以及打AB包的时候SpriteAtlas的“冗余”问题.md"
content_hash: 7410d34f0160e3ea154ed42b234e344fe10c4a80a59b2f8dc01b6db66e4f3971
knowledge_version: 224c990773de.5fa8af6e39fa
site_commit: 224c990773de166d23a886306577dd90379529ce
notes_commit: 5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a
---
# UI在使用SpriteAtlas时的原理，以及打AB包的时候SpriteAtlas的“冗余”问题

> **note · 我的 UWA 问答**
> 本文收录我在 UWA 问答发表的公开回答。问题内容归原提问者；回答保留当时语境，技术结论可能受 Unity 版本、平台和项目条件限制。

## 问题

我之前对SpriteAtlas的理解是，UI在渲染的时候会根据关联的Sprite信息找到对应的SpriteAtlas，这样每个UI渲染都用了同样的Atlas，这样可以减少DrawCall。

所以理论上来讲，应该只需要Atlas这一张图就好了。

可为什么我看到打Atlas的AB包里除了Atlas图还有引用的原图。在UI的AB包里，也有引用的原图。

请问为什么有这样的“冗余”，以及到底Image引用的是图集还是图片，原理是什么？

谢谢~

- 提问者：安日天
- 提问时间：2021-04-29 03:41:46

## 我的回答

不过确实存在一个冗余的问题：如果prefab1和prefab2引用了同一个atlas的sprite，那么这个atlas至少要主动包含在一个AB中，否则会被动打入两个包中，造成冗余。

atlas没有设置AB包：

![image.png](/media/48f056d272c28bec0990.png)

![image.png](/media/7f463aca6c1159b0fccb.png)

atlas打到其中一个AB包中：

![image.png](/media/cdc4ce2e336aea73976d.png)

![image.png](/media/ce038fe549a1bdf79a9f.png)

- 回答时间：2021-04-30 06:17:56
- 最后更新：2021-04-30 07:25:22
- 采纳状态：未采纳

## 来源与关系

- 上位集合：[我的 UWA 问答](https://www.pystone.net/notes/my-uwa-answers/)
- UWA 标签：资源管理、UI、UGUI
- 原始问题：[UI在使用SpriteAtlas时的原理，以及打AB包的时候SpriteAtlas的“冗余”问题](https://answer.uwa4d.com/question/608949fa6bb31032f9791494)
- 源页最后更新：2021-04-30 06:17:56
