I have image of sprite having size 90 X 120 and I want to load that image in unity,
Now when I am loading that image it is look like stretch in height and width I am setting scale value of the object but It is look like not proper as I am just doing error and trial method.
can any one tell me how to calculate so the I can load proper image of sprite in scene.
means if my main camera size is 100 and type is orthographic.
and when I create sprite object below are setting which is been given to object
Texture type = Sprite
Sprite Mode = single
Pixel To units = 100
pivot = center
Max size = 1024
Format = 16 Bits
Now can any one tell me if any setting need to change or how to calculate the scale size of sprite as per above info so that sprite look good
Related
I'm trying to use AR camera with face tracking to capture some vertices from the facemesh(and mask the area), and pass the image to opencv for unity to do further processing.
Vector3 screenPosition = arCamera.GetComponent<Camera>().WorldToScreenPoint(face.transform.position + face.vertices[0])
I'm using this but this returns the position relative to the screen which has a different aspect ratio than the image from "cameraManager.TryAcquireLatestCpuImage". (2340 x 1080) vs (640 x 480)
I tried looking every where how to transform the position from world to cpu image and tried to map the screen coordinates to the cpu image using displaymatrix and projectionmatrix but no luck.
Any solution, would be appreciated!!
I'm having problems to set the right resolution on unity to not have pixel distortion on my pixel art assets. When I create an tile grid, on the preview tab the assets look terrible.
I have an tilemap with 64x32 resolution for each tile.
I'm using 64 pixels per unit.
The camera size is set to 5 in a 640x360 resolution (using the following formula: vertical resolution / PPU / 2).
What I'm doing wrong and what I'm missing?
I don't know how the tiles are defined, but assuming those are rects with textures on topm you could check your texture filter setting and play with it a little, setting it up for example to "anisotropic"
To solve this problem and get an "pixel perfect" view, you need to apply the following formula:
Camera size = height of the screen resolution / PPU (pixels per unit) / 2
This will do the job!
I made a new diffused material for grass in unity5 when applied it to a somrthing small in size it has all the details of the texture grass image but when applied the same material to a much larger objects only solid color is visible with no details of the texture.
refer the down given image.
both the cube and the floor has same material.
MaterialSetting
Increase the tiling. The image will stretch to be 1 x 1 on a huge object the way you have it in your image. The higher the tile count the more the image will be repeated across the object.
Be aware the x and y values may be different to one another depending on the dimensions of the gameobject it is attached to.
I want to animate an SKSpriteNode using textures from an SKTextureAtlas, using SKAction.animateWithTextures(textures,timePerFrame,resize,restore). However, the textures in the atlas have a size that is slightly larger than the original texture (it's basically a character moving). When the action is run, the textures are either compressed to fit the original size of the sprite, or recentered when I set resize to false, which changes the position of the character. What I want, though, is for the textures to be anchored at the lower-left corner (or lower-right, depending on the direction) so that the position of the character doesn't change apart from the extra part of the texture.
I've tried changing the anchor point of the sprite prior to running the action, but obviously that applies to the original texture as well. Also, I guess changing the size of the original texture would have an impact on the physics behaviour, which I want to avoid.
Does anyone have a suggestion about how to do this?
Thanks!
David
This would work
Edit all the textures to match the size of the largest sized texture.
Just give the smaller textures some padding using an alpha channel to give you a transparent background.
E.g. Notice how the first texture has lots of negative space
(From CartoonSmart.com)
Create the physics body with a certain size in mind. E.g. You can load the texture without the padding and get the size. Then position it as needed onto the new and improved texture with padding. So after you create the Sprite as normal with the new resized textures you can then
/// load a texture to be a template for the size
let imageTextureSizeTemplate = SKTexture(imageNamed: textureWithoutPadding)
let bodySize = imageTextureSizeTemplate.size()
/// position template texture physics body on texture that will be used
let bodyCenter = CGPointMake(0.5, 0.5)
// create physics body
let body:SKPhysicsBody = SKPhysicsBody(rectangleOfSize: bodySize, center: bodyCeneter)
self.physicsBody = body
Set resize: false when you animate the textures.
I am a beginner in Unity and I can't understand how the scales of GameObjects work; in the following picture I have a quad and a sprite. The quad's scale should be smaller than the sprite's scale, but in the editor when I touch them they have the same scale of 1.
Short Answer
Every object has a baseline (1, 1, 1) scale when first created. The size for a 2D sprite and 3D quad object are calculated differently for each, which is why they are not the same size in your screenshot.
Long Answer
The sprite is a 2D object and its size is based on the import settings of the sprite. The default size for sprites is 100 pixels is 1 unit.
The quad is a 3D object and its size is based on what 1 unit is in Unity. In Unity's settings, 1 unit is 1 meter, by default. So, the quad is 1 meter cubed, by default.
If you import a sprite that is 100x100, and keep the default 100 pixels is 1 unit, it should be the same size (with an orthographic camera) as the default quad size.