Skip to content

Commit

Permalink
Support WebGL
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmfinol committed Nov 6, 2023
1 parent 791a5cc commit 7f8a9a3
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Assets/Plugins/WebGL.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Assets/Plugins/WebGL/React.jslib
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mergeInto(LibraryManager.library, {
GameReady: function (userName, score) {
window.dispatchReactUnityEvent("GameReady");
},
});
32 changes: 32 additions & 0 deletions Assets/Plugins/WebGL/React.jslib.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Assets/Scripts/Cgs/Menu/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityExtensionMethods;
#if !UNITY_ANDROID && !UNITY_IOS
#endif

namespace Cgs.Menu
{
Expand Down Expand Up @@ -187,17 +185,21 @@ private void ResetGameSelectionCarousel()
[UsedImplicitly]
public void SelectPrevious()
{
#if !UNITY_WEBGL
if (Time.timeSinceLevelLoad < StartBufferTime)
return;
CardGameManager.Instance.Select(CardGameManager.Instance.Previous.Id);
#endif
}

[UsedImplicitly]
public void SelectNext()
{
#if !UNITY_WEBGL
if (Time.timeSinceLevelLoad < StartBufferTime)
return;
CardGameManager.Instance.Select(CardGameManager.Instance.Next.Id);
#endif
}

[UsedImplicitly]
Expand Down
10 changes: 10 additions & 0 deletions Assets/Scripts/Cgs/Menu/TitleScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
#if UNITY_WEBGL && !UNITY_EDITOR
using System.Runtime.InteropServices;
#endif

namespace Cgs.Menu
{
public class TitleScreen : MonoBehaviour
{
#if UNITY_WEBGL && !UNITY_EDITOR
[DllImport("__Internal")]
private static extern void GameReady();
#endif
public const string TouchlessStartMessage = "Press Any Key";

public static string VersionMessage => $"VERSION {Application.version}";
Expand Down Expand Up @@ -93,6 +100,9 @@ private void Start()
centerText.text = TouchlessStartMessage;
#endif
versionText.text = VersionMessage;
#if UNITY_WEBGL && !UNITY_EDITOR
GameReady();
#endif
}

private void Update()
Expand Down

0 comments on commit 7f8a9a3

Please sign in to comment.