File tree Expand file tree Collapse file tree 2 files changed +18
-13
lines changed
Assets/MicroEngineer/Code Expand file tree Collapse file tree 2 files changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -52,19 +52,8 @@ public void Initialize()
5252 WindowRoot [ 0 ] . RegisterCallback < PointerUpEvent > ( UpdateWindowPosition ) ;
5353
5454 // 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 ) ;
67-
55+ Utility . SetDefaultWindowPosition ( WindowRoot [ 0 ] , EntryWindow . FlightRect . position . x , EntryWindow . FlightRect . position . y ) ;
56+
6857 // Hide the settings button if window is not editable (Stage window)
6958 if ( ! EntryWindow . IsEditable )
7059 SettingsButton . style . display = DisplayStyle . None ;
Original file line number Diff line number Diff line change @@ -330,5 +330,21 @@ public static void DisableGameInputOnFocus(this VisualElement element)
330330 element.RegisterCallback<FocusOutEvent>(_ => GameManager.Instance?.Game?.Input.Enable());
331331 }
332332 */
333+
334+ public static void SetDefaultWindowPosition ( VisualElement root , float x , float y )
335+ {
336+ EventCallback < GeometryChangedEvent > _positionCallBack = null ;
337+ _positionCallBack = evt =>
338+ {
339+ if ( evt . newRect . width == 0 || evt . newRect . height == 0 )
340+ return ;
341+
342+ root . style . left = x ;
343+ root . style . top = y ;
344+
345+ root . UnregisterCallback ( _positionCallBack ) ;
346+ } ;
347+ root . RegisterCallback < GeometryChangedEvent > ( _positionCallBack ) ;
348+ }
333349 }
334350}
You can’t perform that action at this time.
0 commit comments