using System.Collections; using System.Collections.Generic; using UnityEngine; public class GridElements : MonoBehaviour { public byte x_Pos; public byte z_Pos; public bool AutoHandle = false; public Transform InitPos; //生成点 public List NearGrids = new List(); //相邻格子 public Rect MyRect = new Rect(); private void Awake() { InitPos = transform.GetChild(0); } [ContextMenu("SetRect")] private void SetMyRect() { Vector3 pos = transform.position; float width = transform.localScale.x; float length = transform.localScale.z; MyRect = new Rect(pos.x - width / 2, pos.z - length / 2, width, length); } private void Reset() { return; string myname = transform.name; x_Pos = byte.Parse(myname[0].ToString()); z_Pos = byte.Parse(myname[1].ToString()); } }