File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
Assets/MicroEngineer/Code/UI Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,20 @@ public void Initialize()
5050 Collapse ( ) ;
5151
5252 WindowRoot [ 0 ] . RegisterCallback < PointerUpEvent > ( UpdateWindowPosition ) ;
53- WindowRoot [ 0 ] . transform . position = EntryWindow . FlightRect . position ;
53+
54+ // Handle initial window positioning. Set the position OnGeometryChangedEvent.
55+ EventCallback < GeometryChangedEvent > _positionCallBack = null ;
56+ _positionCallBack = evt =>
57+ {
58+ if ( evt . newRect . width == 0 || evt . newRect . height == 0 )
59+ return ;
60+
61+ WindowRoot [ 0 ] . style . left = EntryWindow . FlightRect . position . x ;
62+ WindowRoot [ 0 ] . style . top = EntryWindow . FlightRect . position . y ;
63+
64+ WindowRoot [ 0 ] . UnregisterCallback ( _positionCallBack ) ;
65+ } ;
66+ WindowRoot [ 0 ] . RegisterCallback < GeometryChangedEvent > ( _positionCallBack ) ;
5467
5568 // Hide the settings button if window is not editable (Stage window)
5669 if ( ! EntryWindow . IsEditable )
Original file line number Diff line number Diff line change @@ -34,7 +34,20 @@ public void OnEnable()
3434 Root [ 0 ] . RegisterCallback < PointerUpEvent > ( UpdateWindowPosition ) ;
3535
3636 MainGuiWindow = ( MainGuiWindow ) Manager . Instance . Windows . Find ( w => w is MainGuiWindow ) ;
37- Root [ 0 ] . transform . position = MainGuiWindow . FlightRect . position ;
37+
38+ // Handle initial window positioning. Set the position OnGeometryChangedEvent.
39+ EventCallback < GeometryChangedEvent > _positionCallBack = null ;
40+ _positionCallBack = evt =>
41+ {
42+ if ( evt . newRect . width == 0 || evt . newRect . height == 0 )
43+ return ;
44+
45+ Root [ 0 ] . style . left = MainGuiWindow . FlightRect . position . x ;
46+ Root [ 0 ] . style . top = MainGuiWindow . FlightRect . position . y ;
47+
48+ Root [ 0 ] . UnregisterCallback ( _positionCallBack ) ;
49+ } ;
50+ Root [ 0 ] . RegisterCallback < GeometryChangedEvent > ( _positionCallBack ) ;
3851 }
3952
4053 private void UpdateWindowPosition ( PointerUpEvent evt )
You can’t perform that action at this time.
0 commit comments