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
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.