Create a custom round corner rectangle.

Hello everyone,.

First of all, I’m new to Unity, but not bad at scripting.

What I want.
Let me first explain what I’m looking for : I want to generate an ice rink (cf. http://cache3.asset-cache.net/xc/459298881.jpg?v=2&c=IWSAsset&k=2&d=bzSVH3oIlTDvM3PErCrCZ-RBwb2iOcDQBPy1TB9ZRAssljLV_tmX7-lwGilUxLdI0). And on top of this ice rink, i’ll have a grid to script my pathfinding. It’s optional but it would be nice to be able to create custom ice rink (ie. the ice rink length is between 55 and 65f ; the border radius is between 3 & 6f ; …).

What I’ve done.
So far, Ive been able to generate my grid quite easily. I can change length, height and radius, and the grid is generated with gizmos. It works pretty well. But here come the bad news !
To have a “nice” round corner rect, my grid tile size has to be quite small (“more pixels !”). With a 60f length, 30f height, 5f radius, I make a 0.1f tile size. So it’s basically a 603010 (18.000 tile grid !). And right now, my method to render the ice rink in game is to apply a texture on each tile… Yes… I’m pretty sure it’s very very bad.

What I want.
So, I’m a bit lost. Basically, I need tips, or someone to show me the way :slight_smile:
Is there a way of creating a custom sprite shape ?
Should I just photoshop my ice rink and apply a grid on it after ? In this case, how could I custom the length, height, radius of the ice rink ?
Any other ideas ?

What I’ll try next.
I’ve read a few posts. And this one grabed my attention.(cf. c# - Unity Texture2D create rounded corners - Stack Overflow).
If I’m understanding well, I could create a rectangle, and then hide some “pixels” I don’t want. In other words, that’s the contrary of my script (hiding “pixels”, showing “pixels”).
Is there a way to script this mask ? Or is it only possible via the unity interface ? Does it looks like a good idea performance wise ?

Bonus question.
I struggle to understand unity sometimes.
What does 1f represents in terms of pixels ? In other words, if I want a 60f length ice rink, how many pixels should it be in photoshop ? Is it wrong to try to think in this way.

Thanks all for reading and your precious answers.

Ok, so after a good number of epic fails, here I am, back :slight_smile:

Bonus question : solved !
I eventually understood the concept of “pixel per unit” when importing sprites. So if another noobie read this : when you import a sprite, you can tell in the Editor how many “Pixels Per Unit” it should be. In other word, a 256*256px sprite with a 256 Pixel Per Unit value will be 1f in Unity.

My problem : pending…
I’ve tried the method given in the post I quoted. Although it works quite well, it doesn’t cover all my needs.
So basically, I’m now trying to create a mesh, but I’m struggling to get exactly how Triangle-Verticles-Normals works. Well, I think this is exactly what I need so I’ll keep going.

By the way, I’m still in a need of feedbacks. I’m not asking for any code, just advices, feelings. In other words : if you were to do that kind of project, what would be your way ?

Thanks