Creating a grid that holds objects of different sizes?
So I want to create a grid in world space, for now a square/rectangle. I also want to have game objects that fit within the tiles (by the way, the physical size of the tiles will be an integer in world space, like 1x1), but some of the objects may be larger than simply 1x1, such as 2x2, or 4x3, etc.
My question is, how do I go about implementing a way to store data bout what gameobjects are in this grid, and what spaces they are taking up? Obviously you want to say that gameobject A is taking up spaces x1-x2 and y1-y2, so you aren't able to place another object there.
All of the placement would be done with the mouse. This would also allow me to get information on that grid, and create a red-out effect on the object you want to place there (to inform the user they can't place the object in that location, since it will be entering the domain of another item).
How would one go about implementing this? All feedback welcome :)
Search for grid-based inventory scripts like those in Diablo, there is at least one example for Unity available.