Unity 提供了 2D 图元游戏对象,可帮助您快速制作项目原型,而无需导入您自己的资源。 要创建 2D 原始对象,请转到 **GameObject > 2D Object > Sprites ** 并选择以下选项之一:
大多数 2D 图元的默认精灵大小为 256 x 256 像素,每单位像素 (PPU) 大小为 256,这使得它们的大小等于场景中的一个单位。例外情况是胶囊图元,其大小为 256 x 512 像素(1:2 单位),以及等距菱形图元,其大小为 256 x 128 像素(1:0.5 单位)。
方形 2D 图元是一个白色正方形,大小为 1x1 Unity 单位。您可以将其用作各种元素的占位体,例如板条箱等障碍物,或快速创建平台。您可以将 Box Collider 2D 组件添加到该游戏对象,使其与其他游戏对象和 2D 物理交互。对于可动态调整大小的更具可扩展性的精灵,您可以选择 9-Sliced 选项。
圆形 2D 图元是一个直径为 1 Unity 单位的白色圆形。您可以将其用作场景中各种类型元素的占位体,例如障碍物或道具(如拾取物品或能量块)。您可以将 Circle Collider 2D 组件添加到该游戏对象,使其与其他对象和 2D 物理交互。
胶囊体2D 图元是一个白色的胶囊体,大小为 1x2 单位。您可以将此胶囊体用作场景中各种元素的占位体,例如障碍物、道具或角色的替身。您可以将 Capsule Collider 2D 组件添加到该游戏对象,使其与其他对象和 2D 物理交互。
等距菱形2D 图元是一个白色菱形精灵,大小为 1 x 0.5 个单位。此精灵旨在用作等距瓦片地图 的占位体。此精灵的顶部和底部的像素被略微裁剪,可改善平铺效果。
六边形平顶 2D 图元是一个正六边形,宽度为 1 个单位,其顶部和底部为边。它的作用是作为六边形平顶瓦片地图中瓦片的原始精灵占位体。此精灵的左侧和右侧的像素被略微裁剪,可改善平铺效果。
六边形尖顶 2D 图元是一个正六边形,高度为 1 个单位,其顶部和底部为尖。它的作用是作为六边形尖顶瓦片地图中瓦片的原始精灵占位体。此精灵的顶部和底部的像素被略微裁剪,可改善平铺效果。
九宫格 2D 图元是一个带圆角的白色正方形,大小为 1x1 单位。此精灵已切分为 9 片,边框的每边有 64 个像素。它用于精灵渲染器上的 Sliced 和 Tiled 绘制模式。您可以使用九宫格精灵作为场景和项目中各种元素的灵活占位体(有关更多信息,请参阅九宫格精灵)。您可以添加一个启用了 Auto Tiling 的 Box Collider 2D 使该精灵与其他对象和 2D 物理交互。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.