Home > other >  Can code division elves, polygon segmentation??
Can code division elves, polygon segmentation??

Time:09-27

The following code to the dynamic segmentation elves, can only be divided into rectangle, don't know can be divided into polygon?
SpriteRenderer SpriteRenderer=spriteToCrop. GetComponent (a);
Sprite spriteToCropSprite=spriteRenderer. Sprite;
Texture2D spriteTexture=spriteToCropSprite. Texture;
for(int i=0; i <8; I++)
{
For (int j=0; J & lt; 8; J++)
{
Sprite newSprite=Sprite. The Create (spriteTexture, new the Rect (I * 64, j * 64, 64, 64), the new Vector2 (0.5 f to 0.5 f));
GameObject n=new GameObject ();
SpriteRenderer sr=n.a. ddComponent (a);
The sr. Sprite=newSprite;
N.t ransform. Position=new Vector3 (I * 2, j * 2, 0).
N.t ransform. Parent=spriteToCrop. Transform;
}

CodePudding user response:


Do more than the game will use dynamic partitioning polygon Sprite, please directly!
  • Related