|
Method
public NineSlice(Rect2i topLeftCornerRect, Rect2i topSideRect, Rect2i topRightCornerRect, Rect2i leftSideRect, Rect2i middleRect, Rect2i rightSideRect, Rect2i bottomLeftCornerRect, Rect2i bottomSideRect, Rect2i bottomRightCornerRect)
|
public NineSlice(Rect2i topLeftCornerRect, Rect2i topSideRect, Rect2i middleRect)
|
public NineSlice(PackedSpriteID topLeftCornerID, PackedSpriteID topSideID, PackedSpriteID topRightCornerID, PackedSpriteID leftSideID, PackedSpriteID middleID, PackedSpriteID rightSideID, PackedSpriteID bottomLeftCornerID, PackedSpriteID bottomSideID, PackedSpriteID bottomRightCornerID)
|
public NineSlice(PackedSpriteID topLeftCornerID, PackedSpriteID topSideID, PackedSpriteID middleID)
|
public NineSlice(PackedSprite topLeftCorner, PackedSprite topSide, PackedSprite topRightCorner, PackedSprite leftSide, PackedSprite middle, PackedSprite rightSide, PackedSprite bottomLeftCorner, PackedSprite bottomSide, PackedSprite bottomRightCorner)
|
public NineSlice(PackedSprite topLeftCorner, PackedSprite topSide, PackedSprite middle)
|
public NineSlice(string topLeftCornerName, string topSideName, string topRightCornerName, string leftSideName, string middleName, string rightSideName, string bottomLeftCornerName, string bottomSideName, string bottomRightCornerName)
|
public NineSlice(string topLeftCornerName, string topSideName, string middleName)
|
public NineSlice(FastString topLeftCornerName, FastString topSideName, FastString topRightCornerName, FastString leftSideName, FastString middleName, FastString rightSideName, FastString bottomLeftCornerName, FastString bottomSideName, FastString bottomRightCornerName)
|
public NineSlice(FastString topLeftCornerName, FastString topSideName, FastString middleName)
|
Parameters
Returns
Nothing.
Description
Creates a new NineSlice image definition. A nine-slice sprite is a special kind of sprite usually used to draw rectangular shapes for UI elements. A nine-slice sprite is defined by up to 9 separate sprites that are arranged and repeated as needed in such a way that they can fill any rectangular area.
Nine parts that make up a nine slice image
The pieces A, C, G, and I are always drawn in the corners of the nine-slice sprite. B and H are repeated horizontally. E and F are repeated vertically. Finally, X is repeated in both directions to fill the middle of the nine-slice sprite.
For best results each of these groups of pieces should be the same height:
These groups should be the same width:
The center piece X can be of any size.
The pieces that make up a nine-slice image should not be too small to limit the amount of times they have to be repeated to fill your nine-slice sprite.
In some cases, such as in the image above, many of the pieces are symmetric, for convenience there are NineSlice.NineSlice overloads that take only srcTopLeftCornerRect, srcTopSideRect, and srcMiddleRect and simply rotate and mirror the remaining pieces automatically.
You can specify the pieces of a nine-slice image through either source rectangles, or sprite ids for sprites in a sprite pack.
Example
SpriteSheetAsset
uiSprites = new SpriteSheetAsset(); NineSlice dialogFrame;
void Initialize() { uiSprites.Load("spritesheets/ui"); dialogFrame = new NineSlice( new Rect2i(0, 0, 8, 8), new Rect2i(8, 0, 8, 8), new Rect2i(16, 0, 8, 8)); }
void Render() { RB.SpriteSheetSet(uiSprites);
var dialogRect = new Rect2i(100, 100, 128, 64);
RB.DrawNineSlice(dialogRect, dialogFrame); RB.Print( dialogRect, Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, "It's boring to go alone, take me!"); } |
See Also
RB.DrawNineSlice
RB.SpriteSheetSet
SpriteSheetAsset
See Docs
Features - Nine-Slice Sprite
Features - Sprite Sheets
Features - Sprite Packs
|