Skip to content

Commit 11b0580

Browse files
committed
JS sample
1 parent f347e90 commit 11b0580

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
mergeInto(LibraryManager.library, {
2+
3+
ThrowJavaScript: function () {
4+
var something = undefined;
5+
console.log("JavaScript error incoming...");
6+
something.do();
7+
},
8+
9+
});

samples/unity-of-bugs/Assets/Scripts/MobileNativeSupport/JavaScriptPlugin.jslib.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/unity-of-bugs/Assets/Scripts/MobileNativeSupport/NativeSupportButtons.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Collections;
22
using System.Collections.Generic;
3-
#if ENABLE_IL2CPP || PLATFORM_IOS
3+
#if ENABLE_IL2CPP || PLATFORM_IOS || PLATFORM_WEBGL
44
using System.Runtime.InteropServices;
55
#endif
66
using UnityEngine;
@@ -30,8 +30,13 @@ public void ThrowKotlin()
3030
{
3131
jo.CallStatic("throw");
3232
}
33+
#else
34+
// TODO: Add this sample to its own button:
35+
#if PLATFORM_WEBGL
36+
ThrowJavaScript();
3337
#else
3438
Debug.LogWarning("Not running on Android.");
39+
#endif
3540
#endif
3641
}
3742

@@ -124,6 +129,21 @@ public void ThrowObjectiveC()
124129
private static extern void throwObjectiveC();
125130
#endif
126131

132+
public void ThrowJavaScript()
133+
{
134+
#if PLATFORM_WEBGL
135+
throwJavaScript();
136+
#else
137+
Debug.Log("JavaScript interop only works on WebGL players.");
138+
#endif
139+
}
140+
141+
#if PLATFORM_WEBGL
142+
// JavaScriptPlugin.jslib
143+
[DllImport("__Internal")]
144+
private static extern void throwJavaScript();
145+
#endif
146+
127147
public void LoadBugfarm() => SceneManager.LoadScene("1_Bugfarm");
128148
public void LoadAdditionalSamples() => SceneManager.LoadScene("3_AdditionalSamples");
129149
}

src/sentry-dotnet

Submodule sentry-dotnet updated 47 files

0 commit comments

Comments
 (0)