public void PlaceObject(GameObject obj, Vector3 placePos, GridSquare grid, int layer)
This function places the object on the grid and changes the layer back to the original layer the object was on. You will need the obj, its position to place it, the grid to change the cell status and the object’s original layer.
It also adds the GridObject script to it, to keep a reference to the grid it is on.
//Places an obj on left mouse click
ObjectPlacer objectPlacer;
GridSelector gridSelector;
GridSquare grid;
public GameObject myObject;
void Update()
{
if (Input.GetMouseButton(0))
{
objectPlacer.PlaceObject(myObject, gridSelector.GetSelectorPosition(), grid, myObject.layer)
}
}