1 using UnityEngine; 2 using System.Collections; 3 4 public class GridMap : MonoBehaviour { 5 6 public int m_mapWidth = 10; //宽度 7 public int m_mapHeight = 10; //长度 8 9 void OnDrawGizmos() 10 { 11 Gizmos.color = Color.blue; 12 13 //绘制宽度的线 14 for (int i = 0; i < m_mapWidth; i++) 15 { 16 Gizmos.DrawLine(new Vector3(0, 0, i), new Vector3(m_mapHeight, 0, i)); 17 } 18 19 //绘制长度的线 20 for (int i = 0; i < m_mapHeight; i++) 21 { 22 Gizmos.DrawLine(new Vector3(i, 0, 0), new Vector3(i, 0, m_mapWidth)); 23 } 24 } 25 }