I’m trying to make a Grid who will be easily convertible between 2D and 3D and i’m having a problem with overlapping prefabs in the case of the 3D generation.
The thing is, the DataObjects (Tiles) actualy have inside them the prefab of the thing who must be in that tile, but the prefab is bigger than the Tile.
As you can see in the image, i have 3 Tiles selected, Each Tile have a prefab and all of them have the same kind of prefab, they are in the scene highlighted by the orange borders right now in the image.
Then you could imagine than, if the prefabs are equal between the 3 of them they should all have th same size, and that’s exactly the case (i.e. in fact they have the same size) but the thing is they are overlaping each other, have that in consideration when looking at the image.
So the question will be…
How to make sure two Tiles not overlap each other?
based on a suggestion on working not with scale but pixels with units, i don’t know exactly how to do that, but searching on google make me try this, which actualy doesn’t work:
tile.tile_GO.GetComponent<Renderer>().bounds.size = thisPrefab.GetComponent<Renderer>().bounds.size;
It doesn’t work because “bounds” is read only.
Do you know a work around to solve this?, or is another way to achieve what i’m looking for?
Feel free to ask, comment, request for clarification or even correct my grammar, all would be welcome if it is respectfull, specialy if it helps to find and answer.
The idea is stop the overlapping, if you know a way to make one next to the other one, or even leave a gap between them in runtime, it will be also consider a valid answer.
Thanks in advance.
PS: i’m using unity 2017.1.0f3, scripting in C#.