public void ShowPos() { //对象中心位置 nomalizePos.x = (int)transform.position.x; nomalizePos.z = (int)transform.position.z; canBuild = true; buildingInfo.rectangle.enable = true; //将整数化的坐标记录在grids中 for (int i = 0; i < buildingInfo.widght; i++) { for (int j = 0; j < buildingInfo.length; j++) { int gx = (int)nomalizePos.x + i - (buildingInfo.widght / 2); int gz = (int)nomalizePos.z + j - (buildingInfo.length / 2); buildingInfo.locat[i, j].pos = new Vector3(gx, transform.position.y, gz); buildingInfo.locat[i, j].enable = ctrl.HaveBuild(buildingInfo.locat[i, j].pos); //当有一个不满足,就不能够建造 if (!buildingInfo.locat[i, j].enable) { canBuild = false; buildingInfo.rectangle.enable = false; } } } buildingInfo.rectangle.pos = transform.position; if (!buildingInfo.didDraw) { gikey = GridDrawer.AddRectangle(buildingInfo.rectangle); buildingInfo.didDraw = true; } }