modify scripts
This commit is contained in:
@ -23,71 +23,71 @@ namespace WordsToolkit.Scripts.Editor
|
||||
public static string WordConnect = "WordConnect";
|
||||
private static string WordConnectPath = "Assets/WordConnectGameToolkit";
|
||||
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Shop settings")]
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Shop settings")]
|
||||
public static void IAPProducts()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/CoinsShopSettings.asset");
|
||||
}
|
||||
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Ads settings")]
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Ads settings")]
|
||||
public static void AdsSettings()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/AdsSettings.asset");
|
||||
}
|
||||
|
||||
//DailyBonusSettings
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Daily bonus settings")]
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Daily bonus settings")]
|
||||
public static void DailyBonusSettings()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/DailyBonusSettings.asset");
|
||||
}
|
||||
|
||||
//GameSettings
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Game settings")]
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Game settings")]
|
||||
public static void GameSettings()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/GameSettings.asset");
|
||||
}
|
||||
|
||||
//SpinSettings
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Spin settings")]
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Spin settings")]
|
||||
public static void SpinSettings()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/SpinSettings.asset");
|
||||
}
|
||||
|
||||
//DebugSettings
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Debug settings")]
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Debug settings")]
|
||||
public static void DebugSettings()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/DebugSettings.asset");
|
||||
}
|
||||
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Crossword config")]
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Crossword config")]
|
||||
public static void CrosswordConfig()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/CrosswordConfig.asset");
|
||||
}
|
||||
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Tutorial settings")]
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Tutorial settings")]
|
||||
public static void TutorialSettings()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/TutorialSettings.asset");
|
||||
}
|
||||
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Language configuration")]
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Language configuration")]
|
||||
public static void LanguageConfiguration()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/LanguageConfiguration.asset");
|
||||
}
|
||||
|
||||
[MenuItem( nameof(WordConnect) + "/Settings/Gift settings")]
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Gift settings")]
|
||||
public static void GiftSettings()
|
||||
{
|
||||
Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(WordConnectPath + "/Resources/Settings/GiftSettings.asset");
|
||||
}
|
||||
|
||||
[MenuItem( nameof(WordConnect) + "/Scenes/Main scene &1", priority = 0)]
|
||||
[MenuItem(nameof(WordConnect) + "/Scenes/Main scene &1", priority = 0)]
|
||||
public static void MainScene()
|
||||
{
|
||||
EditorSceneManager.OpenScene(WordConnectPath + "/Scenes/main.unity");
|
||||
@ -99,7 +99,7 @@ namespace WordsToolkit.Scripts.Editor
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
}
|
||||
|
||||
[MenuItem( nameof(WordConnect) + "/Scenes/Game scene &2")]
|
||||
[MenuItem(nameof(WordConnect) + "/Scenes/Game scene &2")]
|
||||
public static void GameScene()
|
||||
{
|
||||
var stateManager = Object.FindObjectOfType<StateManager>();
|
||||
@ -107,7 +107,7 @@ namespace WordsToolkit.Scripts.Editor
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
}
|
||||
|
||||
[MenuItem( nameof(WordConnect) + "/Editor/Tile editor", priority = 1)]
|
||||
[MenuItem(nameof(WordConnect) + "/Editor/Tile editor", priority = 1)]
|
||||
public static void ColorEditor()
|
||||
{
|
||||
string folderPath = WordConnectPath + "/Resources/ColorsTile";
|
||||
@ -130,37 +130,44 @@ namespace WordsToolkit.Scripts.Editor
|
||||
EditorGUIUtility.PingObject(tileAsset);
|
||||
}
|
||||
|
||||
[MenuItem( nameof(WordConnect) + "/Documentation/Main", priority = 2)]
|
||||
[MenuItem(nameof(WordConnect) + "/Documentation/Main", priority = 2)]
|
||||
public static void MainDoc()
|
||||
{
|
||||
Application.OpenURL("https://candy-smith.gitbook.io/main");
|
||||
}
|
||||
|
||||
[MenuItem( nameof(WordConnect) + "/Documentation/ADS/Setup ads")]
|
||||
[MenuItem(nameof(WordConnect) + "/Documentation/ADS/Setup ads")]
|
||||
public static void UnityadsDoc()
|
||||
{
|
||||
Application.OpenURL("https://candy-smith.gitbook.io/bubble-shooter-toolkit/tutorials/ads-setup/");
|
||||
}
|
||||
|
||||
[MenuItem( nameof(WordConnect) + "/Documentation/Unity IAP (in-apps)")]
|
||||
[MenuItem(nameof(WordConnect) + "/Documentation/Unity IAP (in-apps)")]
|
||||
public static void Inapp()
|
||||
{
|
||||
Application.OpenURL("https://candy-smith.gitbook.io/main/block-puzzle-game-toolkit/setting-up-in-app-purchase-products");
|
||||
}
|
||||
|
||||
[MenuItem( nameof(WordConnect) + "/NLP/Training Language Model")]
|
||||
[MenuItem(nameof(WordConnect) + "/NLP/Training Language Model")]
|
||||
public static void TrainingModel()
|
||||
{
|
||||
Application.OpenURL("https://colab.research.google.com/drive/199zNcB3FPfnrD6E7OiwmwCcf27jMnY1b?usp=sharing");
|
||||
}
|
||||
|
||||
|
||||
[MenuItem( nameof(WordConnect) + "/Reset PlayerPrefs &e")]
|
||||
[MenuItem(nameof(WordConnect) + "/Reset PlayerPrefs &e")]
|
||||
private static void ResetPlayerPrefs()
|
||||
{
|
||||
GameDataManager.ClearALlData();
|
||||
PlayerPrefs.DeleteKey("GameState");
|
||||
Debug.Log("PlayerPrefs are reset");
|
||||
}
|
||||
|
||||
// 🔥 新增菜单项,打开 PrefabBatchViewer 窗口
|
||||
[MenuItem(nameof(WordConnect) + "/Settings/Prefab Batch Viewer")]
|
||||
public static void OpenPrefabBatchViewer()
|
||||
{
|
||||
PopupPreview.ShowWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
93
Assets/WordConnectGameToolkit/Scripts/Editor/PopupPreview.cs
Normal file
93
Assets/WordConnectGameToolkit/Scripts/Editor/PopupPreview.cs
Normal file
@ -0,0 +1,93 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
public class PopupPreview : EditorWindow
|
||||
{
|
||||
private GameObject[] prefabs;
|
||||
private int currentIndex = 0;
|
||||
private GameObject currentInstance;
|
||||
|
||||
[MenuItem("Tools/Prefab Batch Viewer")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
GetWindow<PopupPreview>("Prefab Batch Viewer");
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
string path = "Assets/WordConnectGameToolkit/Resources/Popups";
|
||||
string[] prefabPaths = Directory.GetFiles(path, "*.prefab", SearchOption.AllDirectories);
|
||||
prefabs = prefabPaths
|
||||
.Select(p => AssetDatabase.LoadAssetAtPath<GameObject>(p))
|
||||
.Where(p => p != null)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (prefabs == null || prefabs.Length == 0)
|
||||
{
|
||||
EditorGUILayout.LabelField("No prefabs found in Resources/Popups.");
|
||||
return;
|
||||
}
|
||||
|
||||
EditorGUILayout.LabelField($"Prefab {currentIndex + 1}/{prefabs.Length}", EditorStyles.boldLabel);
|
||||
EditorGUILayout.ObjectField("Current Prefab", prefabs[currentIndex], typeof(GameObject), false);
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("Previous"))
|
||||
{
|
||||
ShowPreviousPrefab();
|
||||
}
|
||||
if (GUILayout.Button("Next"))
|
||||
{
|
||||
ShowNextPrefab();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
if (currentInstance == null)
|
||||
{
|
||||
if (GUILayout.Button("Instantiate in Scene"))
|
||||
{
|
||||
InstantiateCurrentPrefab();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GUILayout.Button("Remove Instance"))
|
||||
{
|
||||
DestroyImmediate(currentInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowPreviousPrefab()
|
||||
{
|
||||
currentIndex = (currentIndex - 1 + prefabs.Length) % prefabs.Length;
|
||||
InstantiateCurrentPrefab();
|
||||
}
|
||||
|
||||
private void ShowNextPrefab()
|
||||
{
|
||||
currentIndex = (currentIndex + 1) % prefabs.Length;
|
||||
InstantiateCurrentPrefab();
|
||||
}
|
||||
|
||||
private void InstantiateCurrentPrefab()
|
||||
{
|
||||
if (currentInstance != null)
|
||||
{
|
||||
DestroyImmediate(currentInstance);
|
||||
}
|
||||
|
||||
currentInstance = (GameObject)PrefabUtility.InstantiatePrefab(prefabs[currentIndex]);
|
||||
currentInstance.name = prefabs[currentIndex].name + "_Preview";
|
||||
Selection.activeGameObject = currentInstance;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 599a70f1dde3c4f8b879a52397f2416e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -26,6 +26,7 @@ namespace WordsToolkit.Scripts.Enums
|
||||
LanguageChanged,
|
||||
TileSelected,
|
||||
PurchaseSucceeded,
|
||||
PurchaseFailed,
|
||||
ButtonClicked,
|
||||
WordAnimated,
|
||||
ExtraWordClaimed
|
||||
|
||||
@ -4,7 +4,11 @@
|
||||
"references": [
|
||||
"GUID:343deaaf83e0cee4ca978e7df0b80d21",
|
||||
"GUID:d3bf71b33c0c04eb9bc1a8d6513d76bb",
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc"
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc",
|
||||
"GUID:00dd4a7ac8c24c898083910c81898ecc",
|
||||
"GUID:ac6e78962cfc743b9a5fc5f5a808aa72",
|
||||
"GUID:b25ad8286798741e3b2cc3883283e669",
|
||||
"GUID:75bdbcf23199f4cfb86c610d1d946666"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace WordsToolkit.Scripts.Popups
|
||||
{
|
||||
public class MessagePopup : Banner
|
||||
{
|
||||
[SerializeField] private TextMeshProUGUI messageText;
|
||||
|
||||
public void SetMessage(string message)
|
||||
{
|
||||
if (messageText != null)
|
||||
{
|
||||
messageText.text = message;
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b00e69d6788d74f1cb21197ea9faaa8d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -49,6 +49,7 @@ namespace WordsToolkit.Scripts.Popups
|
||||
}
|
||||
|
||||
EventManager.GetEvent<string>(EGameEvent.PurchaseSucceeded).Subscribe(PurchaseSucceded);
|
||||
EventManager.GetEvent<(string, string)>(EGameEvent.PurchaseFailed).Subscribe(PurchaseFailed);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@ -85,6 +86,44 @@ namespace WordsToolkit.Scripts.Popups
|
||||
}
|
||||
}
|
||||
|
||||
private void PurchaseFailed((string, string) info)
|
||||
{
|
||||
var productId = info.Item1;
|
||||
var errorMessage = info.Item2;
|
||||
|
||||
var errorType = IAPErrorHelper.ParseError(errorMessage);
|
||||
Debug.LogWarning($"Purchase failed for product {productId}: {errorMessage}, Error Type: {errorType}");
|
||||
|
||||
switch (errorType)
|
||||
{
|
||||
case IAPErrorType.InvalidProductID:
|
||||
Debug.LogError($"Invalid product ID: {productId}");
|
||||
ShowErrorMessage("Invalid product ID. Please try again later.");
|
||||
break;
|
||||
case IAPErrorType.UserCancelled:
|
||||
Debug.LogWarning("Purchase cancelled by user.");
|
||||
break;
|
||||
case IAPErrorType.DuplicateTransaction:
|
||||
Debug.LogWarning($"Duplicate transaction for product {productId}. This usually means the purchase was already completed.");
|
||||
break;
|
||||
case IAPErrorType.IAPInitFailed:
|
||||
Debug.LogError("IAP initialization failed. Please check your IAP settings.");
|
||||
ShowErrorMessage("IAP initialization failed. Please try again later.");
|
||||
break;
|
||||
default:
|
||||
ShowErrorMessage($"Payment failed: {errorMessage}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void ShowErrorMessage(string message)
|
||||
{
|
||||
var popup = menuManager.ShowPopup<MessagePopup>();
|
||||
if (popup != null)
|
||||
{
|
||||
popup.SetMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public void BuyCoins(string id)
|
||||
{
|
||||
// StopInteration();
|
||||
|
||||
@ -25,6 +25,7 @@ namespace WordsToolkit.Scripts.Services.IAP
|
||||
private IExtensionProvider extensionProvider;
|
||||
|
||||
public static event Action<string> OnSuccessfulPurchase;
|
||||
public static event Action<(string,string)> OnFailedPurchase;
|
||||
public static event Action<bool, List<string>> OnRestorePurchasesFinished;
|
||||
|
||||
public void InitializePurchasing(IEnumerable<(string productId, ProductTypeWrapper.ProductType productType)> products)
|
||||
@ -111,20 +112,24 @@ namespace WordsToolkit.Scripts.Services.IAP
|
||||
{
|
||||
Debug.Log(string.Format("Purchasing product asychronously: '{0}'", product.definition.id));
|
||||
storeController.InitiatePurchase(product);
|
||||
OnFailedPurchase?.Invoke((productId, "Product not found or not available for purchase.")); // debug only
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase {productId}");
|
||||
OnFailedPurchase?.Invoke((productId, "InvalidProductID: product not found or not available for purchase."));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("BuyProductID FAIL. Not initialized.");
|
||||
Debug.Log("IAPInitFailed: BuyProductID FAIL. Not initialized.");
|
||||
OnFailedPurchase?.Invoke((productId, "IAPInitFailed: Not initialized."));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Log("BuyProductID: FAIL. Exception during purchase. " + e);
|
||||
OnFailedPurchase?.Invoke((productId, "Exception during purchase: " + e.Message));
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,11 +164,13 @@ namespace WordsToolkit.Scripts.Services.IAP
|
||||
public void OnPurchaseFailed(Product product, PurchaseFailureDescription failureDescription)
|
||||
{
|
||||
Debug.Log("OnPurchaseFailed: FAIL. Product: " + product.definition.id + " PurchaseFailureDescription: " + failureDescription);
|
||||
OnFailedPurchase?.Invoke((product.definition.id, failureDescription.message));
|
||||
}
|
||||
|
||||
public void OnPurchaseFailed(Product i, PurchaseFailureReason p)
|
||||
{
|
||||
Debug.Log($"OnPurchaseFailed: FAIL. Product: '{i.definition.id}', PurchaseFailureReason: {p}");
|
||||
OnFailedPurchase?.Invoke((i.definition.id, p.ToString()));
|
||||
}
|
||||
|
||||
public void OnInitializeFailed(InitializationFailureReason reason)
|
||||
|
||||
57
Assets/WordConnectGameToolkit/Scripts/Services/IAP/IAPErr.cs
Normal file
57
Assets/WordConnectGameToolkit/Scripts/Services/IAP/IAPErr.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
|
||||
namespace WordsToolkit.Scripts.Services.IAP
|
||||
{
|
||||
/// <summary>
|
||||
/// IAP 典型错误类型枚举
|
||||
/// </summary>
|
||||
public enum IAPErrorType
|
||||
{
|
||||
None,
|
||||
UserCancelled,
|
||||
PaymentDeclined,
|
||||
InsufficientFunds,
|
||||
ProductUnavailable,
|
||||
DuplicateTransaction,
|
||||
NetworkError,
|
||||
NetworkUnavailable,
|
||||
IAPInitFailed,
|
||||
InvalidProductID,
|
||||
Unknown
|
||||
}
|
||||
|
||||
public static class IAPErrorHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据错误信息字符串,提取并映射到 IAPErrorType 枚举
|
||||
/// </summary>
|
||||
public static IAPErrorType ParseError(string errorMessage)
|
||||
{
|
||||
if (string.IsNullOrEmpty(errorMessage))
|
||||
return IAPErrorType.Unknown;
|
||||
|
||||
errorMessage = errorMessage.ToLowerInvariant();
|
||||
|
||||
if (errorMessage.Contains("usercancelled") || errorMessage.Contains("user cancelled"))
|
||||
return IAPErrorType.UserCancelled;
|
||||
if (errorMessage.Contains("paymentdeclined") || errorMessage.Contains("payment declined"))
|
||||
return IAPErrorType.PaymentDeclined;
|
||||
if (errorMessage.Contains("insufficientfunds") || errorMessage.Contains("insufficient funds"))
|
||||
return IAPErrorType.InsufficientFunds;
|
||||
if (errorMessage.Contains("productunavailable") || errorMessage.Contains("product unavailable"))
|
||||
return IAPErrorType.ProductUnavailable;
|
||||
if (errorMessage.Contains("duplicatetransaction") || errorMessage.Contains("duplicate transaction"))
|
||||
return IAPErrorType.DuplicateTransaction;
|
||||
if (errorMessage.Contains("networkerror") || errorMessage.Contains("network error"))
|
||||
return IAPErrorType.NetworkError;
|
||||
if (errorMessage.Contains("networkunavailable") || errorMessage.Contains("network unavailable"))
|
||||
return IAPErrorType.NetworkUnavailable;
|
||||
if (errorMessage.Contains("InvalidProductID".ToLowerInvariant()) )
|
||||
return IAPErrorType.InvalidProductID;
|
||||
if (errorMessage.Contains("IAPInitFailed".ToLowerInvariant()))
|
||||
return IAPErrorType.IAPInitFailed;
|
||||
|
||||
return IAPErrorType.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03eff658508844cfd91bab5657295e76
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -50,6 +50,12 @@ namespace WordsToolkit.Scripts.Services.IAP
|
||||
IAPController.OnSuccessfulPurchase += purchaseHandler;
|
||||
#endif
|
||||
}
|
||||
public void SubscribeToPurchaseFailedEvent(Action<(string, string)> purchaseHandler)
|
||||
{
|
||||
#if UNITY_PURCHASING
|
||||
IAPController.OnFailedPurchase += purchaseHandler;
|
||||
#endif
|
||||
}
|
||||
|
||||
public void UnsubscribeFromPurchaseEvent(Action<string> purchaseHandler)
|
||||
{
|
||||
|
||||
@ -13,6 +13,8 @@ namespace WordsToolkit.Scripts.Services.IAP
|
||||
bool IsProductPurchased(string productId);
|
||||
void RestorePurchases(Action<bool, List<string>> action);
|
||||
void SubscribeToPurchaseEvent(Action<string> purchaseHandler);
|
||||
|
||||
void SubscribeToPurchaseFailedEvent(Action<(string, string)> purchaseHandler);
|
||||
void UnsubscribeFromPurchaseEvent(Action<string> purchaseHandler);
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,11 @@
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:d3bf71b33c0c04eb9bc1a8d6513d76bb",
|
||||
"GUID:00dd4a7ac8c24c898083910c81898ecc"
|
||||
"GUID:00dd4a7ac8c24c898083910c81898ecc",
|
||||
"GUID:ac6e78962cfc743b9a5fc5f5a808aa72",
|
||||
"GUID:b25ad8286798741e3b2cc3883283e669",
|
||||
"GUID:75bdbcf23199f4cfb86c610d1d946666",
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
|
||||
@ -103,6 +103,7 @@ namespace WordsToolkit.Scripts.System
|
||||
language = langName;
|
||||
EventManager.GetEvent<string>(EGameEvent.LanguageChanged).Subscribe(LanguageChanged);
|
||||
iapManager.SubscribeToPurchaseEvent(PurchaseSucceeded);
|
||||
iapManager.SubscribeToPurchaseFailedEvent(PurchaseFailed);
|
||||
|
||||
stateManager.OnStateChanged.AddListener((state) => {
|
||||
if (state != EScreenStates.MainMenu)
|
||||
@ -229,6 +230,11 @@ namespace WordsToolkit.Scripts.System
|
||||
{
|
||||
EventManager.GetEvent<string>(EGameEvent.PurchaseSucceeded).Invoke(id);
|
||||
}
|
||||
public void PurchaseFailed((string, string) info)
|
||||
{
|
||||
EventManager.GetEvent<(string, string)>(EGameEvent.PurchaseFailed).Invoke(info);
|
||||
}
|
||||
|
||||
|
||||
public void SetGameMode(EGameMode gameMode)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user