public static MaterialItem CreateFromTemplate( string name, Vector2Int size, Vector2[] shape, Texture2D baseTexture, Vector2Int baseStart) { bool[,] shapeMask = MaterialShape.PolygonFillMask(size.y, size.x, shape, true); Texture2D texture = MaterialTexture.CreateTextureFromMask(shapeMask, baseTexture, baseStart); return(new MaterialItem(name, Sprite.Create( texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)))); }
public void UpdateSprite() { bool[,] shapeMask = MaterialShape.PolygonFillMask(512, 256, MaterialShape.square, true); Texture2D shape = MaterialTexture.CreateTextureFromMask( shapeMask, nyan, new Vector2Int(x, y)); blueprint = MaterialTexture.Copy(origBlueprint); MaterialTexture.Paste(blueprint, mask, shape, Vector2Int.zero); GetComponent <Image>().sprite = Sprite.Create( blueprint, new Rect(0, 0, blueprint.width, blueprint.height), new Vector2(0.5f, 0.5f)); }