/// <summary> /// Show the scene view editor for editing waypoints. /// </summary> virtual protected void ShowEditWaypoints(WaypointMoverPlatform platform) { GUIStyle centeredLabelStyle = GUI.skin.GetStyle("Label"); centeredLabelStyle.alignment = TextAnchor.UpperCenter; for (int i = 0; i < platform.waypoints.Count; i++) { if (Event.current.shift && platform.waypoints.Count > 2) { if (DrawRemoveHandle(platform.waypoints[i])) { platform.waypoints.RemoveAt(i); EditorUtility.SetDirty(platform); return; } } else { Vector2 newPosition = DrawMoveHandle(platform.waypoints[i]); if (newPosition != platform.waypoints[i]) { platform.waypoints[i] = newPosition; EditorUtility.SetDirty(platform); } } if (i > 0) { if (DrawAddHandle(platform.waypoints[i], platform.waypoints[i - 1])) { platform.waypoints.Insert(i, (platform.waypoints[i] + platform.waypoints[i - 1]) / 2.0f); EditorUtility.SetDirty(platform); } } else if (platform.moveType == WaypointMoveType.LOOP) { if (DrawAddHandle(platform.waypoints[i], platform.waypoints[platform.waypoints.Count - 1])) { platform.waypoints.Add((platform.waypoints[i] + platform.waypoints[platform.waypoints.Count - 1]) / 2.0f); EditorUtility.SetDirty(platform); } } } }
/// <summary> /// Show the scene view editor for editing waypoints. /// </summary> virtual protected void ShowWaypoints(WaypointMoverPlatform platform) { GUIStyle centeredLabelStyle = GUI.skin.GetStyle("Label"); centeredLabelStyle.alignment = TextAnchor.UpperCenter; Handles.color = handleColor; for (int i = 0; i < platform.waypoints.Count; i++) { if (i == 0 && platform.moveType == WaypointMoveType.LOOP) { Handles.DrawLine(platform.waypoints[platform.waypoints.Count - 1], platform.waypoints[i]); Vector2 v = platform.waypoints[i] - platform.waypoints[platform.waypoints.Count - 1]; v = Vector3.Cross(v, Vector3.forward); v.Normalize(); Vector2 a1 = (Vector2)(Quaternion.Euler(0, 0, -60) * (0.5f * v)) + platform.waypoints[i]; Vector2 a2 = (Vector2)(Quaternion.Euler(0, 0, 60) * (-0.5f * v)) + platform.waypoints[i]; Handles.DrawLine(a1, platform.waypoints[i]); Handles.DrawLine(a2, platform.waypoints[i]); } if (i != 0) { Handles.DrawLine(platform.waypoints[i - 1], platform.waypoints[i]); //Handles.DrawLine( movement.wayPoints[i], a2); Vector2 v = platform.waypoints[i] - platform.waypoints[i - 1]; v = Vector3.Cross(v, Vector3.forward); v.Normalize(); Vector2 a1 = (Vector2)(Quaternion.Euler(0, 0, -60) * (0.5f * v)) + platform.waypoints[i]; Vector2 a2 = (Vector2)(Quaternion.Euler(0, 0, 60) * (-0.5f * v)) + platform.waypoints[i]; Handles.DrawLine(a1, platform.waypoints[i]); Handles.DrawLine(a2, platform.waypoints[i]); } } }