80 lines
2.4 KiB
C#
80 lines
2.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Newtonsoft.Json;
|
|
using Uni2SDK;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
|
|
namespace UNSDK
|
|
{
|
|
public class SdkConfigMgr : ScriptableObject
|
|
{
|
|
[FormerlySerializedAs("Secret")] public string secret;
|
|
[FormerlySerializedAs("Host")] public string host;
|
|
[FormerlySerializedAs("IsLog")] public bool isLog;
|
|
|
|
public static bool IsInitSuccess = false;
|
|
|
|
private static SdkConfigMgr _instance;
|
|
|
|
public static SdkConfigMgr Instance
|
|
{
|
|
get
|
|
{
|
|
if (_instance) return _instance;
|
|
_instance = AssetTools.GetScriptableObject<SdkConfigMgr>(typeof(SdkConfigMgr).Name, "Assets/Resources", false, false);
|
|
return _instance;
|
|
}
|
|
set => _instance = value;
|
|
}
|
|
|
|
|
|
public static void Init(string packageName = "")
|
|
{
|
|
var package = StringExtensions.IsNullOrWhiteSpace(packageName) ? Application.identifier: packageName;
|
|
|
|
Uni2SDKManager.Instance.SetPackage("com.wackyllamagame.chaos",package);
|
|
|
|
Uni2SDKManager.Instance.SetLog(Instance.isLog);
|
|
|
|
Uni2SDKManager.Instance.Init(Instance.host,Instance.secret, (b, msg) =>
|
|
{
|
|
IsInitSuccess = b;
|
|
Debug.Log($"init SDK bool===={b} WvManager.Instance.Init s==={msg}");
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭有感
|
|
/// 必须调用,且在退出有感界界面时调用
|
|
/// 调用此方法后,可以将其他游戏界面等显示了
|
|
/// </summary>
|
|
public void Close()
|
|
{
|
|
#if !UNITY_EDITOR
|
|
Uni2SDKManager.Instance.Close();
|
|
#endif
|
|
}
|
|
/// <summary>
|
|
/// 开启有感
|
|
/// 开启时:需要将其他游戏界面等隐藏,注意,是隐藏,不是在其界面上再添加一个界面
|
|
/// </summary>
|
|
public void Open(bool normal = true, string url = "")
|
|
{
|
|
#if !UNITY_EDITOR
|
|
Uni2SDKManager.Instance.Open(0,0,0,156,normal,url);
|
|
#endif
|
|
}
|
|
}
|
|
|
|
public class SDKOpenConfig
|
|
{
|
|
[JsonProperty("normal")]
|
|
public bool normal;
|
|
[JsonProperty("url")]
|
|
public string url;
|
|
}
|
|
|
|
}
|
|
|