0% found this document useful (0 votes)
42 views

Grid

This script creates a grid on the game world using Gizmos. It draws horizontal and vertical lines based on the camera position, width and height variables. The lines are the color specified in the color variable and extend far beyond the camera view. Tiles can be placed on the grid using the tilePrefab and tileSet references.

Uploaded by

api-302510505
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Grid

This script creates a grid on the game world using Gizmos. It draws horizontal and vertical lines based on the camera position, width and height variables. The lines are the color specified in the color variable and extend far beyond the camera view. Tiles can be placed on the grid using the tilePrefab and tileSet references.

Uploaded by

api-302510505
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

using UnityEngine;

using System.Collections;
public class grid : MonoBehaviour {
public float width = 32.0f;
public float height = 32.0f;
public Color color = Color.white;
public Transform tilePrefab;
public TileSet tileSet;
void OnDrawGizmos() {
Vector3 pos = Camera.current.transform.position;
Gizmos.color = this.color;
for (float y = pos.y - 800.0f; y < pos.y + 800f; y += height) {
Gizmos.DrawLine(new Vector3(-100000.0f, Mathf.Floor(y / height) * height,
0f), new Vector3(100000.0f, Mathf.Floor(y / height) * height, 0f));
}

for (float x = pos.x - 1200.0f; x < pos.x + 1200f; x += this.width)


{
Gizmos.DrawLine(new Vector3(Mathf.Floor(x / this.width) * this.width, 1000000, 0f), new Vector3 (Mathf.Floor(x / width) * this.width, 1000000, 0f));
}
}
}

You might also like