sdk 代码合并

This commit is contained in:
LYP
2024-08-06 16:22:00 +08:00
parent 4f80b73fd0
commit de5c781bd7
15 changed files with 1470 additions and 250 deletions

View File

@@ -0,0 +1,49 @@
using System.Threading.Tasks;
using UnityEngine;
namespace tysdk
{
public partial class TYSdkFacade : MonoBehaviour
{
/*================================================
_ _____ _____
/ \|_ _|_ _|
/ _ \ | | | |
/ ___ \| | | |
/_/ \_\_| |_|
=================================================*/
public bool IsAttAccepted()
{
return UnityBridgeFunc.GetATT() == 1;
}
public async Task<ATTInfo> RequestATT()
{
#if UNITY_EDITOR || UNITY_ANDROID
await Task.Yield();
return new ATTInfo(){isAccepted = true};
#elif UNITY_IOS
var taskSource = new TaskCompletionSource<ATTInfo>();
callbacks.Add("RequestATT", (ITYSdkCallback callback) =>
{
taskSource.SetResult((ATTInfo)callback);
});
UnityBridgeFunc.RequestATT();
return await taskSource.Task;
#endif
}
public void RequestATTResult(string r)
{
if (callbacks.TryGetValue("RequestATT", out var action))
{
action.Invoke(new ATTInfo(){isAccepted = r == "1"});
callbacks.Remove("RequestATT");
}
}
}
}