1616
1717namespace Supyrb
1818{
19- public partial class WebGlBridge
19+ /// <summary>
20+ /// Add commands to the WebGL bridge to expose them to the browser console
21+ /// </summary>
22+ public class CommonCommands : WebCommands
2023 {
2124 /// <summary>
2225 /// Disable capturing all keyboard input, e.g. for using native html input fields
2326 /// Browser Usage: <code>unityGame.SendMessage("WebGL","DisableCaptureAllKeyboardInput");</code>
2427 /// </summary>
25- [ WebGlCommand ( Description = "Disable unity from consuming all keyboard input" ) ]
28+ [ WebCommand ( Description = "Disable unity from consuming all keyboard input" ) ]
2629 public void DisableCaptureAllKeyboardInput ( )
2730 {
2831#if ! UNITY_EDITOR && UNITY_WEBGL
@@ -35,7 +38,7 @@ public void DisableCaptureAllKeyboardInput()
3538 /// Enable capturing all keyboard input, to make sure the game does not miss any key strokes
3639 /// Browser Usage: <code>unityGame.SendMessage("WebGL","EnableCaptureAllKeyboardInput");</code>
3740 /// </summary>
38- [ WebGlCommand ( Description = "Enable unity from consuming all keyboard input" ) ]
41+ [ WebCommand ( Description = "Enable unity from consuming all keyboard input" ) ]
3942 public void EnableCaptureAllKeyboardInput ( )
4043 {
4144#if ! UNITY_EDITOR && UNITY_WEBGL
@@ -48,18 +51,18 @@ public void EnableCaptureAllKeyboardInput()
4851 /// Logs the current memory usage
4952 /// Browser Usage: <code>unityGame.SendMessage("WebGL","LogMemory");</code>
5053 /// </summary>
51- [ WebGlCommand ( Description = "Logs the current memory" ) ]
54+ [ WebCommand ( Description = "Logs the current memory" ) ]
5255 [ ContextMenu ( nameof ( LogMemory ) ) ]
5356 public void LogMemory ( )
5457 {
55- WebGlPlugins . LogMemory ( ) ;
58+ WebToolPlugins . LogMemory ( ) ;
5659 }
5760
5861 /// <summary>
5962 /// Unloads all unused assets <see cref="Resources.UnloadUnusedAssets"/>
6063 /// Browser Usage: <code>unityGame.SendMessage("WebGL","UnloadUnusedAssets");</code>
6164 /// </summary>
62- [ WebGlCommand ( Description = "Resources.UnloadUnusedAssets" ) ]
65+ [ WebCommand ( Description = "Resources.UnloadUnusedAssets" ) ]
6366 [ ContextMenu ( nameof ( UnloadUnusedAssets ) ) ]
6467 public void UnloadUnusedAssets ( )
6568 {
@@ -72,7 +75,7 @@ public void UnloadUnusedAssets()
7275 /// Browser Usage: <code>unityGame.SendMessage("WebGL", "SetApplicationRunInBackground", 1);</code>
7376 /// </summary>
7477 /// <param name="runInBackground">1 if it should run in background</param>
75- [ WebGlCommand ( Description = "Application.runInBackground" ) ]
78+ [ WebCommand ( Description = "Application.runInBackground" ) ]
7679 public void SetApplicationRunInBackground ( int runInBackground )
7780 {
7881 Application . runInBackground = runInBackground == 1 ;
@@ -83,7 +86,7 @@ public void SetApplicationRunInBackground(int runInBackground)
8386 /// Browser Usage: <code>unityGame.SendMessage("WebGL", "SetApplicationTargetFrameRate", 15);</code>
8487 /// </summary>
8588 /// <param name="targetFrameRate">frame rate to render in</param>
86- [ WebGlCommand ( Description = "Application.targetFrameRate" ) ]
89+ [ WebCommand ( Description = "Application.targetFrameRate" ) ]
8790 public void SetApplicationTargetFrameRate ( int targetFrameRate )
8891 {
8992 Application . targetFrameRate = targetFrameRate ;
@@ -94,7 +97,7 @@ public void SetApplicationTargetFrameRate(int targetFrameRate)
9497 /// Browser Usage: <code>unityGame.SendMessage("WebGL", "SetTimeFixedDeltaTime", 0.02);</code>
9598 /// </summary>
9699 /// <param name="fixedDeltaTime"></param>
97- [ WebGlCommand ( Description = "Time.fixedDeltaTime" ) ]
100+ [ WebCommand ( Description = "Time.fixedDeltaTime" ) ]
98101 public void SetTimeFixedDeltaTime ( float fixedDeltaTime )
99102 {
100103 Time . fixedDeltaTime = fixedDeltaTime ;
@@ -106,7 +109,7 @@ public void SetTimeFixedDeltaTime(float fixedDeltaTime)
106109 /// Browser Usage: <code>unityGame.SendMessage("WebGL", "SetTimeTimeScale", 0.2);</code>
107110 /// </summary>
108111 /// <param name="timeScale">new timescale value</param>
109- [ WebGlCommand ( Description = "Time.timeScale" ) ]
112+ [ WebCommand ( Description = "Time.timeScale" ) ]
110113 public void SetTimeTimeScale ( float timeScale )
111114 {
112115 Time . timeScale = timeScale ;
@@ -116,28 +119,28 @@ public void SetTimeTimeScale(float timeScale)
116119 /// Toggle the visibility of the info panel in the top right corner
117120 /// Browser Usage: <code>unityGame.SendMessage("WebGL", "ToggleInfoPanel");</code>
118121 /// </summary>
119- [ WebGlCommand ( Description = "Toggle develop ui visibility of InfoPanel" ) ]
122+ [ WebCommand ( Description = "Toggle develop ui visibility of InfoPanel" ) ]
120123 public void ToggleInfoPanel ( )
121124 {
122- WebGlPlugins . ToggleInfoPanel ( ) ;
125+ WebToolPlugins . ToggleInfoPanel ( ) ;
123126 }
124127
125128 /// <summary>
126129 /// Log the user agent of the browser and if this agent is classified as mobile
127130 /// Browser Usage: <code>unityGame.SendMessage("WebGL", "LogUserAgent");</code>
128131 /// </summary>
129- [ WebGlCommand ( Description = "Log User Agent and isMobileDevice" ) ]
132+ [ WebCommand ( Description = "Log User Agent and isMobileDevice" ) ]
130133 public void LogUserAgent ( )
131134 {
132- string userAgent = WebGlPlugins . GetUserAgent ( ) ;
133- bool isMobileDevice = WebGlPlugins . IsMobileDevice ( ) ;
135+ string userAgent = WebToolPlugins . GetUserAgent ( ) ;
136+ bool isMobileDevice = WebToolPlugins . IsMobileDevice ( ) ;
134137 Debug . Log ( $ "<color=#4D65A4>User Agent:</color> '{ userAgent } ', <color=#4D65A4>IsMobileDevice:</color> '{ isMobileDevice } '") ;
135138 }
136139
137140 /// <summary>
138141 /// Log example messages to show off unity rich text parsing to html & console styling
139142 /// </summary>
140- [ WebGlCommand ( Description = "Log example messages for Log, warning and error" ) ]
143+ [ WebCommand ( Description = "Log example messages for Log, warning and error" ) ]
141144 [ ContextMenu ( nameof ( LogExampleMessages ) ) ]
142145 public void LogExampleMessages ( )
143146 {
@@ -150,7 +153,7 @@ public void LogExampleMessages()
150153 /// Log a custom message to test Debug.Log in general
151154 /// </summary>
152155 /// <param name="message">Message that will be logged</param>
153- [ WebGlCommand ( Description = "Log a custom message" ) ]
156+ [ WebCommand ( Description = "Log a custom message" ) ]
154157 public void LogMessage ( string message )
155158 {
156159 Debug . Log ( message ) ;
@@ -159,7 +162,7 @@ public void LogMessage(string message)
159162 /// <summary>
160163 /// Throw an exception from System namespace to see how stack traces look for that
161164 /// </summary>
162- [ WebGlCommand ( Description = "Throw a dictionary key not found exception" ) ]
165+ [ WebCommand ( Description = "Throw a dictionary key not found exception" ) ]
163166 [ ContextMenu ( nameof ( ThrowDictionaryException ) ) ]
164167 public void ThrowDictionaryException ( )
165168 {
@@ -172,7 +175,7 @@ public void ThrowDictionaryException()
172175 /// Log information of all texture formats that Unity supports, which ones are supported by
173176 /// the current platform and browser, and which ones are not supported
174177 /// </summary>
175- [ WebGlCommand ( Description = "Log supported and unsupported texture formats" ) ]
178+ [ WebCommand ( Description = "Log supported and unsupported texture formats" ) ]
176179 [ ContextMenu ( nameof ( LogTextureSupport ) ) ]
177180 public void LogTextureSupport ( )
178181 {
@@ -206,7 +209,7 @@ public void LogTextureSupport()
206209 /// <summary>
207210 /// Deletes all player prefs <see cref="PlayerPrefs.DeleteAll"/>
208211 /// </summary>
209- [ WebGlCommand ( Description = "PlayerPrefs.DeleteAll" ) ]
212+ [ WebCommand ( Description = "PlayerPrefs.DeleteAll" ) ]
210213 [ ContextMenu ( nameof ( DeleteAllPlayerPrefs ) ) ]
211214 public void DeleteAllPlayerPrefs ( )
212215 {
@@ -218,7 +221,7 @@ public void DeleteAllPlayerPrefs()
218221 /// <see cref="GraphicsSettings.logWhenShaderIsCompiled "/>
219222 /// </summary>
220223 /// <param name="runInBackground">1 if it should run in background</param>
221- [ WebGlCommand ( Description = "GraphicsSettings.logWhenShaderIsCompiled" ) ]
224+ [ WebCommand ( Description = "GraphicsSettings.logWhenShaderIsCompiled" ) ]
222225 [ ContextMenu ( nameof ( LogShaderCompilation ) ) ]
223226 public void LogShaderCompilation ( int enabled )
224227 {
0 commit comments