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 *
1616using UnityEngine . SceneManagement ;
1717using System . Text . RegularExpressions ;
1818using Simulator . Editor ;
19+ using UnityEditor . SceneManagement ;
1920
2021public 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 ( )
0 commit comments