Link to home
Start Free TrialLog in
Avatar of James Hancock
James HancockFlag for United States of America

asked on

Unity game graphics. C# Why does this jpg image go half-size at run-time?

Hi


My game is almost finished, but one unity graphics part has eluded me.

I use game icons like these for gameplay clues: They look great..

User generated image


User generated image


files :

icon003.jpg

icon001.png

The above ones stay properly sized when loaded correctly from a Sprites section in the Unity IDE at the beginning of my Monobehavior, like so:



    public Sprite[] sprites;


But this one here shrinks in size (half-size) when I put it into a GameObject the same way:

Is it a problematic altered format? (file below)

User generated image

icon014.jpg


Thanks



Avatar of Scott Bennett
Scott Bennett
Flag of United States of America image

looks like the footprint icon is 120x120 and the others are both over 200pixes in width and height... so the image itself is smaller than the others.

I would fiddle with the max size and the compression settings:


User generated image


And i would also take a look at the adjusting the Pixels Per Unit setting on the sprite when you create it.


https://docs.unity3d.com/ScriptReference/Sprite.Create.html

Avatar of James Hancock

ASKER

thanks,

my game sprites are tiles which I load into a sprite[] from the IDE at the top my code.


Should I deal with them in code such as this?  :


https://stackoverflow.com/questions/73063700/unity-how-to-change-sprite-size-to-fixed-resoltion-in-code">https://stackoverflow.com/questions/73063700/unity-how-to-change-sprite-size-to-fixed-resoltion-in-code

I think it would be advantageous to do its at runtime, coz the game will have so many images

ASKER CERTIFIED SOLUTION
Avatar of Scott Bennett
Scott Bennett
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial