From 018fb2c35bc09d06a85e671a7f5656ecff024be5 Mon Sep 17 00:00:00 2001 From: huyufei Date: Sun, 11 Aug 2024 21:31:25 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Code/Model/GuruSDKModel.cs | 37 +++++++++------------------ Runtime/Code/SDK/GuruSDK.Analytics.cs | 2 ++ Runtime/Code/SDK/GuruSDK.cs | 20 --------------- 3 files changed, 14 insertions(+), 45 deletions(-) diff --git a/Runtime/Code/Model/GuruSDKModel.cs b/Runtime/Code/Model/GuruSDKModel.cs index 71af8ee..026b3d2 100644 --- a/Runtime/Code/Model/GuruSDKModel.cs +++ b/Runtime/Code/Model/GuruSDKModel.cs @@ -3,7 +3,6 @@ namespace Guru using System; using UnityEngine; using System.Collections.Generic; - using Newtonsoft.Json; using System.Linq; @@ -38,8 +37,8 @@ namespace Guru private DateTime _lastSavedTime = new DateTime(1970,1,1); private bool _noAds = false; - private readonly BindableProperty _bLevel; - private readonly BindableProperty _bPlay; + private int _bLevel; + private int _bPlay; private string _uid; private List _purchased; @@ -60,33 +59,33 @@ namespace Guru GuruSDKSerializedModel model = LoadModel(); _uid = model.uid; _noAds = model.no_ads; - _bLevel = new BindableProperty(model.b_level); - _bPlay = new BindableProperty(model.b_play); + _bLevel = model.b_level; + _bPlay = model.b_play; _purchased = model.purchased; } public int BLevel { - get => _bLevel.Value; + get => _bLevel; set { - if (value < _bLevel.Value) + if (value < _bLevel) { // b_level 必须比上一次的值大 - Debug.LogWarning($"[SDK] :: Set b_level [{value}] should not be less than original value [{_bLevel.Value}]"); + Debug.LogWarning($"[SDK] :: Set b_level [{value}] should not be less than original value [{_bLevel}]"); return; } - _bLevel.Value = value; + _bLevel = value; Save(); } } public int BPlay { - get => _bPlay.Value; + get => _bPlay; set { - _bPlay.Value = value; + _bPlay = value; Save(); } } @@ -113,18 +112,7 @@ namespace Guru Save(); } } - - public void SetOnBLevelChanged(Action action) - { - _bLevel.OnValueChanged += action; - } - public void SetOnBPlayChanged(Action action) - { - _bPlay.OnValueChanged += action; - } - - #region 初始化 @@ -153,14 +141,13 @@ namespace Guru /// /// 保存至 PlayerPrefs 数据 /// - /// private void SetToMemory() { var model = new GuruSDKSerializedModel() { uid = _uid, - b_level = _bLevel.Value, - b_play = _bPlay.Value, + b_level = _bLevel, + b_play = _bPlay, no_ads = _noAds, purchased = _purchased, }; diff --git a/Runtime/Code/SDK/GuruSDK.Analytics.cs b/Runtime/Code/SDK/GuruSDK.Analytics.cs index 82f122f..7d69ba1 100644 --- a/Runtime/Code/SDK/GuruSDK.Analytics.cs +++ b/Runtime/Code/SDK/GuruSDK.Analytics.cs @@ -57,11 +57,13 @@ namespace Guru public static void SetUserBLevel(int bLevel) { + Analytics.SetBLevel(bLevel); Model.BLevel = bLevel; } public static void SetUserBPlay(int bPlay) { + Analytics.SetBPlay(bPlay); Model.BPlay = bPlay; } diff --git a/Runtime/Code/SDK/GuruSDK.cs b/Runtime/Code/SDK/GuruSDK.cs index b554679..bbdc1ac 100644 --- a/Runtime/Code/SDK/GuruSDK.cs +++ b/Runtime/Code/SDK/GuruSDK.cs @@ -111,9 +111,6 @@ namespace Guru /// private void StartWithConfig(GuruSDKInitConfig config, Action onComplete) { - Model.SetOnBLevelChanged(OnBLevelChanged); - Model.SetOnBPlayChanged(OnBPlayChanged); - IsInitialSuccess = false; _initConfig = config; _isDebugEnabled = config.DebugMode; @@ -416,23 +413,6 @@ namespace Guru CheckAttStatus(); } #endif - #endregion - - #region 数据 - - private void OnBLevelChanged(int bLevel) - { - Debug.Log($"[ANU][SDK] --- OnBLevelChanged: {bLevel}"); - Analytics.SetBLevel(bLevel); - } - - private void OnBPlayChanged(int bPlay) - { - Debug.Log($"[ANU][SDK] --- OnBPlayChanged: {bPlay}"); - Analytics.SetBPlay(bPlay); - } - - #endregion #region Logging