@@ -35,13 +35,17 @@ public static class WebToolPlugins
3535 [ DllImport ( "__Internal" ) ]
3636 private static extern uint _GetTotalMemorySize ( ) ;
3737 [ DllImport ( "__Internal" ) ]
38+ private static extern uint _GetDeviceMemorySize ( ) ;
39+ [ DllImport ( "__Internal" ) ]
3840 private static extern bool _CopyToClipboard ( string text ) ;
3941 [ DllImport ( "__Internal" ) ]
4042 private static extern int _IsOnline ( ) ;
4143 [ DllImport ( "__Internal" ) ]
4244 private static extern void _DownloadFile ( string filename , string content ) ;
4345 [ DllImport ( "__Internal" ) ]
4446 private static extern void _DownloadBlob ( string filename , byte [ ] byteArray , int byteLength , string mimeType ) ;
47+ [ DllImport ( "__Internal" ) ]
48+ private static extern void _SetCursor ( string cursorName ) ;
4549
4650#endif
4751
@@ -191,6 +195,29 @@ public static float GetTotalMemorySize()
191195#endif
192196 }
193197
198+ /// <summary>
199+ /// Get the device memory size in MB if supported by the browser
200+ /// Uses navigator.deviceMemory which is supported by chromium based browsers
201+ /// <see href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/deviceMemory"/>
202+ /// </summary>
203+ /// <returns>Size in MB or -1 if not supported</returns>
204+ public static float GetDeviceMemory ( )
205+ {
206+ #if UNITY_WEBGL && ! UNITY_EDITOR
207+ var gb = _GetDeviceMemorySize ( ) ;
208+ if ( gb > 0 )
209+ {
210+ return gb * 1024f ; // convert to MB
211+ }
212+ return - 1f ;
213+ #elif UNITY_EDITOR && WEBTOOLS_LOG_CALLS
214+ Debug . Log ( $ "{ nameof ( WebToolPlugins ) } .{ nameof ( GetDeviceMemory ) } called") ;
215+ return - 1f ;
216+ #else
217+ return - 1f ;
218+ #endif
219+ }
220+
194221 /// <summary>
195222 /// Get the managed memory size used by the application in MB
196223 /// </summary>
@@ -280,5 +307,28 @@ public static void DownloadBinaryFile(string filename, byte[] data, string mimeT
280307 Debug . Log ( $ "{ nameof ( WebToolPlugins ) } .{ nameof ( DownloadBinaryFile ) } called with filename: { filename } ") ;
281308 #endif
282309 }
310+
311+ /// <summary>
312+ /// Sets the CSS cursor style for the Unity canvas element.
313+ /// <see href="https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor"/>
314+ /// </summary>
315+ /// <param name="cursorName">The CSS cursor value (e.g., "pointer", "grab", "crosshair", "text", "default")</param>
316+ /// <example>
317+ /// <code>
318+ /// // Example: Change cursor to pointer on hover
319+ /// WebToolPlugins.SetCursor("pointer");
320+ ///
321+ /// // Example: Reset to default cursor
322+ /// WebToolPlugins.SetCursor("default");
323+ /// </code>
324+ /// </example>
325+ public static void SetCursor ( string cursorName )
326+ {
327+ #if UNITY_WEBGL && ! UNITY_EDITOR
328+ _SetCursor ( cursorName ) ;
329+ #elif UNITY_EDITOR && WEBTOOLS_LOG_CALLS
330+ Debug . Log ( $ "{ nameof ( WebToolPlugins ) } .{ nameof ( SetCursor ) } called with cursor: { cursorName } ") ;
331+ #endif
332+ }
283333 }
284334}
0 commit comments