Skip to content

Commit 9e22149

Browse files
committed
Merge remote-tracking branch 'origin/master' into release-2021.2
2 parents 19b90e5 + 90c47ce commit 9e22149

22 files changed

+117
-91
lines changed

Assets/Scripts/Editor/Map/MapAnnotations.cs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2019-2020 LG Electronics, Inc.
2+
* Copyright (c) 2019-2021 LG Electronics, Inc.
33
*
44
* This software contains code licensed as described in LICENSE.
55
*
@@ -16,6 +16,7 @@
1616
using UnityEngine.SceneManagement;
1717
using System.Text.RegularExpressions;
1818
using Simulator.Editor;
19+
using UnityEditor.SceneManagement;
1920

2021
public class MapAnnotations : EditorWindow
2122
{
@@ -84,6 +85,8 @@ private enum SignType { STOP, YIELD };
8485
private Vector2 scrollPos;
8586
private int ExtraLinesCnt;
8687

88+
private Scene CurrentActiveScene;
89+
8790
[MenuItem("Simulator/Annotate HD Map #&m", false, 100)]
8891
public static void Open()
8992
{
@@ -231,6 +234,7 @@ private void OnEnable()
231234
if (targetWaypointGO != null)
232235
DestroyImmediate(targetWaypointGO);
233236
mapHolder = FindObjectOfType<MapHolder>();
237+
CurrentActiveScene = EditorSceneManager.GetActiveScene();
234238
}
235239

236240
private void OnSelectionChange()
@@ -271,6 +275,13 @@ private void OnDisable()
271275

272276
private void Update()
273277
{
278+
if (CurrentActiveScene != EditorSceneManager.GetActiveScene())
279+
{
280+
CurrentActiveScene = EditorSceneManager.GetActiveScene();
281+
mapHolder = FindObjectOfType<MapHolder>();
282+
OnSelectionChange();
283+
}
284+
274285
switch (MapAnnotationTool.createMode)
275286
{
276287
case MapAnnotationTool.CreateMode.NONE:
@@ -368,6 +379,28 @@ private void OnGUI()
368379
GUILayout.EndHorizontal();
369380
GUILayout.Space(20);
370381

382+
if (mapHolder)
383+
{
384+
MapAnnotationTool.WAYPOINT_SIZE = mapHolder.MapWaypointSize;
385+
EditorGUILayout.LabelField("Gizmo Size", titleLabelStyle, GUILayout.ExpandWidth(true));
386+
GUILayout.BeginHorizontal("box");
387+
if (!EditorGUIUtility.isProSkin)
388+
GUI.backgroundColor = nonProColor;
389+
GUILayout.Space(10);
390+
var prevSize = MapAnnotationTool.WAYPOINT_SIZE;
391+
MapAnnotationTool.WAYPOINT_SIZE = EditorGUILayout.Slider(MapAnnotationTool.WAYPOINT_SIZE, 0.02f, 1f, GUILayout.ExpandWidth(true));
392+
mapHolder.MapWaypointSize = MapAnnotationTool.WAYPOINT_SIZE;
393+
if (prevSize != MapAnnotationTool.WAYPOINT_SIZE)
394+
{
395+
SceneView.RepaintAll();
396+
EditorUtility.SetDirty(mapHolder);
397+
}
398+
if (!EditorGUIUtility.isProSkin)
399+
GUI.backgroundColor = Color.white;
400+
GUILayout.EndHorizontal();
401+
GUILayout.Space(20);
402+
}
403+
371404
EditorGUILayout.LabelField("Create Modes", titleLabelStyle, GUILayout.ExpandWidth(true));
372405
if (!EditorGUIUtility.isProSkin)
373406
GUI.backgroundColor = nonProColor;
@@ -981,6 +1014,8 @@ private void CreateMapHolder()
9811014
{
9821015
MapAnnotations tool = (MapAnnotations)GetWindow(typeof(MapAnnotations));
9831016

1017+
MapOrigin.Find();
1018+
9841019
var tempGO = new GameObject("Map" + SceneManager.GetActiveScene().name);
9851020
tempGO.transform.position = Vector3.zero;
9861021
tempGO.transform.rotation = Quaternion.identity;
@@ -994,7 +1029,7 @@ private void CreateMapHolder()
9941029
Undo.RegisterCreatedObjectUndo(tempGO, nameof(tempGO));
9951030

9961031
SceneView.RepaintAll();
997-
Debug.Log("Holder object for this scenes annotations, intersections and lanes created");
1032+
Debug.Log("MapHolder object for this scenes annotations created", tempGO);
9981033
}
9991034

10001035
private void CreateIntersectionHolder()

Assets/Scripts/Editor/Map/MapOriginEditor.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2019 LG Electronics, Inc.
2+
* Copyright (c) 2019-2021 LG Electronics, Inc.
33
*
44
* This software contains code licensed as described in LICENSE.
55
*
@@ -48,14 +48,11 @@ public override void OnInspectorGUI()
4848
origin.AltitudeOffset = EditorGUILayout.FloatField("Altitude Offset", origin.AltitudeOffset);
4949

5050
int currentlySelected = -1;
51-
if (origin.TimeZoneSerialized != null)
51+
currentlySelected = Array.FindIndex(TimeZones, tz => tz.DisplayName == origin.TimeZoneString);
52+
if (currentlySelected == -1)
5253
{
53-
currentlySelected = Array.FindIndex(TimeZones, tz => tz.DisplayName == origin.TimeZoneString);
54-
if (currentlySelected == -1)
55-
{
56-
var timeZone = origin.TimeZone;
57-
currentlySelected = Array.FindIndex(TimeZones, tz => tz.BaseUtcOffset == timeZone.BaseUtcOffset);
58-
}
54+
var timeZone = origin.TimeZone;
55+
currentlySelected = Array.FindIndex(TimeZones, tz => tz.BaseUtcOffset == timeZone.BaseUtcOffset);
5956
}
6057

6158
var values = TimeZones.Select(tz => tz.DisplayName.Replace("&", "&&")).ToArray();
@@ -66,9 +63,12 @@ public override void OnInspectorGUI()
6663
{
6764
origin.TimeZoneSerialized = TimeZones[currentlySelected].ToSerializedString();
6865
origin.TimeZoneString = TimeZones[currentlySelected].DisplayName;
66+
6967
EditorUtility.SetDirty(origin);
68+
Repaint();
7069
}
7170
}
71+
7272
if (GUILayout.Button("Add Reference Point"))
7373
{
7474
AddReferencePoint(origin);

Assets/Scripts/Map/MapAnnotationTool.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*
66
*/
77

8-
using System.Collections;
9-
using System.Collections.Generic;
108
using UnityEngine;
119

1210
namespace Simulator.Map
@@ -41,6 +39,7 @@ public enum PedestrianPathType
4139
public static bool SHOW_MAP_SELECTED { get; set; } = false;
4240
public static float PROXIMITY { get; set; } = 1.0f;
4341
public static float EXPORT_SCALE_FACTOR = 1.0f;
44-
public static float ARROWSIZE = 50.0f;
42+
public static float ARROWSIZE => 100f * WAYPOINT_SIZE;
43+
public static float WAYPOINT_SIZE { get; set; } = 0.5f;
4544
}
4645
}

Assets/Scripts/Map/MapClearArea.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
/**
2-
* Copyright (c) 2019 LG Electronics, Inc.
2+
* Copyright (c) 2019-2021 LG Electronics, Inc.
33
*
44
* This software contains code licensed as described in LICENSE.
55
*
66
*/
77

8-
using System.Collections;
9-
using System.Collections.Generic;
10-
using UnityEngine;
11-
using Simulator.Map;
12-
138
namespace Simulator.Map
149
{
1510
public class MapClearArea : MapDataPoints, IMapType
@@ -23,7 +18,7 @@ public override void Draw()
2318
{
2419
if (mapLocalPositions.Count < 3) return;
2520

26-
AnnotationGizmos.DrawWaypoints(transform, mapLocalPositions, MapAnnotationTool.PROXIMITY * 0.5f, clearAreaColor + selectedColor);
21+
AnnotationGizmos.DrawWaypoints(transform, mapLocalPositions, MapAnnotationTool.WAYPOINT_SIZE, clearAreaColor + selectedColor);
2722
AnnotationGizmos.DrawLines(transform, mapLocalPositions, clearAreaColor + selectedColor);
2823
if (MapAnnotationTool.SHOW_HELP)
2924
{

Assets/Scripts/Map/MapCrossWalk.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
/**
2-
* Copyright (c) 2019 LG Electronics, Inc.
2+
* Copyright (c) 2019-2021 LG Electronics, Inc.
33
*
44
* This software contains code licensed as described in LICENSE.
55
*
66
*/
77

8-
using System.Collections;
9-
using System.Collections.Generic;
10-
using UnityEngine;
11-
using Simulator.Map;
12-
138
namespace Simulator.Map
149
{
1510
public class MapCrossWalk : MapDataPoints, IMapType
@@ -23,7 +18,7 @@ public override void Draw()
2318
{
2419
if (mapLocalPositions.Count < 3) return;
2520

26-
AnnotationGizmos.DrawWaypoints(transform, mapLocalPositions, MapAnnotationTool.PROXIMITY * 0.5f, crossWalkColor + selectedColor);
21+
AnnotationGizmos.DrawWaypoints(transform, mapLocalPositions, MapAnnotationTool.WAYPOINT_SIZE, crossWalkColor + selectedColor);
2722
AnnotationGizmos.DrawLines(transform, mapLocalPositions, crossWalkColor + selectedColor);
2823

2924
if (MapAnnotationTool.SHOW_HELP)

Assets/Scripts/Map/MapData.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
/**
2-
* Copyright (c) 2019 LG Electronics, Inc.
2+
* Copyright (c) 2019-2021 LG Electronics, Inc.
33
*
44
* This software contains code licensed as described in LICENSE.
55
*
66
*/
77

8-
using System.Collections;
98
using System.Collections.Generic;
109
using UnityEngine;
11-
using Simulator.Map;
1210

1311
namespace Simulator.Map
1412
{
@@ -195,7 +193,7 @@ public static void DrawArrowHeads(Transform mainTrans, List<Vector3> localPoints
195193
{
196194
var start = mainTrans.TransformPoint(localPoints[i]);
197195
var end = mainTrans.TransformPoint(localPoints[i + 1]);
198-
DrawArrowHead(start, end, lineColor, arrowHeadScale: MapAnnotationTool.ARROWSIZE * 1f, arrowPositionRatio: 0.5f); // TODO why reference map annotation tool?
196+
DrawArrowHead(start, end, lineColor, arrowHeadScale: MapAnnotationTool.ARROWSIZE, arrowPositionRatio: 0.5f);
199197
}
200198
}
201199

Assets/Scripts/Map/MapHolder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
/**
2-
* Copyright (c) 2019 LG Electronics, Inc.
2+
* Copyright (c) 2019-2021 LG Electronics, Inc.
33
*
44
* This software contains code licensed as described in LICENSE.
55
*
66
*/
77

8-
using System.Collections;
9-
using System.Collections.Generic;
108
using UnityEngine;
119

1210
namespace Simulator.Map
@@ -15,5 +13,7 @@ public class MapHolder : MonoBehaviour
1513
{
1614
public Transform trafficLanesHolder;
1715
public Transform intersectionsHolder;
16+
[HideInInspector]
17+
public float MapWaypointSize = 0.5f;
1818
}
1919
}

Assets/Scripts/Map/MapIntersection.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
using System.Collections.Generic;
99
using UnityEngine;
10-
using Simulator.Controllable;
1110
using Simulator.Utilities;
1211

1312
namespace Simulator.Map
@@ -35,7 +34,6 @@ public class MapIntersection : MapData
3534

3635
[System.NonSerialized]
3736
List<MapSignal> signalGroup = new List<MapSignal>();
38-
private MonoBehaviour FixedUpdateManager;
3937
public bool isStopSignIntersection = false;
4038

4139
public void SetIntersectionData()
@@ -268,7 +266,7 @@ public override void Draw()
268266
var start = transform.position;
269267
var end = start + transform.up * 6f;
270268

271-
AnnotationGizmos.DrawWaypoint(transform.position, MapAnnotationTool.PROXIMITY * 0.5f, intersectionColor + selectedColor);
269+
AnnotationGizmos.DrawWaypoint(transform.position, MapAnnotationTool.WAYPOINT_SIZE, intersectionColor + selectedColor);
272270
Gizmos.color = intersectionColor + selectedColor;
273271
Gizmos.DrawLine(start, end);
274272
AnnotationGizmos.DrawArrowHead(start, end, intersectionColor + selectedColor, arrowHeadScale: MapAnnotationTool.ARROWSIZE, arrowPositionRatio: 1f);

Assets/Scripts/Map/MapJunction.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
/**
2-
* Copyright (c) 2019 LG Electronics, Inc.
2+
* Copyright (c) 2019-2021 LG Electronics, Inc.
33
*
44
* This software contains code licensed as described in LICENSE.
55
*
66
*/
77

8-
using System.Collections;
9-
using System.Collections.Generic;
10-
using UnityEngine;
11-
using Simulator.Map;
12-
138
namespace Simulator.Map
149
{
1510
public class MapJunction : MapDataPoints, IMapType
@@ -24,7 +19,7 @@ public override void Draw()
2419
{
2520
if (mapLocalPositions.Count < 2) return;
2621

27-
AnnotationGizmos.DrawWaypoints(transform, mapLocalPositions, MapAnnotationTool.PROXIMITY * 0.5f, junctionColor);
22+
AnnotationGizmos.DrawWaypoints(transform, mapLocalPositions, MapAnnotationTool.WAYPOINT_SIZE, junctionColor);
2823
AnnotationGizmos.DrawLines(transform, mapLocalPositions, junctionColor);
2924
if (MapAnnotationTool.SHOW_HELP)
3025
{

Assets/Scripts/Map/MapLaneSection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2019-2020 LG Electronics, Inc.
2+
* Copyright (c) 2019-2021 LG Electronics, Inc.
33
*
44
* This software contains code licensed as described in LICENSE.
55
*
@@ -170,7 +170,7 @@ public override void Draw()
170170
{
171171
var start = transform.position;
172172
var end = start + transform.up * 2f;
173-
var size = new Vector3(MapAnnotationTool.PROXIMITY * 0.75f, MapAnnotationTool.PROXIMITY * 0.75f, MapAnnotationTool.PROXIMITY * 0.75f);
173+
var size = new Vector3(MapAnnotationTool.WAYPOINT_SIZE, MapAnnotationTool.WAYPOINT_SIZE, MapAnnotationTool.WAYPOINT_SIZE);
174174
AnnotationGizmos.DrawCubeWaypoint(transform.position, size, laneColor + selectedColor);
175175
Gizmos.color = laneColor + selectedColor;
176176
Gizmos.DrawLine(start, end);

0 commit comments

Comments
 (0)