update: 更新应用配置逻辑
parent
17f30fe445
commit
4f3ab222c3
|
|
@ -15,13 +15,13 @@ namespace Guru.Editor
|
||||||
private static string DefaultFilePath =
|
private static string DefaultFilePath =
|
||||||
Path.GetFullPath(Path.Combine(Application.dataPath, $"{DefaultFileName}.json"));
|
Path.GetFullPath(Path.Combine(Application.dataPath, $"{DefaultFileName}.json"));
|
||||||
|
|
||||||
private static string _selectedFilePath = "";
|
internal static string EmbededServiceFilePath = "";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载配置
|
/// 加载配置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static GuruServiceConfig LoadConfig()
|
public static GuruServicesConfig LoadConfig()
|
||||||
{
|
{
|
||||||
var a = AssetDatabase.FindAssets($"*{DefaultFileName}* t:TextAsset");
|
var a = AssetDatabase.FindAssets($"*{DefaultFileName}* t:TextAsset");
|
||||||
if (a == null || a.Length == 0)
|
if (a == null || a.Length == 0)
|
||||||
|
|
@ -32,10 +32,10 @@ namespace Guru.Editor
|
||||||
{
|
{
|
||||||
var p = AssetDatabase.GUIDToAssetPath(a[0]);
|
var p = AssetDatabase.GUIDToAssetPath(a[0]);
|
||||||
var fp = Path.GetFullPath(p);
|
var fp = Path.GetFullPath(p);
|
||||||
if (File.Exists(fp)) _selectedFilePath = fp;
|
if (File.Exists(fp)) EmbededServiceFilePath = fp;
|
||||||
var t = AssetDatabase.LoadAssetAtPath<TextAsset>(p);
|
var t = AssetDatabase.LoadAssetAtPath<TextAsset>(p);
|
||||||
// Debug.Log($"<color=#88ff00>--- find services file:{p} \n{t.text}</color>");
|
// Debug.Log($"<color=#88ff00>--- find services file:{p} \n{t.text}</color>");
|
||||||
return JsonMapper.ToObject<GuruServiceConfig>(t.text);
|
return JsonMapper.ToObject<GuruServicesConfig>(t.text);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -44,11 +44,11 @@ namespace Guru.Editor
|
||||||
/// 保存配置
|
/// 保存配置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config"></param>
|
||||||
internal static void SaveConfig(GuruServiceConfig config = null)
|
internal static void SaveConfig(GuruServicesConfig config = null)
|
||||||
{
|
{
|
||||||
if (config == null)
|
if (config == null)
|
||||||
{
|
{
|
||||||
config = new GuruServiceConfig();
|
config = new GuruServicesConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
var jw = new JsonWriter()
|
var jw = new JsonWriter()
|
||||||
|
|
@ -59,19 +59,19 @@ namespace Guru.Editor
|
||||||
|
|
||||||
var json = jw.ToString();
|
var json = jw.ToString();
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(_selectedFilePath)) _selectedFilePath = DefaultFilePath;
|
if (string.IsNullOrEmpty(EmbededServiceFilePath)) EmbededServiceFilePath = DefaultFilePath;
|
||||||
File.WriteAllText(_selectedFilePath, json);
|
File.WriteAllText(EmbededServiceFilePath, json);
|
||||||
Debug.Log($"Save config to {_selectedFilePath}");
|
Debug.Log($"Save config to {EmbededServiceFilePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建空配置
|
/// 创建空配置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
internal static GuruServiceConfig CreateEmpty()
|
internal static GuruServicesConfig CreateEmpty()
|
||||||
{
|
{
|
||||||
var cfg = new GuruServiceConfig();
|
var cfg = new GuruServicesConfig();
|
||||||
cfg.version = GuruSDK.Version;
|
cfg.version = 0;
|
||||||
cfg.app_settings = new GuruAppSettings();
|
cfg.app_settings = new GuruAppSettings();
|
||||||
cfg.ad_settings = new GuruAdSettings();
|
cfg.ad_settings = new GuruAdSettings();
|
||||||
cfg.adjust_settings = new GuruAdjustSettings();
|
cfg.adjust_settings = new GuruAdjustSettings();
|
||||||
|
|
@ -88,6 +88,25 @@ namespace Guru.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void DeployAppServiceFile()
|
||||||
|
{
|
||||||
|
var streamingPath = Application.streamingAssetsPath;
|
||||||
|
if(!Directory.Exists(streamingPath)) Directory.CreateDirectory(streamingPath);
|
||||||
|
var path = Path.Combine(streamingPath, $"{GuruSDK.ServicesConfigKey}.{GuruSDK.ServicesConfigExtension}");
|
||||||
|
|
||||||
|
var config = LoadConfig();
|
||||||
|
var from = EmbededServiceFilePath;
|
||||||
|
if (string.IsNullOrEmpty(from) || !File.Exists(from)) // 文件不存在
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null != config)
|
||||||
|
{
|
||||||
|
if (File.Exists(path)) File.Delete(path);
|
||||||
|
Debug.Log($"<color=#88ff00> --- setup {GuruSDK.ServicesConfigKey} file on streamingPath</color>");
|
||||||
|
File.Copy(from, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -32,38 +32,12 @@ namespace Guru.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[InitializeOnLoad]
|
||||||
|
|
||||||
// [InitializeOnLoad]
|
|
||||||
internal class BoostOnLoad
|
internal class BoostOnLoad
|
||||||
{
|
{
|
||||||
static BoostOnLoad()
|
static BoostOnLoad()
|
||||||
{
|
{
|
||||||
var config = EditorGuruServiceIO.LoadConfig();
|
EditorGuruServiceIO.DeployAppServiceFile();
|
||||||
if (null != config)
|
|
||||||
{
|
|
||||||
Debug.Log("<color=#88ff00>found guru-services file on disk</color>");
|
|
||||||
// TODO:
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Log("<color=yellow>Can't find guru-services.json on load...</color>");
|
|
||||||
// GuruSDKManager.Open();
|
|
||||||
EditorGuruServiceIO.LoadConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,18 +1,13 @@
|
||||||
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using Facebook.Unity.Settings;
|
|
||||||
using UnityEditor.Compilation;
|
|
||||||
|
|
||||||
namespace Guru.Editor
|
namespace Guru.Editor
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Guru;
|
using Guru;
|
||||||
using AppLovinMax.Scripts.IntegrationManager.Editor;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using Facebook.Unity.Settings;
|
||||||
|
using UnityEditor.Compilation;
|
||||||
|
|
||||||
public class GuruSDKManager: EditorWindow
|
public class GuruSDKManager: EditorWindow
|
||||||
{
|
{
|
||||||
|
|
@ -35,7 +30,7 @@ namespace Guru.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GuruServiceConfig _serviceConfig;
|
private GuruServicesConfig _servicesConfig;
|
||||||
private static GUIStyle _itemTitleStyle;
|
private static GUIStyle _itemTitleStyle;
|
||||||
private static GUIStyle StyleItemTitle
|
private static GUIStyle StyleItemTitle
|
||||||
{
|
{
|
||||||
|
|
@ -74,8 +69,8 @@ namespace Guru.Editor
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
titleContent = new GUIContent("Guru SDK Manager");
|
titleContent = new GUIContent("Guru SDK Manager");
|
||||||
_serviceConfig = EditorGuruServiceIO.LoadConfig();
|
_servicesConfig = EditorGuruServiceIO.LoadConfig();
|
||||||
if (_serviceConfig != null)
|
if (_servicesConfig != null)
|
||||||
{
|
{
|
||||||
Debug.Log($"<color=#88ff00>[Guru] Load <guru-services> success.</color>");
|
Debug.Log($"<color=#88ff00>[Guru] Load <guru-services> success.</color>");
|
||||||
CheckServicesCompletion();
|
CheckServicesCompletion();
|
||||||
|
|
@ -108,7 +103,7 @@ namespace Guru.Editor
|
||||||
string mk_no = " ( \u2718 ) ";
|
string mk_no = " ( \u2718 ) ";
|
||||||
string mk_star = " ( \u2605 ) ";
|
string mk_star = " ( \u2605 ) ";
|
||||||
string check_passed = $"{MARK_INDENT}{mk_yes} All items passed!";
|
string check_passed = $"{MARK_INDENT}{mk_yes} All items passed!";
|
||||||
if (_serviceConfig == null)
|
if (_servicesConfig == null)
|
||||||
{
|
{
|
||||||
AddResultLine($"{mk_yes} guru-services is missing", false);
|
AddResultLine($"{mk_yes} guru-services is missing", false);
|
||||||
AddResultLine($"Please contact Guru tech support to get help.", false);
|
AddResultLine($"Please contact Guru tech support to get help.", false);
|
||||||
|
|
@ -123,7 +118,7 @@ namespace Guru.Editor
|
||||||
//-------- APP Settings --------
|
//-------- APP Settings --------
|
||||||
passed = true;
|
passed = true;
|
||||||
AddResultLine($"[ App ]");
|
AddResultLine($"[ App ]");
|
||||||
if (_serviceConfig.app_settings == null)
|
if (_servicesConfig.app_settings == null)
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} settings is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} settings is missing!", false);
|
||||||
|
|
@ -131,25 +126,25 @@ namespace Guru.Editor
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_serviceConfig.app_settings.app_id.IsNullOrEmpty())
|
if (_servicesConfig.app_settings.app_id.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} AppID is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} AppID is missing!", false);
|
||||||
_serviceCriticalFail++;
|
_serviceCriticalFail++;
|
||||||
}
|
}
|
||||||
if (_serviceConfig.app_settings.bundle_id.IsNullOrEmpty())
|
if (_servicesConfig.app_settings.bundle_id.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} BundleID is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} BundleID is missing!", false);
|
||||||
_serviceCriticalFail++;
|
_serviceCriticalFail++;
|
||||||
}
|
}
|
||||||
if (_serviceConfig.app_settings.product_name.IsNullOrEmpty())
|
if (_servicesConfig.app_settings.product_name.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Product Name is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Product Name is missing!", false);
|
||||||
_serviceCriticalFail++;
|
_serviceCriticalFail++;
|
||||||
}
|
}
|
||||||
if (_serviceConfig.app_settings.support_email.IsNullOrEmpty())
|
if (_servicesConfig.app_settings.support_email.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Support Email is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Support Email is missing!", false);
|
||||||
|
|
@ -162,7 +157,7 @@ namespace Guru.Editor
|
||||||
//-------- ADS Settings --------
|
//-------- ADS Settings --------
|
||||||
passed = true;
|
passed = true;
|
||||||
AddResultLine($"[ Ads ]");
|
AddResultLine($"[ Ads ]");
|
||||||
if (_serviceConfig.ad_settings == null)
|
if (_servicesConfig.ad_settings == null)
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} settings is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} settings is missing!", false);
|
||||||
|
|
@ -170,61 +165,61 @@ namespace Guru.Editor
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_serviceConfig.ad_settings.sdk_key.IsNullOrEmpty())
|
if (_servicesConfig.ad_settings.sdk_key.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} SDK Key is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} SDK Key is missing!", false);
|
||||||
_serviceCriticalFail++;
|
_serviceCriticalFail++;
|
||||||
}
|
}
|
||||||
if (!IsArrayNotEmpty(_serviceConfig.ad_settings.admob_app_id))
|
if (!IsArrayNotEmpty(_servicesConfig.ad_settings.admob_app_id))
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Admob ID is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Admob ID is missing!", false);
|
||||||
_serviceCriticalFail++;
|
_serviceCriticalFail++;
|
||||||
}
|
}
|
||||||
if (!IsArrayNotEmpty(_serviceConfig.ad_settings.max_ids_android))
|
if (!IsArrayNotEmpty(_servicesConfig.ad_settings.max_ids_android))
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} AppLovin Android IDs is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} AppLovin Android IDs is missing!", false);
|
||||||
_serviceCriticalFail++;
|
_serviceCriticalFail++;
|
||||||
}
|
}
|
||||||
if (!IsArrayNotEmpty(_serviceConfig.ad_settings.max_ids_ios))
|
if (!IsArrayNotEmpty(_servicesConfig.ad_settings.max_ids_ios))
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} AppLovin iOS IDs is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} AppLovin iOS IDs is missing!", false);
|
||||||
_serviceCriticalFail++;
|
_serviceCriticalFail++;
|
||||||
}
|
}
|
||||||
if (!IsArrayNotEmpty(_serviceConfig.ad_settings.amazon_ids_android))
|
if (!IsArrayNotEmpty(_servicesConfig.ad_settings.amazon_ids_android))
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Amazon Android IDs is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Amazon Android IDs is missing!", false);
|
||||||
_serviceCriticalFail++;
|
_serviceCriticalFail++;
|
||||||
}
|
}
|
||||||
if (!IsArrayNotEmpty(_serviceConfig.ad_settings.amazon_ids_ios))
|
if (!IsArrayNotEmpty(_servicesConfig.ad_settings.amazon_ids_ios))
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Amazon iOS IDs is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Amazon iOS IDs is missing!", false);
|
||||||
_serviceCriticalFail++;
|
_serviceCriticalFail++;
|
||||||
}
|
}
|
||||||
if (!IsArrayNotEmpty(_serviceConfig.ad_settings.pubmatic_ids_android))
|
if (!IsArrayNotEmpty(_servicesConfig.ad_settings.pubmatic_ids_android))
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Pubmatic Android IDs is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Pubmatic Android IDs is missing!", false);
|
||||||
_serviceCriticalFail++;
|
_serviceCriticalFail++;
|
||||||
}
|
}
|
||||||
if (!IsArrayNotEmpty(_serviceConfig.ad_settings.pubmatic_ids_ios))
|
if (!IsArrayNotEmpty(_servicesConfig.ad_settings.pubmatic_ids_ios))
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Pubmatic iOS IDs is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Pubmatic iOS IDs is missing!", false);
|
||||||
_serviceCriticalFail++;
|
_serviceCriticalFail++;
|
||||||
}
|
}
|
||||||
if (!IsArrayNotEmpty(_serviceConfig.ad_settings.moloco_ids_android))
|
if (!IsArrayNotEmpty(_servicesConfig.ad_settings.moloco_ids_android))
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Moloco Android Test IDs is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Moloco Android Test IDs is missing!", false);
|
||||||
_serviceNormalFail++;
|
_serviceNormalFail++;
|
||||||
}
|
}
|
||||||
if (!IsArrayNotEmpty(_serviceConfig.ad_settings.moloco_ids_ios))
|
if (!IsArrayNotEmpty(_servicesConfig.ad_settings.moloco_ids_ios))
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Moloco iOS Test IDs is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Moloco iOS Test IDs is missing!", false);
|
||||||
|
|
@ -236,7 +231,7 @@ namespace Guru.Editor
|
||||||
//-------- Channels Settings --------
|
//-------- Channels Settings --------
|
||||||
passed = true;
|
passed = true;
|
||||||
AddResultLine($"[ Channels ]");
|
AddResultLine($"[ Channels ]");
|
||||||
if (_serviceConfig.fb_settings == null)
|
if (_servicesConfig.fb_settings == null)
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Facebook settings is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Facebook settings is missing!", false);
|
||||||
|
|
@ -244,13 +239,13 @@ namespace Guru.Editor
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_serviceConfig.fb_settings.app_id.IsNullOrEmpty())
|
if (_servicesConfig.fb_settings.app_id.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Facebook AppID is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Facebook AppID is missing!", false);
|
||||||
_serviceCriticalFail++;
|
_serviceCriticalFail++;
|
||||||
}
|
}
|
||||||
if (_serviceConfig.fb_settings.client_token.IsNullOrEmpty())
|
if (_servicesConfig.fb_settings.client_token.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Facebook Client Token is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Facebook Client Token is missing!", false);
|
||||||
|
|
@ -258,7 +253,7 @@ namespace Guru.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_serviceConfig.adjust_settings == null)
|
if (_servicesConfig.adjust_settings == null)
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Adjust settings is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Adjust settings is missing!", false);
|
||||||
|
|
@ -266,14 +261,14 @@ namespace Guru.Editor
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!IsArrayNotEmpty(_serviceConfig.adjust_settings.app_token))
|
if(!IsArrayNotEmpty(_servicesConfig.adjust_settings.app_token))
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Adjust AppToken is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Adjust AppToken is missing!", false);
|
||||||
_serviceCriticalFail++;
|
_serviceCriticalFail++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsArrayNotEmpty(_serviceConfig.adjust_settings.events))
|
if (!IsArrayNotEmpty(_servicesConfig.adjust_settings.events))
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Adjust Events is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Adjust Events is missing!", false);
|
||||||
|
|
@ -285,7 +280,7 @@ namespace Guru.Editor
|
||||||
//-------- IAP --------
|
//-------- IAP --------
|
||||||
passed = true;
|
passed = true;
|
||||||
AddResultLine($"[ IAP ]");
|
AddResultLine($"[ IAP ]");
|
||||||
if (!IsArrayNotEmpty(_serviceConfig.products))
|
if (!IsArrayNotEmpty(_servicesConfig.products))
|
||||||
{
|
{
|
||||||
passed = false;
|
passed = false;
|
||||||
AddResultLine($"{MARK_INDENT}{mk_no} Product list is missing!", false);
|
AddResultLine($"{MARK_INDENT}{mk_no} Product list is missing!", false);
|
||||||
|
|
@ -347,7 +342,7 @@ namespace Guru.Editor
|
||||||
GUI_WindowTitle();
|
GUI_WindowTitle();
|
||||||
|
|
||||||
// CONTENT
|
// CONTENT
|
||||||
if (_serviceConfig == null)
|
if (_servicesConfig == null)
|
||||||
{
|
{
|
||||||
GUI_OnConfigDisabled();
|
GUI_OnConfigDisabled();
|
||||||
}
|
}
|
||||||
|
|
@ -447,6 +442,8 @@ namespace Guru.Editor
|
||||||
ApplyMods();
|
ApplyMods();
|
||||||
EditorUtility.DisplayCancelableProgressBar(barTitle, "All Mods is done", 0.8f);
|
EditorUtility.DisplayCancelableProgressBar(barTitle, "All Mods is done", 0.8f);
|
||||||
|
|
||||||
|
EditorGuruServiceIO.DeployAppServiceFile(); // 部署文件
|
||||||
|
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
|
|
||||||
CompilationPipeline.RequestScriptCompilation();
|
CompilationPipeline.RequestScriptCompilation();
|
||||||
|
|
@ -473,13 +470,13 @@ namespace Guru.Editor
|
||||||
AssetDatabase.CreateAsset(settings, GURU_SETTINGS_PATH);
|
AssetDatabase.CreateAsset(settings, GURU_SETTINGS_PATH);
|
||||||
}
|
}
|
||||||
settings.CompanyName = "Guru";
|
settings.CompanyName = "Guru";
|
||||||
settings.ProductName = _serviceConfig.app_settings.product_name;
|
settings.ProductName = _servicesConfig.app_settings.product_name;
|
||||||
settings.GameIdentifier = _serviceConfig.app_settings.bundle_id;
|
settings.GameIdentifier = _servicesConfig.app_settings.bundle_id;
|
||||||
settings.PriacyUrl = _serviceConfig.app_settings.privacy_url;
|
settings.PriacyUrl = _servicesConfig.app_settings.privacy_url;
|
||||||
settings.TermsUrl = _serviceConfig.app_settings.terms_url;
|
settings.TermsUrl = _servicesConfig.app_settings.terms_url;
|
||||||
settings.SupportEmail = _serviceConfig.app_settings.support_email;
|
settings.SupportEmail = _servicesConfig.app_settings.support_email;
|
||||||
settings.AndroidStoreUrl = _serviceConfig.app_settings.android_store;
|
settings.AndroidStoreUrl = _servicesConfig.app_settings.android_store;
|
||||||
settings.IOSStoreUrl = _serviceConfig.app_settings.ios_store;
|
settings.IOSStoreUrl = _servicesConfig.app_settings.ios_store;
|
||||||
|
|
||||||
SerializedObject so = new SerializedObject(settings);
|
SerializedObject so = new SerializedObject(settings);
|
||||||
SerializedProperty n;
|
SerializedProperty n;
|
||||||
|
|
@ -491,10 +488,13 @@ namespace Guru.Editor
|
||||||
if (null != n)
|
if (null != n)
|
||||||
{
|
{
|
||||||
p = n.serializedObject.FindProperty("IPMSetting.appID");
|
p = n.serializedObject.FindProperty("IPMSetting.appID");
|
||||||
p.stringValue = _serviceConfig.app_settings.app_id;
|
p.stringValue = _servicesConfig.app_settings.app_id;
|
||||||
|
|
||||||
p = n.serializedObject.FindProperty("IPMSetting.tokenValidTime");
|
if (_servicesConfig.app_settings.token_vaild_time > 0)
|
||||||
p.intValue = _serviceConfig.app_settings.token_vaild_time;
|
{
|
||||||
|
p = n.serializedObject.FindProperty("IPMSetting.tokenValidTime");
|
||||||
|
p.intValue = _servicesConfig.app_settings.token_vaild_time;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------- AMAZON -----------------------
|
//---------- AMAZON -----------------------
|
||||||
|
|
@ -504,7 +504,7 @@ namespace Guru.Editor
|
||||||
p = n.serializedObject.FindProperty("AmazonSetting.Enable");
|
p = n.serializedObject.FindProperty("AmazonSetting.Enable");
|
||||||
p.boolValue = true;
|
p.boolValue = true;
|
||||||
|
|
||||||
arr = _serviceConfig.ad_settings.amazon_ids_android;
|
arr = _servicesConfig.ad_settings.amazon_ids_android;
|
||||||
if (IsArrayHasLength(arr, 4))
|
if (IsArrayHasLength(arr, 4))
|
||||||
{
|
{
|
||||||
p = n.serializedObject.FindProperty("AmazonSetting.Android.appID");
|
p = n.serializedObject.FindProperty("AmazonSetting.Android.appID");
|
||||||
|
|
@ -517,7 +517,7 @@ namespace Guru.Editor
|
||||||
p.stringValue = arr[3];
|
p.stringValue = arr[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
arr = _serviceConfig.ad_settings.amazon_ids_ios;
|
arr = _servicesConfig.ad_settings.amazon_ids_ios;
|
||||||
if (IsArrayHasLength(arr, 4))
|
if (IsArrayHasLength(arr, 4))
|
||||||
{
|
{
|
||||||
p = n.serializedObject.FindProperty("AmazonSetting.iOS.appID");
|
p = n.serializedObject.FindProperty("AmazonSetting.iOS.appID");
|
||||||
|
|
@ -538,7 +538,7 @@ namespace Guru.Editor
|
||||||
p = n.serializedObject.FindProperty("PubmaticSetting.Enable");
|
p = n.serializedObject.FindProperty("PubmaticSetting.Enable");
|
||||||
p.boolValue = true;
|
p.boolValue = true;
|
||||||
|
|
||||||
arr = _serviceConfig.ad_settings.pubmatic_ids_android;
|
arr = _servicesConfig.ad_settings.pubmatic_ids_android;
|
||||||
if (IsArrayHasLength(arr, 4))
|
if (IsArrayHasLength(arr, 4))
|
||||||
{
|
{
|
||||||
p = n.serializedObject.FindProperty("PubmaticSetting.Android.storeUrl");
|
p = n.serializedObject.FindProperty("PubmaticSetting.Android.storeUrl");
|
||||||
|
|
@ -551,7 +551,7 @@ namespace Guru.Editor
|
||||||
p.stringValue = arr[3];
|
p.stringValue = arr[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
arr = _serviceConfig.ad_settings.pubmatic_ids_ios;
|
arr = _servicesConfig.ad_settings.pubmatic_ids_ios;
|
||||||
if (IsArrayHasLength(arr, 4))
|
if (IsArrayHasLength(arr, 4))
|
||||||
{
|
{
|
||||||
p = n.serializedObject.FindProperty("PubmaticSetting.iOS.storeUrl");
|
p = n.serializedObject.FindProperty("PubmaticSetting.iOS.storeUrl");
|
||||||
|
|
@ -572,7 +572,7 @@ namespace Guru.Editor
|
||||||
p = n.serializedObject.FindProperty("MolocoSetting.Enable");
|
p = n.serializedObject.FindProperty("MolocoSetting.Enable");
|
||||||
p.boolValue = true;
|
p.boolValue = true;
|
||||||
|
|
||||||
arr = _serviceConfig.ad_settings.moloco_ids_android;
|
arr = _servicesConfig.ad_settings.moloco_ids_android;
|
||||||
if (IsArrayHasLength(arr, 3))
|
if (IsArrayHasLength(arr, 3))
|
||||||
{
|
{
|
||||||
p = n.serializedObject.FindProperty("MolocoSetting.Android.bannerTestUnitID");
|
p = n.serializedObject.FindProperty("MolocoSetting.Android.bannerTestUnitID");
|
||||||
|
|
@ -583,7 +583,7 @@ namespace Guru.Editor
|
||||||
p.stringValue = arr[2];
|
p.stringValue = arr[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
arr = _serviceConfig.ad_settings.moloco_ids_ios;
|
arr = _servicesConfig.ad_settings.moloco_ids_ios;
|
||||||
if (IsArrayHasLength(arr, 3))
|
if (IsArrayHasLength(arr, 3))
|
||||||
{
|
{
|
||||||
p = n.serializedObject.FindProperty("MolocoSetting.iOS.bannerTestUnitID");
|
p = n.serializedObject.FindProperty("MolocoSetting.iOS.bannerTestUnitID");
|
||||||
|
|
@ -600,9 +600,9 @@ namespace Guru.Editor
|
||||||
if (null != n)
|
if (null != n)
|
||||||
{
|
{
|
||||||
p = n.serializedObject.FindProperty("ADSetting.SDK_KEY");
|
p = n.serializedObject.FindProperty("ADSetting.SDK_KEY");
|
||||||
p.stringValue = _serviceConfig.ad_settings.sdk_key;
|
p.stringValue = _servicesConfig.ad_settings.sdk_key;
|
||||||
|
|
||||||
arr = _serviceConfig.ad_settings.max_ids_android;
|
arr = _servicesConfig.ad_settings.max_ids_android;
|
||||||
if(IsArrayHasLength(arr, 3))
|
if(IsArrayHasLength(arr, 3))
|
||||||
{
|
{
|
||||||
p = n.serializedObject.FindProperty("ADSetting.Android_Banner_ID");
|
p = n.serializedObject.FindProperty("ADSetting.Android_Banner_ID");
|
||||||
|
|
@ -613,7 +613,7 @@ namespace Guru.Editor
|
||||||
p.stringValue = arr[2];
|
p.stringValue = arr[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
arr = _serviceConfig.ad_settings.max_ids_ios;
|
arr = _servicesConfig.ad_settings.max_ids_ios;
|
||||||
if (IsArrayHasLength(arr, 3))
|
if (IsArrayHasLength(arr, 3))
|
||||||
{
|
{
|
||||||
p = n.serializedObject.FindProperty("ADSetting.IOS_Banner_ID");
|
p = n.serializedObject.FindProperty("ADSetting.IOS_Banner_ID");
|
||||||
|
|
@ -628,13 +628,13 @@ namespace Guru.Editor
|
||||||
//----------- AdjustSetting -------------------
|
//----------- AdjustSetting -------------------
|
||||||
n = so.FindProperty("AdjustSetting");
|
n = so.FindProperty("AdjustSetting");
|
||||||
if (null != n
|
if (null != n
|
||||||
&& IsArrayHasLength(_serviceConfig.adjust_settings.app_token, 2))
|
&& IsArrayHasLength(_servicesConfig.adjust_settings.app_token, 2))
|
||||||
{
|
{
|
||||||
p = n.serializedObject.FindProperty("AdjustSetting.androidAppToken");
|
p = n.serializedObject.FindProperty("AdjustSetting.androidAppToken");
|
||||||
p.stringValue = _serviceConfig.adjust_settings.app_token[0];
|
p.stringValue = _servicesConfig.adjust_settings.app_token[0];
|
||||||
|
|
||||||
p = n.serializedObject.FindProperty("AdjustSetting.iOSAppToken");
|
p = n.serializedObject.FindProperty("AdjustSetting.iOSAppToken");
|
||||||
p.stringValue = _serviceConfig.adjust_settings.app_token[1];
|
p.stringValue = _servicesConfig.adjust_settings.app_token[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------- AnalyticsSetting -------------------
|
//----------- AnalyticsSetting -------------------
|
||||||
|
|
@ -642,20 +642,20 @@ namespace Guru.Editor
|
||||||
if (null != n)
|
if (null != n)
|
||||||
{
|
{
|
||||||
p = n.serializedObject.FindProperty("AnalyticsSetting.levelEndSuccessNum");
|
p = n.serializedObject.FindProperty("AnalyticsSetting.levelEndSuccessNum");
|
||||||
p.intValue = _serviceConfig.app_settings.level_end_success_num;
|
p.intValue = _servicesConfig.app_settings.level_end_success_num;
|
||||||
p = n.serializedObject.FindProperty("AnalyticsSetting.enalbeFirebaseAnalytics");
|
p = n.serializedObject.FindProperty("AnalyticsSetting.enalbeFirebaseAnalytics");
|
||||||
p.boolValue = _serviceConfig.app_settings.enable_firebase;
|
p.boolValue = _servicesConfig.app_settings.enable_firebase;
|
||||||
p = n.serializedObject.FindProperty("AnalyticsSetting.enalbeFacebookAnalytics");
|
p = n.serializedObject.FindProperty("AnalyticsSetting.enalbeFacebookAnalytics");
|
||||||
p.boolValue = _serviceConfig.app_settings.enable_facebook;
|
p.boolValue = _servicesConfig.app_settings.enable_facebook;
|
||||||
p = n.serializedObject.FindProperty("AnalyticsSetting.enalbeAdjustAnalytics");
|
p = n.serializedObject.FindProperty("AnalyticsSetting.enalbeAdjustAnalytics");
|
||||||
p.boolValue = _serviceConfig.app_settings.enable_adjust;
|
p.boolValue = _servicesConfig.app_settings.enable_adjust;
|
||||||
p = n.serializedObject.FindProperty("AnalyticsSetting.adjustEventList");
|
p = n.serializedObject.FindProperty("AnalyticsSetting.adjustEventList");
|
||||||
if (null != p && IsArrayNotEmpty(_serviceConfig.adjust_settings.events))
|
if (null != p && IsArrayNotEmpty(_servicesConfig.adjust_settings.events))
|
||||||
{
|
{
|
||||||
p.ClearArray();
|
p.ClearArray();
|
||||||
for (int i = 0; i < _serviceConfig.adjust_settings.events.Length; i++)
|
for (int i = 0; i < _servicesConfig.adjust_settings.events.Length; i++)
|
||||||
{
|
{
|
||||||
arr = _serviceConfig.adjust_settings.events[i].Split(",");
|
arr = _servicesConfig.adjust_settings.events[i].Split(",");
|
||||||
if (IsArrayHasLength(arr, 3))
|
if (IsArrayHasLength(arr, 3))
|
||||||
{
|
{
|
||||||
p.InsertArrayElementAtIndex(i);
|
p.InsertArrayElementAtIndex(i);
|
||||||
|
|
@ -670,12 +670,12 @@ namespace Guru.Editor
|
||||||
|
|
||||||
//---------------- Productions ------------------------
|
//---------------- Productions ------------------------
|
||||||
n = so.FindProperty("Products");
|
n = so.FindProperty("Products");
|
||||||
if (n != null && IsArrayNotEmpty(_serviceConfig.products))
|
if (n != null && IsArrayNotEmpty(_servicesConfig.products))
|
||||||
{
|
{
|
||||||
n.ClearArray();
|
n.ClearArray();
|
||||||
for (int i = 0; i < _serviceConfig.products.Length; i++)
|
for (int i = 0; i < _servicesConfig.products.Length; i++)
|
||||||
{
|
{
|
||||||
arr = _serviceConfig.products[i].Split(",");
|
arr = _servicesConfig.products[i].Split(",");
|
||||||
if (IsArrayHasLength(arr, 5))
|
if (IsArrayHasLength(arr, 5))
|
||||||
{
|
{
|
||||||
n.InsertArrayElementAtIndex(i);
|
n.InsertArrayElementAtIndex(i);
|
||||||
|
|
@ -715,11 +715,11 @@ namespace Guru.Editor
|
||||||
|
|
||||||
settings.SetAttributionReportEndpoint = true;
|
settings.SetAttributionReportEndpoint = true;
|
||||||
settings.QualityServiceEnabled = true;
|
settings.QualityServiceEnabled = true;
|
||||||
settings.SdkKey = _serviceConfig.ad_settings.sdk_key;
|
settings.SdkKey = _servicesConfig.ad_settings.sdk_key;
|
||||||
if (IsArrayHasLength(_serviceConfig.ad_settings.admob_app_id, 2))
|
if (IsArrayHasLength(_servicesConfig.ad_settings.admob_app_id, 2))
|
||||||
{
|
{
|
||||||
settings.AdMobAndroidAppId = _serviceConfig.ad_settings.admob_app_id[0];
|
settings.AdMobAndroidAppId = _servicesConfig.ad_settings.admob_app_id[0];
|
||||||
settings.AdMobIosAppId = _serviceConfig.ad_settings.admob_app_id[1];
|
settings.AdMobIosAppId = _servicesConfig.ad_settings.admob_app_id[1];
|
||||||
}
|
}
|
||||||
settings.ConsentFlowEnabled = false;
|
settings.ConsentFlowEnabled = false;
|
||||||
EditorUtility.SetDirty(settings);
|
EditorUtility.SetDirty(settings);
|
||||||
|
|
@ -748,7 +748,7 @@ namespace Guru.Editor
|
||||||
{
|
{
|
||||||
n.ClearArray();
|
n.ClearArray();
|
||||||
n.InsertArrayElementAtIndex(0);
|
n.InsertArrayElementAtIndex(0);
|
||||||
n.GetArrayElementAtIndex(0).stringValue = _serviceConfig.app_settings.product_name;
|
n.GetArrayElementAtIndex(0).stringValue = _servicesConfig.app_settings.product_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = so.FindProperty("appIds");
|
n = so.FindProperty("appIds");
|
||||||
|
|
@ -756,7 +756,7 @@ namespace Guru.Editor
|
||||||
{
|
{
|
||||||
n.ClearArray();
|
n.ClearArray();
|
||||||
n.InsertArrayElementAtIndex(0);
|
n.InsertArrayElementAtIndex(0);
|
||||||
n.GetArrayElementAtIndex(0).stringValue = _serviceConfig.fb_settings.app_id;
|
n.GetArrayElementAtIndex(0).stringValue = _servicesConfig.fb_settings.app_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = so.FindProperty("clientTokens");
|
n = so.FindProperty("clientTokens");
|
||||||
|
|
@ -764,7 +764,7 @@ namespace Guru.Editor
|
||||||
{
|
{
|
||||||
n.ClearArray();
|
n.ClearArray();
|
||||||
n.InsertArrayElementAtIndex(0);
|
n.InsertArrayElementAtIndex(0);
|
||||||
n.GetArrayElementAtIndex(0).stringValue = _serviceConfig.fb_settings.client_token;
|
n.GetArrayElementAtIndex(0).stringValue = _servicesConfig.fb_settings.client_token;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = so.FindProperty("androidKeystorePath");
|
n = so.FindProperty("androidKeystorePath");
|
||||||
|
|
@ -777,7 +777,7 @@ namespace Guru.Editor
|
||||||
|
|
||||||
private void ApplyMods()
|
private void ApplyMods()
|
||||||
{
|
{
|
||||||
PlayerSettings.applicationIdentifier = _serviceConfig.app_settings.bundle_id; // 设置包名
|
PlayerSettings.applicationIdentifier = _servicesConfig.app_settings.bundle_id; // 设置包名
|
||||||
|
|
||||||
#if UNITY_ANDROID
|
#if UNITY_ANDROID
|
||||||
AndroidManifestMod.Apply();
|
AndroidManifestMod.Apply();
|
||||||
|
|
@ -808,11 +808,6 @@ namespace Guru.Editor
|
||||||
}
|
}
|
||||||
private void GUI_Button(string label, Action content, GUIStyle style = null, params GUILayoutOption[] options)
|
private void GUI_Button(string label, Action content, GUIStyle style = null, params GUILayoutOption[] options)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (style != null)
|
if (style != null)
|
||||||
{
|
{
|
||||||
if (GUILayout.Button(label,style, options))
|
if (GUILayout.Button(label,style, options))
|
||||||
|
|
@ -827,8 +822,6 @@ namespace Guru.Editor
|
||||||
content?.Invoke();
|
content?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ namespace Guru
|
||||||
{
|
{
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class GuruServiceConfig
|
public class GuruServicesConfig
|
||||||
{
|
{
|
||||||
public string version;
|
public long version = 0;
|
||||||
public GuruAppSettings app_settings;
|
public GuruAppSettings app_settings;
|
||||||
public GuruAdjustSettings adjust_settings;
|
public GuruAdjustSettings adjust_settings;
|
||||||
public GuruFbSettings fb_settings;
|
public GuruFbSettings fb_settings;
|
||||||
|
|
@ -37,8 +37,6 @@ namespace Guru
|
||||||
ad_settings.moloco_ids_ios != null &&
|
ad_settings.moloco_ids_ios != null &&
|
||||||
ad_settings.moloco_ids_ios.Length > 0;
|
ad_settings.moloco_ids_ios.Length > 0;
|
||||||
//-------------------------------- 配置检测 --------------------------------
|
//-------------------------------- 配置检测 --------------------------------
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
|
@ -54,10 +52,11 @@ namespace Guru
|
||||||
public string ios_store;
|
public string ios_store;
|
||||||
public int token_vaild_time = 604800;
|
public int token_vaild_time = 604800;
|
||||||
public int level_end_success_num = 50;
|
public int level_end_success_num = 50;
|
||||||
|
public bool use_keywords = true;
|
||||||
public bool enable_firebase = true;
|
public bool enable_firebase = true;
|
||||||
public bool enable_facebook = true;
|
public bool enable_facebook = true;
|
||||||
public bool enable_adjust = true;
|
public bool enable_adjust = true;
|
||||||
public bool enable_iap = false;
|
public bool enable_iap = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
|
@ -65,6 +64,9 @@ namespace Guru
|
||||||
{
|
{
|
||||||
public string[] app_token;
|
public string[] app_token;
|
||||||
public string[] events;
|
public string[] events;
|
||||||
|
|
||||||
|
public string AndroidToken => app_token != null && app_token.Length > 0 ? app_token[0] : "";
|
||||||
|
public string iOSToken => app_token != null && app_token.Length > 1 ? app_token[1] : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
|
@ -13,7 +13,26 @@ namespace Guru
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Callbacks
|
public class Callbacks
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// APP 事件
|
||||||
|
/// </summary>
|
||||||
|
public static class App
|
||||||
|
{
|
||||||
|
internal static Action<bool> _onAppPaused;
|
||||||
|
public static event Action<bool> OnAppPaused
|
||||||
|
{
|
||||||
|
add => _onAppPaused += value;
|
||||||
|
remove => _onAppPaused -= value;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static Action _onAppQuit;
|
||||||
|
public static event Action OnAppQuit
|
||||||
|
{
|
||||||
|
add => _onAppQuit += value;
|
||||||
|
remove => _onAppQuit -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// GDPR Consent
|
/// GDPR Consent
|
||||||
|
|
@ -83,17 +102,29 @@ namespace Guru
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 云控参数
|
||||||
|
/// </summary>
|
||||||
public static class Remote
|
public static class Remote
|
||||||
{
|
{
|
||||||
internal static Action _onRemoteInitComplete;
|
internal static Action _onRemoteInitComplete;
|
||||||
public static event Action OnRemoteInitComplete;
|
public static event Action OnRemoteInitComplete
|
||||||
|
{
|
||||||
internal static Action _onRemoteFetchComplete;
|
add => _onRemoteInitComplete += value;
|
||||||
public static event Action OnRemoteFetchComplete;
|
remove => _onRemoteInitComplete -= value;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static Action<bool> _onRemoteFetchComplete;
|
||||||
|
public static event Action<bool> OnRemoteFetchComplete
|
||||||
|
{
|
||||||
|
add => _onRemoteFetchComplete += value;
|
||||||
|
remove => _onRemoteFetchComplete -= value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 支付回调
|
||||||
|
/// </summary>
|
||||||
public static class IAP
|
public static class IAP
|
||||||
{
|
{
|
||||||
internal static Action<bool> _onIAPInitComplete;
|
internal static Action<bool> _onIAPInitComplete;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Firebase.RemoteConfig;
|
||||||
|
|
||||||
|
namespace Guru
|
||||||
|
{
|
||||||
|
public partial class GuruSDK
|
||||||
|
{
|
||||||
|
|
||||||
|
public static void FetchAllRemote(bool immediately = false) => RemoteConfigManager.FetchAll(immediately);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 注册云控配置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="defaultValue"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static void RegisterRemoteConfig(string key, string defaultValue)
|
||||||
|
{
|
||||||
|
RemoteConfigManager.RegisterConfig(key, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取运控配置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T GetRemoteConfig<T>(string key) where T : IRemoteConfig<T>
|
||||||
|
{
|
||||||
|
return RemoteConfigManager.GetConfig<T>(key);
|
||||||
|
}
|
||||||
|
public static string GetRemoteString(string key) => RemoteConfigManager.GetString(key);
|
||||||
|
public static int GetRemoteInt(string key) => RemoteConfigManager.GetInt(key);
|
||||||
|
public static long GetRemoteLong(string key) => RemoteConfigManager.GetLong(key);
|
||||||
|
public static double GetRemoteDouble(string key) => RemoteConfigManager.GetDouble(key);
|
||||||
|
public static float GetRemoteFloat(string key) => RemoteConfigManager.GetFloat(key);
|
||||||
|
public static bool GetRemoteBool(string key) => RemoteConfigManager.GetBool(key);
|
||||||
|
|
||||||
|
|
||||||
|
public static void RegisterOnValueChanged(string key, Action<string,string> onValueChanged)
|
||||||
|
{
|
||||||
|
RemoteConfigManager.RegisterOnValueChanged(key, onValueChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UnRegisterOnValueChanged(string key, Action<string,string> onValueChanged)
|
||||||
|
{
|
||||||
|
RemoteConfigManager.UnRegisterOnValueChanged(key, onValueChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Dictionary<string, ConfigValue> GetRemoteAllValues() => RemoteConfigManager.GetAllValues();
|
||||||
|
|
||||||
|
|
||||||
|
public static string GetRemoteStaticValue(string key) => RemoteConfigManager.GetStaticValue(key);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e4344f1c04b64ca98a66081bbcb696aa
|
||||||
|
timeCreated: 1703588862
|
||||||
|
|
@ -1,12 +1,18 @@
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
namespace Guru
|
namespace Guru
|
||||||
{
|
{
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
public partial class GuruSDK: MonoBehaviour
|
public partial class GuruSDK: MonoBehaviour
|
||||||
{
|
{
|
||||||
public const string Version = "0.1.0";
|
public const string Version = "0.1.0";
|
||||||
public static readonly string Tag = "[Guru]";
|
public const string Tag = "[Guru]";
|
||||||
|
public const string ServicesConfigKey = "guru_services";
|
||||||
|
public const string ServicesConfigExtension = "cfg";
|
||||||
|
|
||||||
private static GuruSDK _instance;
|
private static GuruSDK _instance;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -32,8 +38,8 @@ namespace Guru
|
||||||
|
|
||||||
internal static GuruSDKInitConfig InitConfig => Instance._initConfig;
|
internal static GuruSDKInitConfig InitConfig => Instance._initConfig;
|
||||||
internal static GuruSDKModel Model => GuruSDKModel.Instance;
|
internal static GuruSDKModel Model => GuruSDKModel.Instance;
|
||||||
|
private static GuruServicesConfig _appServicesConfig;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Debug Mode
|
/// Debug Mode
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -49,7 +55,8 @@ namespace Guru
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 初始化
|
#region 初始化
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static GuruSDK CreateInstance()
|
private static GuruSDK CreateInstance()
|
||||||
{
|
{
|
||||||
|
|
@ -59,6 +66,20 @@ namespace Guru
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static GuruSDKInitConfig BuildConfig(
|
||||||
|
bool useCustomConsent = false,
|
||||||
|
bool autoLoadAds = true,
|
||||||
|
bool iapEnabled = true,
|
||||||
|
bool autoRecordFinishedLevels = true,
|
||||||
|
bool showDebugLog = false,
|
||||||
|
Dictionary<string, object> defaultRemoteData = null,
|
||||||
|
byte[] googleKeys = null,
|
||||||
|
byte[] appleRootCerts = null)
|
||||||
|
{
|
||||||
|
var config = GuruSDKInitConfig.Build(useCustomConsent, autoLoadAds, iapEnabled,
|
||||||
|
autoRecordFinishedLevels, showDebugLog, defaultRemoteData, googleKeys, appleRootCerts);
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
public static void Init(Action<bool> onComplete)
|
public static void Init(Action<bool> onComplete)
|
||||||
{
|
{
|
||||||
|
|
@ -88,40 +109,119 @@ namespace Guru
|
||||||
|
|
||||||
//---------- Start Firebase ------------
|
//---------- Start Firebase ------------
|
||||||
FirebaseUtil.InitFirebase(OnFirebaseReady);
|
FirebaseUtil.InitFirebase(OnFirebaseReady);
|
||||||
FirebaseUtil.OnFetchRemoteSuccess += OnFetchRemoteSuccess;
|
// FirebaseUtil.OnFetchRemoteSuccess+= OnFetchRemoteCallback;
|
||||||
//---------- Start Facebook ------------
|
//---------- Start Facebook ------------
|
||||||
FBService.Instance.StartService();
|
FBService.Instance.StartService();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFetchRemoteSuccess()
|
|
||||||
{
|
|
||||||
Callbacks.Remote._onRemoteFetchComplete?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开始各种组件初始化
|
/// 开始各种组件初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnFirebaseReady()
|
private void OnFirebaseReady()
|
||||||
{
|
{
|
||||||
LogI($"--- #1 SDK Init complete ---");
|
LogI($"--- Firebase complete ---");
|
||||||
if (InitConfig.IAPEnabled)
|
if (InitConfig.IAPEnabled)
|
||||||
{
|
{
|
||||||
LogI($"--- #2 Init IAP ---");
|
// LogI($"--- #2 Init IAP ---");
|
||||||
InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP
|
InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!InitConfig.UseCustomConsent)
|
if (!InitConfig.UseCustomConsent)
|
||||||
{
|
{
|
||||||
LogI($"--- #3 Start Consent Flow ---");
|
// LogI($"--- #3 Start Consent Flow ---");
|
||||||
StartConsentFlow();
|
StartConsentFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: 开始Remote初始化
|
// 开始Remote Manager初始化
|
||||||
|
RemoteConfigManager.Init(BuildDefaultRemoteData(_initConfig.DefaultRemoteData));
|
||||||
|
RemoteConfigManager.OnFetchCompleted += OnFetchRemoteCallback;
|
||||||
|
|
||||||
if(!string.IsNullOrEmpty(IPMConfig.IPM_UID)) SetUID(IPMConfig.IPM_UID);
|
if(!string.IsNullOrEmpty(IPMConfig.IPM_UID)) SetUID(IPMConfig.IPM_UID);
|
||||||
|
|
||||||
|
// 根据上次的云控配置来初始化参数
|
||||||
|
SetupServicesConfig();
|
||||||
|
|
||||||
_onCompleteCallback?.Invoke(true);
|
_onCompleteCallback?.Invoke(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 注入云控参数基础数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dict"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private Dictionary<string, object> BuildDefaultRemoteData(Dictionary<string, object> dict)
|
||||||
|
{
|
||||||
|
string json = Model.LoadAppServicesConfigJson(); // 注入默认的Services 配置值
|
||||||
|
if (!string.IsNullOrEmpty(json))
|
||||||
|
{
|
||||||
|
if (dict == null) dict = new Dictionary<string, object>(3);
|
||||||
|
dict[ServicesConfigKey] = json;
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 拉取云控参数完成
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="success"></param>
|
||||||
|
private void OnFetchRemoteCallback(bool success)
|
||||||
|
{
|
||||||
|
LogI($"--- Remote fetch complete: {success} ---");
|
||||||
|
ABTestManager.Init(); // 启动AB测试解析器
|
||||||
|
Callbacks.Remote._onRemoteFetchComplete?.Invoke(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region App Remote Update
|
||||||
|
|
||||||
|
private void SetupServicesConfig()
|
||||||
|
{
|
||||||
|
bool useKeywords = true;
|
||||||
|
var guruSettings = GuruSettings.Instance;
|
||||||
|
|
||||||
|
var services = GetRemoteServicesConfig();
|
||||||
|
if (services != null)
|
||||||
|
{
|
||||||
|
_appServicesConfig = services;
|
||||||
|
useKeywords = _appServicesConfig.app_settings.use_keywords;
|
||||||
|
|
||||||
|
|
||||||
|
if (null != guruSettings)
|
||||||
|
{
|
||||||
|
if(_appServicesConfig.adjust_settings != null)
|
||||||
|
{
|
||||||
|
// 更新 Adjust Tokens
|
||||||
|
guruSettings.UpdateAdjustTokens(_appServicesConfig.adjust_settings.AndroidToken
|
||||||
|
,_appServicesConfig.adjust_settings.iOSToken);
|
||||||
|
// 更新 Adjust Events
|
||||||
|
guruSettings.UpdateAdjustEvents(_appServicesConfig.adjust_settings.events);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(useKeywords) KeywordsManager.Install(Model.IsIAPUser, Model.SuccessLevelCount); // 启动Keyword管理器
|
||||||
|
|
||||||
|
AdjustService.StartService();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private GuruServicesConfig GetRemoteServicesConfig()
|
||||||
|
{
|
||||||
|
var json = GetRemoteString(ServicesConfigKey);
|
||||||
|
if (!string.IsNullOrEmpty(json))
|
||||||
|
{
|
||||||
|
return JsonParser.ToObject<GuruServicesConfig>(json);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 数据
|
||||||
|
|
||||||
private void OnBLevelChanged(int blevel)
|
private void OnBLevelChanged(int blevel)
|
||||||
{
|
{
|
||||||
|
|
@ -133,10 +233,8 @@ namespace Guru
|
||||||
SetUserBPlay(bplay);
|
SetUserBPlay(bplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Misc
|
#region Misc
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -169,7 +267,92 @@ namespace Guru
|
||||||
Debug.LogError($"{Tag} {message}");
|
Debug.LogError($"{Tag} {message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
public static void LogException(string message)
|
||||||
|
{
|
||||||
|
LogException( new Exception($"{Tag} {message}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogException(Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 生命周期
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 暂停时处理
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="paused"></param>
|
||||||
|
private void OnAppPauseHandler(bool paused)
|
||||||
|
{
|
||||||
|
if(paused) Model.Save(true); // 强制保存数据
|
||||||
|
Callbacks.App._onAppPaused?.Invoke(paused);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnApplicationPause(bool paused)
|
||||||
|
{
|
||||||
|
OnAppPauseHandler(paused);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnApplicationFocus(bool hasFocus)
|
||||||
|
{
|
||||||
|
OnAppPauseHandler(!hasFocus);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnApplicationQuit()
|
||||||
|
{
|
||||||
|
Model.Save(true);
|
||||||
|
Callbacks.App._onAppQuit?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 延迟处理
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启动协程
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="enumerator"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Coroutine DoCoroutine(IEnumerator enumerator)
|
||||||
|
{
|
||||||
|
return Instance != null ? Instance.StartCoroutine(enumerator) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void KillCoroutine(Coroutine coroutine)
|
||||||
|
{
|
||||||
|
if(coroutine != null)
|
||||||
|
Instance.StopCoroutine(coroutine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 延时执行
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="seconds"></param>
|
||||||
|
/// <param name="callback"></param>
|
||||||
|
public static void Delay(float seconds, Action callback)
|
||||||
|
{
|
||||||
|
DoCoroutine(Instance.OnDelayCall(seconds, callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator OnDelayCall(float delay, Action callback)
|
||||||
|
{
|
||||||
|
if (delay > 0)
|
||||||
|
{
|
||||||
|
yield return new WaitForSeconds(delay);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
callback?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,6 +3,8 @@ namespace Guru
|
||||||
internal class GuruIAP: IAPServiceBase<GuruIAP>
|
internal class GuruIAP: IAPServiceBase<GuruIAP>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取BLevel
|
/// 获取BLevel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,18 @@
|
||||||
using System;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Serialization;
|
|
||||||
|
|
||||||
namespace Guru
|
namespace Guru
|
||||||
{
|
{
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
internal class GuruSDKModel
|
internal class GuruSDKModel
|
||||||
{
|
{
|
||||||
|
private const float SaveInterval = 3;
|
||||||
|
private const string SaveKey = "com.guru.sdk.model.save";
|
||||||
|
|
||||||
|
|
||||||
private static GuruSDKModel _instance;
|
private static GuruSDKModel _instance;
|
||||||
public static GuruSDKModel Instance
|
public static GuruSDKModel Instance
|
||||||
{
|
{
|
||||||
|
|
@ -69,8 +75,7 @@ namespace Guru
|
||||||
|
|
||||||
#region 初始化
|
#region 初始化
|
||||||
|
|
||||||
private const float SaveInterval = 3;
|
|
||||||
private const string SaveKey = "com.guru.sdk.model.save";
|
|
||||||
public static GuruSDKModel Load()
|
public static GuruSDKModel Load()
|
||||||
{
|
{
|
||||||
GuruSDKModel model = null;
|
GuruSDKModel model = null;
|
||||||
|
|
@ -146,7 +151,27 @@ namespace Guru
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 启动配置
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从 Streaming 加载 AppServices 配置
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string LoadAppServicesConfigJson()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string path = Path.Combine(Application.streamingAssetsPath, $"{GuruSDK.ServicesConfigKey}.{GuruSDK.ServicesConfigExtension}");
|
||||||
|
return File.ReadAllText(path);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Exception(e);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: fc679813f31644f20b79c6f24939c6a9
|
|
||||||
timeCreated: 1702611035
|
|
||||||
|
|
@ -10,6 +10,5 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"category": "Game,Tool,Development",
|
"category": "Game,Tool,Development",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.guru.unity.sdk.core": "git@git.chengdu.pundit.company:castbox/com.guru.unity.sdk.core.git"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue