# How can I get the borderSize/s of a plane?

public Texture2D gridImage;
public GameObject floor;

private int borderSize;

private void Start()
{

GenerateGrid();
}

void GenerateGrid()
{
Color gridColor = Color.cyan;
Color borderColor = Color.black;
Collider floorCollider = floor.GetComponent<Collider>();
MeshRenderer floorRenderer = floor.GetComponent<MeshRenderer>();
floorRenderer.material.mainTexture = gridImage;
floorRenderer.material.mainTextureScale = new Vector2(floorCollider.bounds.size.x, floorCollider.bounds.size.z);
floorRenderer.material.mainTextureOffset = new Vector2(.5f, .5f);

Vector3 foorSize = new Vector3(floorCollider.bounds.size.x, floorCollider.bounds.size.z);
for (int x = 0; x < gridImage.width; x++)
{
for (int y = 0; y < gridImage.height; y++)
{
if (x < borderSize || x > gridImage.width - borderSize || y < borderSize || y > gridImage.height - borderSize)
{
gridImage.SetPixel(x, y, new Color(borderColor.r, borderColor.g, borderColor.b, 50));
}
else gridImage.SetPixel(x, y, new Color(gridColor.r, gridColor.g, gridColor.b, 50));
}
gridImage.Apply();
}
}


In the end I want to create something like this on a 3D Plane UI :

• Do you mean the Unity plane primitive? It's 10 units by 10 units by default, then scaled by whatever scale factors you've applied to it and its parents. If you have a different need, can you edit your question to elaborate? – DMGregory Jul 31 at 21:09
• Your question does not have enough detail. Is floorCollider the object you want the size of? Is floorCollider.bounds.size not giving you what you need? – Kevin Jul 31 at 21:22