Sprite Shape Renderer 组件用于渲染 Unity 沿着样条图生成的几何体,并控制该几何体在 2D 和 3D 项目场景中的可视化效果。该组件的输入来自 Sprite Shape Profile。
属性 | 功能 |
---|---|
Color | 定义精灵形状几何体的顶点颜色,通过该颜色对精灵形状进行着色或重新着色。使用拾色器来设置顶点颜色。请参阅此表下方的颜色部分以查看示例。 |
Mask Interaction | 设置精灵渲染器在与精灵遮罩交互时的行为方式。请参阅下面的 Mask Interaction 部分中不同选项的示例。 |
None | Sprite Shape Renderer 不与场景中的任何精灵遮罩交互。这是默认选项。 |
Visible Inside Mask | 精灵形状在精灵遮罩覆盖精灵的地方是可见的,而在遮罩外部不可见。 |
Visible Outside Mask | 精灵形状在精灵遮罩外部是可见的,而在遮罩内部不可见。精灵遮罩会隐藏其覆盖的精灵形状部分。 |
Sorting Layer | 设置精灵形状几何体的排序图层 (Sorting Layer),此图层用于控制渲染期间的几何体优先级。从下拉框中选择现有的排序图层,或创建新的排序图层。 |
Order In Layer | 设置精灵形状在其排序图层中的渲染优先级。首先渲染编号较低的精灵形状,编号较高的精灵形状叠加在前者之上。 |
以下示例显示了在 Sprite Shape Renderer 的 Color 设置中更改 RGB 值的效果。要更改精灵形状的不透明度,请更改 Alpha (A) 通道的值:较低的值会使精灵看起来更透明,而较高的值会使精灵看起来更不透明。
使用材质的材质和着色器设置可控制 Unity 如何渲染填充几何体和边缘几何体。新精灵形状的默认材质为“Sprites - Default”。场景光照不会影响此默认精灵形状。要让精灵对光照做出反应,请指定材质“Default - Diffuse”。要执行此操作,请单击 Material 字段旁边的小圆圈以显示 Object Picker 窗口,然后选择“Default-Diffuse”材质。请参阅材质、着色器和纹理以了解有关这些设置的更多信息。
Mask Interaction 可控制 Sprite Shape Renderer 与精灵遮罩交互的方式。从 Mask Interaction 下拉菜单中选择 Visible Inside Mask 或 Visible Outside Mask。以下示例显示了这两个选项的效果:
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.