diff --git a/Assets/Scripts/Cgs/CardGameManager.cs b/Assets/Scripts/Cgs/CardGameManager.cs index b4216d37..66185d72 100644 --- a/Assets/Scripts/Cgs/CardGameManager.cs +++ b/Assets/Scripts/Cgs/CardGameManager.cs @@ -18,6 +18,10 @@ using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityExtensionMethods; +#if UNITY_WEBGL && !UNITY_EDITOR +using System.Runtime.InteropServices; +#endif + #if UNITY_ANDROID && !UNITY_EDITOR using UnityEngine.Networking; #endif @@ -28,6 +32,10 @@ namespace Cgs { public class CardGameManager : MonoBehaviour { +#if UNITY_WEBGL && !UNITY_EDITOR + [DllImport("__Internal")] + private static extern void GameReady(); +#endif // Show all Debug.Log() to help with debugging? private const bool IsMessengerDebugLogVerbose = false; public const string PlayerPrefsDefaultGame = "DefaultGame"; @@ -185,12 +193,10 @@ private void Awake() ResetCurrentToDefault(); -#if !UNITY_WEBGL +#if !UNITY_WEBGL || UNITY_EDITOR Debug.Log("CardGameManager::Awake:CheckDeepLinks"); CheckDeepLinks(); #endif - - Debug.Log("CardGameManager is Awake!"); } // ReSharper disable once MemberCanBeMadeStatic.Local @@ -342,7 +348,7 @@ private void OnSceneUnloaded(Scene scene) OnSceneActions.Clear(); } -#if !UNITY_WEBGL +#if !UNITY_WEBGL || UNITY_EDITOR private void CheckDeepLinks() { Application.deepLinkActivated += OnDeepLinkActivated; @@ -600,6 +606,14 @@ internal void ResetGameScene() action(); } +#if UNITY_WEBGL && !UNITY_EDITOR + private void Start() + { + Debug.Log("CardGameManager::Start:GameReady"); + GameReady(); + } +#endif + private void IgnoreCurrentErroredGame() { Current.ClearError(); @@ -607,35 +621,6 @@ private void IgnoreCurrentErroredGame() ResetGameScene(); } - public void PromptDelete() - { - if (AllCardGames.Count > 1) - Messenger.Prompt(DeletePrompt, Delete); - else - Messenger.Show(DeleteWarningMessage); - } - - private void Delete() - { - if (AllCardGames.Count < 1) - { - Debug.LogError(DeleteErrorMessage + DeleteWarningMessage); - return; - } - - try - { - Directory.Delete(Current.GameDirectoryPath, true); - AllCardGames.Remove(Current.Id); - ResetCurrentToDefault(); - ResetGameScene(); - } - catch (Exception ex) - { - Debug.LogError(DeleteErrorMessage + ex.Message); - } - } - public void Share() { Debug.Log("CGS Share:: Deep:" + Current.CgsGamesLink + " Auto:" + Current.AutoUpdateUrl); @@ -733,6 +718,35 @@ public IEnumerator OpenZip(Uri uri, string gameId) } #endif + public void PromptDelete() + { + if (AllCardGames.Count > 1) + Messenger.Prompt(DeletePrompt, Delete); + else + Messenger.Show(DeleteWarningMessage); + } + + private void Delete() + { + if (AllCardGames.Count < 1) + { + Debug.LogError(DeleteErrorMessage + DeleteWarningMessage); + return; + } + + try + { + Directory.Delete(Current.GameDirectoryPath, true); + AllCardGames.Remove(Current.Id); + ResetCurrentToDefault(); + ResetGameScene(); + } + catch (Exception ex) + { + Debug.LogError(DeleteErrorMessage + ex.Message); + } + } + private void LateUpdate() { Inputs.WasFocusBack = Inputs.IsFocusBack; diff --git a/Assets/Scripts/Cgs/Menu/TitleScreen.cs b/Assets/Scripts/Cgs/Menu/TitleScreen.cs index 30246f26..b7babf47 100644 --- a/Assets/Scripts/Cgs/Menu/TitleScreen.cs +++ b/Assets/Scripts/Cgs/Menu/TitleScreen.cs @@ -5,18 +5,11 @@ 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}"; @@ -100,9 +93,6 @@ private void Start() centerText.text = TouchlessStartMessage; #endif versionText.text = VersionMessage; -#if UNITY_WEBGL && !UNITY_EDITOR - GameReady(); -#endif } private void Update()