Skip to content

Commit 4f3e7fe

Browse files
committed
Add some more commands for debugging purposes
1 parent b793618 commit 4f3e7fe

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Assets/Plugins/WebGL/WebGLTools/WebGlBridge.Commands.cs

+34
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Collections.Generic;
1313
using Supyrb.Attributes;
1414
using UnityEngine;
15+
using UnityEngine.Rendering;
1516

1617
namespace Supyrb
1718
{
@@ -54,6 +55,17 @@ public void LogMemory()
5455
WebGlPlugins.LogMemory();
5556
}
5657

58+
/// <summary>
59+
/// Unloads all unused assets <see cref="Resources.UnloadUnusedAssets"/>
60+
/// Browser Usage: <code>unityGame.SendMessage("WebGL","UnloadUnusedAssets");</code>
61+
/// </summary>
62+
[WebGlCommand(Description = "Resources.UnloadUnusedAssets")]
63+
[ContextMenu(nameof(UnloadUnusedAssets))]
64+
public void UnloadUnusedAssets()
65+
{
66+
Resources.UnloadUnusedAssets();
67+
}
68+
5769
/// <summary>
5870
/// Sets if the application should run while not focused.
5971
/// It is in background while another tab is focused or the console is focused
@@ -178,5 +190,27 @@ public void LogTextureSupport()
178190
Debug.Log($"Supported Texture formats: \n{string.Join(", ", supportedFormats)}");
179191
Debug.Log($"Unsupported Texture formats: \n{string.Join(", ", unsupportedFormats)}");
180192
}
193+
194+
/// <summary>
195+
/// Deletes all player prefs <see cref="PlayerPrefs.DeleteAll"/>
196+
/// </summary>
197+
[WebGlCommand(Description = "PlayerPrefs.DeleteAll")]
198+
[ContextMenu(nameof(DeleteAllPlayerPrefs))]
199+
public void DeleteAllPlayerPrefs()
200+
{
201+
PlayerPrefs.DeleteAll();
202+
}
203+
204+
/// <summary>
205+
/// Log shader compilation in debug builds (no effect in release builds)
206+
/// <see cref="GraphicsSettings.logWhenShaderIsCompiled "/>
207+
/// </summary>
208+
/// <param name="runInBackground">1 if it should run in background</param>
209+
[WebGlCommand(Description = "GraphicsSettings.logWhenShaderIsCompiled")]
210+
[ContextMenu(nameof(LogShaderCompilation))]
211+
public void LogShaderCompilation(int enabled)
212+
{
213+
GraphicsSettings.logWhenShaderIsCompiled = enabled == 1;
214+
}
181215
}
182216
}

0 commit comments

Comments
 (0)