qertnerd.blogg.se

Unity texturepacker sprite loses width and height
Unity texturepacker sprite loses width and height




unity texturepacker sprite loses width and height

For more information, see the Normal map texture type documentation.įor more information on normal mapping in general, see Importing Textures. The Normal map texture type formats the texture asset so it’s suitable for real-time normal mapping. Normal map A type of Bump Map texture that allows you to add surface detail such as bumps, grooves, and scratches to a model which catch the light as if they are represented by real geometry. For more information, see the Default Texture type. It provides access to most of the properties for Texture importing. This is the most common setting used for all Textures. The following table lists the available texture types and explains their purpose.

unity texturepacker sprite loses width and height

The other properties in the Texture Import settings window change depending on the value you set. Use the Texture Type property to select the type of Texture you want to create from the source image file. You can preview the Texture and adjust its values here. Use the Platform-specific overrides panel to set default options and their overrides for a specific platforms. Depending on what Texture Type value you select, extra properties might appear in this area. (C) Type-specific and advanced properties. Select the shape and set properties specific to that shape in this area.

unity texturepacker sprite loses width and height

Select the type of Texture you want to create. There are several sections on the Texture Import Settings window: Expand the Advanced section in the Inspector window to view these properties. Note: Some of the less commonly used properties are hidden by default. The Texture Import Settings window appears in the Inspector A Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. To access this window, select the image file in the Project window A window that shows the contents of your Assets folder (Project tab) More info See in Glossary. TextureRegion.getV2() + (textureRegion.getV() - textureRegion.The Texture Import Settings window defines how Unity imports images from your project’s Assets folder into the Unity Editor. Position.y + height*(1 - portionToDraw) , Vector2 position, float width, float height, float portionToDraw) SpriteBatch batcher, TextureRegion textureRegion, So I figured out another solution: public static void I really don't know why, but the other answers didn't help me in my case. Height / 2, /* draw the sprite at half height*/įrame.getRegionHeight() / 2, /* only use the texture data from the top of the sprite */Īfter much struggle, I finally found a way to draw texture portions. Y + (height / 2), /* reposition to draw from half way up from the original sprite position */ To only draw the top half of a sprite (as if the sprite was standing in a liquid, for example) you would set the height, the texture region height, and include a slight adjustment to the draw position: spriteBatch.draw( X, y, width and height are the same as you would use in spriteBatch.draw(frame, x, y, width, height) Where spriteBatch is the SpriteBatch and frame is a Sprite * We only want to use half the source texture region */įrame.getRegionWidth() / 2, /* srcWidth the source with in texels */įrame.getRegionHeight(), /* srcHeight the source height in texels */įalse, /* flipX whether to flip the sprite horizontally */įalse) /* flipY whether to flip the sprite vertically */ Height, /* height the height in pixels */įrame.getScaleX(), /* scaleX the scale of the rectangle around originX/originY in x */įrame.getScaleY(), /* scaleY the scale of the rectangle around originX/originY in y */Ġ, /* rotation the angle of counter clockwise rotation of the rectangle around originX/originY */įrame.getRegionX(), /* srcX the x-coordinate in texel space */įrame.getRegionY(), /* srcY the y-coordinate in texel space */ Width / 2, /* width the width in pixels */ * We only want to draw half the width of the sprite */ Height / 2, /* originY the y-coordinate of the scaling and rotation origin relative to the screen space coordinates */ Width / 2, /* originX the x-coordinate of the scaling and rotation origin relative to the screen space coordinates */ Y, /* y the y-coordinate in screen space */ X, /* x the x-coordinate in screen space */

Unity texturepacker sprite loses width and height code#

getTexture() function.įor example, the following code could be used to draw only the left side of a sprite: spriteBatch.draw(

unity texturepacker sprite loses width and height

If you have a Sprite that you are already drawing, you can get the Texture itself from the Sprite using the. As long as you only intend to draw a rectangular sub-section of that sprite. It's quite possible to partially draw a sprite using the SpriteBatch.draw( Texture.) rather than the SpriteBatch.draw( TextureRegion.).






Unity texturepacker sprite loses width and height