Version: 2022.2
言語: 日本語
Image import settings
USS transform

9-Slice images with UI Toolkit

Generally, you can apply the 9-slice technique to a regular 2D Sprite. However, with UI Toolkit, you can apply the 9-slice technique to Texture, Render Texture, and SVG Vector images.

To apply the 9-slice technique to an image:

To apply the 9-slice technique to a selected image with USS:

  1. Open UI Builder.
  2. In the Background section in the Inspector, specify the Left, Right, Top, and Bottom slice values.
Slice options in UI Builder
Slice options in UI Builder

You can also specify the slice values directly in USS, UXML, or C# files for the following properties:

  • -unity-slice-left
  • -unity-slice-right
  • -unity-slice-top
  • -unity-slice-bottom
  • -unity-slice-scale

Important:

  • Slice values set with USS apply only to the image in the associated visual element. The values don’t apply to the same image used in other visual elements, in other UI documents, or in a scene.
  • Unset slice value is zero. For example, if you set the Top, Bottom, and Right slice attributes but leave the Left slice empty, the Left slice is zero.
  • Slice values set in USS override slice values set in the Sprite Editor. For the example above, no matter what value you added to the Left slice in the Sprite Editor, the Left slice value is zero.

その他の参考資料

Image import settings
USS transform
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961