Currently, the Image component uses the sprite’s pixels per unit variable in order to determine the sizes when slicing and tiling an image.
It is currently impossible for a user to have different slicing using only one texture. The only solution I have found was to duplicate the texture file and reimport it, which quickly bloats the texture atlas.
By copying the Image script, and simply applying a factor to the pixelsPerUnits variable, I have been able to make the slicing manually editable :
It would be handy to either make the pixelPerUnit variable virtual in order to be overriden, or adding a factor variable.
Hello @phil-Unity
do you think this feature could be useful (cause for us it seems to be a good one) and not too touchy to be accessible by script without create a custom Image component ?
Hasn’t seen this thread but i honestly stared at the gif for minutes just mesmerized by the fact we didn’t think of this. Personally i think its simple and handy. I will pass it on to get it done (soon ™).
@phil-Unity thanks for the answer ! It’s really great to hear that !!
We will abuse of your kindness by linking you this associated problem in the 2D part (which is maybe a UI trouble we didn’t know where to post those 2 topics )
By soon, do you think it could land into 2018.3 ? (I don’t think so but we try)
Glad this is getting noticed ! The link @aurelien-morel-ubiant is accurate as having multiple ppu for one texture would make the gif above available not only for the Image class, but for every classes using Sprite, which sounds like a more generic solution.
Sorry for the ad, but if you cannot wait for it, you can use Better UI which allows you to do something very similar (and is even a bit more powerful).
it’s not the most elegant solution in the world, but you can actually accomplish this by inheriting from the Image class rather than fulling copying it into your own duplicate class.
first create a public new float pixelsPerUnit to hide the variable from the base class. It so happens that even though this property is not virtual, all of the functions that access it are, so just override all of those functions, and copy paste there contents into your custom Image class so that they use your new pixelsPerUnit variable. There is quite a lot of copy pasting still and it’s obviously not ideal, but at least you will still be able to use your custom image class with other UI classes that require Images
I also would very much like to see this feature. This could save us so many duplicated sprites because the artists want different corner radius on various buttons/backgrounds/etc.
@phil-Unity Yes, but you are going to be disappointed, it is just a circle. I linked the meta file along so you have the sprite import settings with it!
[quote=“VincentPaquinUbiant, post:12, topic: 716916, username:VincentPaquinUbiant”] @phil-Unity Yes, but you are going to be disappointed, it is just a circle. I linked the meta file along so you have the sprite import settings with it!
[/quote] Thanks, kind of what i thought but figured just double check with a known asset vs me just pulling some random asset from a bug case.