public void OnDrawGismos(Transform tr) { Bounds bounds; List <IntPoint> buffer = ListPool <IntPoint> .Claim(); if (this.type == NavmeshCut.MeshType.Circle) { NavmeshCut.GetContour_Circle(buffer, tr, this.circleResolution, this.circleRadius, this.center, this.useRotation); bounds = NavmeshCut.GetBounds_Circle(tr, this.center, this.circleRadius, this.height, this.useRotation); } else { NavmeshCut.GetContour_Rectangle(buffer, tr, this.rectangleSize, this.center, this.useRotation); bounds = NavmeshCut.GetBounds_Rectangle(tr, this.center, this.rectangleSize, this.height, this.useRotation); } float y = bounds.min.y; Vector3 vector = (Vector3)(Vector3.up * (bounds.max.y - y)); for (int i = 0; i < buffer.Count; i++) { Vector3 from = NavmeshCut.IntPointToV3(buffer[i]); from.y = y; Vector3 to = NavmeshCut.IntPointToV3(buffer[(i + 1) % buffer.Count]); to.y = y; Gizmos.DrawLine(from, to); Gizmos.DrawLine(from + vector, to + vector); Gizmos.DrawLine(from, from + vector); Gizmos.DrawLine(to, to + vector); } ListPool <IntPoint> .Release(buffer); }
public void OnDrawGismos(Transform tr) { List <IntPoint> list = ListPool <IntPoint> .Claim(); Bounds bounds; if (this.type == NavmeshCut.MeshType.Circle) { NavmeshCut.GetContour_Circle(list, tr, this.circleResolution, this.circleRadius, this.center, this.useRotation); bounds = NavmeshCut.GetBounds_Circle(tr, this.center, this.circleRadius, this.height, this.useRotation); } else { NavmeshCut.GetContour_Rectangle(list, tr, this.rectangleSize, this.center, this.useRotation); bounds = NavmeshCut.GetBounds_Rectangle(tr, this.center, this.rectangleSize, this.height, this.useRotation); } float y = bounds.min.y; Vector3 b = Vector3.up * (bounds.max.y - y); for (int i = 0; i < list.get_Count(); i++) { Vector3 vector = NavmeshCut.IntPointToV3(list.get_Item(i)); vector.y = y; Vector3 vector2 = NavmeshCut.IntPointToV3(list.get_Item((i + 1) % list.get_Count())); vector2.y = y; Gizmos.DrawLine(vector, vector2); Gizmos.DrawLine(vector + b, vector2 + b); Gizmos.DrawLine(vector, vector + b); Gizmos.DrawLine(vector2, vector2 + b); } ListPool <IntPoint> .Release(list); }
public void OnDrawGizmosSelected(Transform tr) { Bounds bounds; Gizmos.color = Color.Lerp(NavmeshCut.GizmoColor, new Color(1f, 1f, 1f, 0.2f), 0.9f); if (this.type == NavmeshCut.MeshType.Circle) { bounds = NavmeshCut.GetBounds_Circle(tr, this.center, this.circleRadius, this.height, this.useRotation); } else { bounds = NavmeshCut.GetBounds_Rectangle(tr, this.center, this.rectangleSize, this.height, this.useRotation); } Gizmos.DrawCube(bounds.center, bounds.size); Gizmos.DrawWireCube(bounds.center, bounds.size); }
public Bounds GetBounds() { switch (this.type) { case NavmeshCut.MeshType.Rectangle: this.bounds = NavmeshCut.GetBounds_Rectangle(this.tr, this.center, this.rectangleSize, this.height, this.useRotation); break; case NavmeshCut.MeshType.Circle: this.bounds = NavmeshCut.GetBounds_Circle(this.tr, this.center, this.circleRadius, this.height, this.useRotation); break; case NavmeshCut.MeshType.CustomMesh: if (!(this.mesh == null)) { Bounds bounds = this.mesh.bounds; if (this.useRotation) { Matrix4x4 localToWorldMatrix = this.tr.localToWorldMatrix; bounds.center *= this.meshScale; bounds.size *= this.meshScale; this.bounds = new Bounds(localToWorldMatrix.MultiplyPoint3x4(this.center + bounds.center), Vector3.zero); Vector3 max = bounds.max; Vector3 min = bounds.min; this.bounds.Encapsulate(localToWorldMatrix.MultiplyPoint3x4(this.center + new Vector3(max.x, max.y, max.z))); this.bounds.Encapsulate(localToWorldMatrix.MultiplyPoint3x4(this.center + new Vector3(min.x, max.y, max.z))); this.bounds.Encapsulate(localToWorldMatrix.MultiplyPoint3x4(this.center + new Vector3(min.x, max.y, min.z))); this.bounds.Encapsulate(localToWorldMatrix.MultiplyPoint3x4(this.center + new Vector3(max.x, max.y, min.z))); this.bounds.Encapsulate(localToWorldMatrix.MultiplyPoint3x4(this.center + new Vector3(max.x, min.y, max.z))); this.bounds.Encapsulate(localToWorldMatrix.MultiplyPoint3x4(this.center + new Vector3(min.x, min.y, max.z))); this.bounds.Encapsulate(localToWorldMatrix.MultiplyPoint3x4(this.center + new Vector3(min.x, min.y, min.z))); this.bounds.Encapsulate(localToWorldMatrix.MultiplyPoint3x4(this.center + new Vector3(max.x, min.y, min.z))); Vector3 size = this.bounds.size; size.y = Mathf.Max(size.y, this.height * this.tr.lossyScale.y); this.bounds.size = size; } else { Vector3 size2 = bounds.size * this.meshScale; size2.y = Mathf.Max(size2.y, this.height); this.bounds = new Bounds(base.transform.position + this.center + bounds.center * this.meshScale, size2); } } break; } return(this.bounds); }