virtual public void DrawPath(UCL.Core.MathLib.UCL_Path _Path, RectTransform field, Color col, VectorExtensionMethods.Vec3ToVec2 dir = VectorExtensionMethods.Vec3ToVec2.xy, int seg_count = 20) { Vector3[] Corners = new Vector3[4]; field.GetWorldCorners(Corners); Vector2 Min = Corners[0]; Vector2 Max = Corners[2]; for (int i = 0; i < 4; i++) { var point = Corners[i]; if (point.x < Min.x) { Min.x = point.x; } if (point.x > Max.x) { Max.x = point.x; } if (point.y < Min.y) { Min.y = point.y; } if (point.y > Max.y) { Max.y = point.y; } } DrawPath(_Path, Min, Max - Min, col, dir, seg_count); }
public override Rect GetRect(VectorExtensionMethods.Vec3ToVec2 dir = VectorExtensionMethods.Vec3ToVec2.xy) { if (m_Path == null) { return(Rect.zero); } return(m_Path.GetRect()); }
/// <summary> /// Get the Rect cover hole path /// </summary> /// <param name="dir">the direction of rect(etc. xy</param> /// <returns></returns> override public Rect GetRect(VectorExtensionMethods.Vec3ToVec2 dir = VectorExtensionMethods.Vec3ToVec2.xy) { if (m_WorldSpacePoints == null || m_WorldSpacePoints.Length == 0) { return(Rect.zero); } Vector3 min = m_WorldSpacePoints[0]; Vector3 max = min; for (int i = 1; i < m_WorldSpacePoints.Length; i++) { var point = m_WorldSpacePoints[i]; if (point.x < min.x) { min.x = point.x; } else if (point.x > max.x) { max.x = point.x; } if (point.y < min.y) { min.y = point.y; } else if (point.y > max.y) { max.y = point.y; } if (point.z < min.z) { min.z = point.z; } else if (point.z > max.z) { max.z = point.z; } } Vector2 minn = min.ToVec2(dir); Vector2 maxx = max.ToVec2(dir); float width = maxx.x - minn.x; float height = maxx.y - minn.y; return(Rect.MinMaxRect(minn.x - 0.1f * width, minn.y - 0.1f * height, maxx.x + 0.1f * width, maxx.y + 0.1f * height)); }
virtual public void DrawPath(UCL.Core.MathLib.UCL_Path _Path, Vector2 start_pos, Vector2 size, Color col, VectorExtensionMethods.Vec3ToVec2 dir = VectorExtensionMethods.Vec3ToVec2.xy, int seg_count = 20) { if (seg_count < 1) { seg_count = 1; } Vector2 prev_pos = _Path.GetPos(0).ToVec2(dir); for (int i = 1; i <= seg_count; i++) { float at = (i / (float)seg_count); Vector2 pos = _Path.GetPos(at).ToVec2(dir); DrawLine((prev_pos.x - start_pos.x) / size.x, (prev_pos.y - start_pos.y) / size.y, (pos.x - start_pos.x) / size.x, (pos.y - start_pos.y) / size.y, col); prev_pos = pos; } }
public override Rect GetRect(VectorExtensionMethods.Vec3ToVec2 dir = VectorExtensionMethods.Vec3ToVec2.xy) { return(base.GetRect(dir)); }
//virtual public rect3D /// <summary> /// Get the Rect cover whole path /// </summary> /// <param name="dir">the direction of rect(etc. xy</param> /// <returns></returns> virtual public Rect GetRect(VectorExtensionMethods.Vec3ToVec2 dir = VectorExtensionMethods.Vec3ToVec2.xy) { return(Rect.zero); }
virtual public void DrawPath(UCL.Core.MathLib.UCL_Path _Path, Rect rect, Color col, VectorExtensionMethods.Vec3ToVec2 dir = VectorExtensionMethods.Vec3ToVec2.xy, int seg_count = 20) { DrawPath(_Path, rect.min, rect.size, col, dir, seg_count); }