This repository was archived by the owner on Feb 12, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed
packages/com.mkmarek.uielements.react/Runtime Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -57,10 +57,9 @@ public class ReactRenderer : PanelRenderer
5757 StartCoroutine ( HandleMessages ( ) ) ;
5858 StartCoroutine ( HandleEvents ( ) ) ;
5959 StartCoroutine ( CheckforJsErrors ( ) ) ;
60+ StartCoroutine ( CheckForMouseOverElement ( ) ) ;
6061
6162 visualTree . pickingMode = PickingMode . Ignore ;
62- visualTree . RegisterCallback < MouseEnterEvent > ( x => isMouseOverElement = true ) ;
63- visualTree . RegisterCallback < MouseLeaveEvent > ( x => isMouseOverElement = false ) ;
6463 }
6564
6665 public void RunModule ( string [ ] modulesToReload )
@@ -78,6 +77,33 @@ public void AddMessageToBuffer(string message)
7877 jsToNativeMessages . Enqueue ( message ) ;
7978 }
8079
80+ private IEnumerator CheckForMouseOverElement ( )
81+ {
82+ while ( true )
83+ {
84+ var position =
85+ new Vector2 ( Input . mousePosition . x / Screen . width , Input . mousePosition . y / Screen . height ) *
86+ this . visualTree . layout . size ;
87+
88+ // the position needs to be inverted vertically
89+ position . y = this . visualTree . layout . size . y - position . y ;
90+
91+ var picked = panel . Pick ( position ) ;
92+
93+ // Should also ignore panel elements
94+ if ( picked ? . parent != null )
95+ {
96+ isMouseOverElement = true ;
97+ }
98+ else
99+ {
100+ isMouseOverElement = false ;
101+ }
102+
103+ yield return new WaitForEndOfFrame ( ) ;
104+ }
105+ }
106+
81107 private IEnumerator CheckforJsErrors ( )
82108 {
83109 while ( true )
You can’t perform that action at this time.
0 commit comments