N-Slice Data Assignment

How to assign and manage N-Slice data in NSliceSpriteRenderer

N-Slice Data Assignment

The NSliceSpriteRenderer component requires N-Slice data to render sprites using the 9-slice method. This page explains how to assign and manage N-Slice data.

N-Slice Data Field

When No Data is Assigned

When no N-Slice Data is assigned, the inspector displays the following guidance messages:

  • Warning Message: "Please assign a N-Slice Data asset to use N-slicing features."
  • Info Message: "Click the 'Create New' button to create a new N-Slice Data asset."
  • Create New Button: Allows you to instantly create a new N-Slice Data asset.

Assigning Data

Methods to assign N-Slice Data:

  1. Use Existing Data: Click the object selector of the N-Slice Data field to select an existing N-Slice Data asset from your project.
  2. Create New Data: Click the Create New button to generate a new N-Slice Data asset.
  3. Drag and Drop: Directly drag an N-Slice Data asset from the Project window to the field.

After Data Assignment

Once N-Slice Data is assigned, the following information is displayed:

  • N-Slice Info: Shows "N-Slice: [rows] rows x [columns] columns" (e.g., "N-Slice: 7 rows x 9 columns")
  • Source Sprite: A thumbnail of the original sprite is displayed.
  • Available N-Slice Data: A dropdown list of all available N-Slice Data assets in the project for easy switching.

Data Management Buttons

  • Edit: Opens the settings for the selected N-Slice Data for editing.
  • Create New: Creates a new N-Slice Data asset.
  • Delete: Deletes the currently selected N-Slice Data asset (Warning: This action cannot be undone).

Important Notes

  • N-Slice Data are ScriptableObject assets stored in your project.
  • A single N-Slice Data can be shared across multiple NSliceSpriteRenderers.
  • It's recommended to give N-Slice Data assets meaningful names (e.g., "Button_NSliceData", "Panel_NSliceData").