Hey guys,
I'm having some trouble...
I'm using Unity and about to get into testing out the level design for the 3D game I'm making. I've got some test textures that I made (poorly) and I'm confused on how to get them to show up the same way regardless of the mesh they're placed on.
I already sought help on the matter by asking on the Unity Answers website some time ago. I explained the dilemma there and I put an image up to help demonstrate it. Here's a link there. Just so you know, the answer below my question there isn't really relevant to this thread.
I kind of fixed the issue with the help of the community and some of my own hacky coding.
What I did was code up a way to make a new material (which, in Unity, is a texture, kind of) and set its tiling based on the distance the material has to be 'stretched across'. If the mesh is 25 units wide and 8 units tall, then it sets the X tiling to 25 and the Y tiling to 8. Since the goal was to try and make a way to tile a texture by game units instead of "how many times it's placed on the mesh", I added a variable called 'gameUnitsPerTile' and set the X and Y tiling to X distance / gameUnitsPerTile and Y distance / gameUnitsPerTile, respectively.
The thought was, the material tiles across the whole mesh X/Y tiling times. So if the tiling is 4x4, then it draws the image 4 times along the X axis and 4 times along the Y axis. If the tiling values were set to the actual 'length' of the mesh, then it'd be tiling it once across the whole mesh. That way, as long as your gameUnitsPerTile value was the same for each mesh, you could have the texture showing the same way on each mesh.
It actually worked pretty well, but I still feel like I'm doing it wrong, and I'm not totally confident my method is very optimized (having a different material for each wall) or will work in every situation I'll need it to. I'm probably just severely mixed up about how UVs and texture tiling works. I feel like this is a lot harder than it should be.
Anyway, thanks for reading this far, and I hope it makes sense. If I've failed to explain something properly, please tell me what it is and I'll try to fix it. Any help would be appreciated.