com.taptap.sdk.core 4.6.0-beta.1 → 4.6.1-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Mobile/Editor/NativeDependencies.xml +3 -2
- package/Mobile/Runtime/TapCoreMobile.cs +5 -0
- package/Mobile/Runtime/TapEventMobile.cs +21 -0
- package/Runtime/Internal/Platform/ITapCorePlatform.cs +2 -0
- package/Runtime/Internal/Platform/ITapEventPlatform.cs +4 -0
- package/Runtime/Internal/Utils/BridgeUtils.cs +126 -8
- package/Runtime/Internal/Utils/EventManager.cs +2 -0
- package/Runtime/Public/TapTapEvent.cs +7 -0
- package/Runtime/Public/TapTapSDK.cs +7 -1
- package/Runtime/Public/TapTapSdkOptions.cs +14 -0
- package/Standalone/Plugins/x86/tapsdkcore.dll +0 -0
- package/Standalone/Plugins/x86_64/tapsdkcore.dll +0 -0
- package/Standalone/Plugins/x86_64/taptap_api.dll +0 -0
- package/Standalone/Plugins/x86_64/taptap_api.dll.meta +52 -0
- package/Standalone/Resources/Prefabs/TapClient/TapClientConnectTipPanel.prefab +983 -0
- package/Standalone/Resources/Prefabs/TapClient/TapClientConnectTipPanel.prefab.meta +7 -0
- package/Standalone/Resources/Prefabs/TapClient.meta +8 -0
- package/Standalone/Resources/Prefabs.meta +8 -0
- package/Standalone/Resources/Texures/TapClientConnectError.png +0 -0
- package/Standalone/Resources/Texures/TapClientConnectError.png.meta +128 -0
- package/Standalone/Resources/Texures.meta +8 -0
- package/Standalone/Resources.meta +8 -0
- package/Standalone/Runtime/Internal/Openlog/TapCoreTracker.cs +107 -0
- package/Standalone/Runtime/Internal/Openlog/TapCoreTracker.cs.meta +11 -0
- package/Standalone/Runtime/Internal/TapClientBridge.cs +224 -0
- package/Standalone/Runtime/Internal/TapClientBridge.cs.meta +11 -0
- package/Standalone/Runtime/Internal/TapClientBridgePoll.cs +36 -0
- package/Standalone/Runtime/Internal/TapClientBridgePoll.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UI/TapClientConnectTipController.cs +59 -0
- package/Standalone/Runtime/Internal/UI/TapClientConnectTipController.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UI/TapUnderLineText.cs +76 -0
- package/Standalone/Runtime/Internal/UI/TapUnderLineText.cs.meta +11 -0
- package/Standalone/Runtime/Internal/UI.meta +8 -0
- package/Standalone/Runtime/Public/TapCoreStandalone.cs +366 -0
- package/Standalone/Runtime/Public/TapEventStandalone.cs +27 -0
- package/package.json +1 -1
|
Binary file
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: caf855ae07df04c859a1c5c64ea0802d
|
|
3
|
+
TextureImporter:
|
|
4
|
+
internalIDToNameTable: []
|
|
5
|
+
externalObjects: {}
|
|
6
|
+
serializedVersion: 11
|
|
7
|
+
mipmaps:
|
|
8
|
+
mipMapMode: 0
|
|
9
|
+
enableMipMap: 0
|
|
10
|
+
sRGBTexture: 1
|
|
11
|
+
linearTexture: 0
|
|
12
|
+
fadeOut: 0
|
|
13
|
+
borderMipMap: 0
|
|
14
|
+
mipMapsPreserveCoverage: 0
|
|
15
|
+
alphaTestReferenceValue: 0.5
|
|
16
|
+
mipMapFadeDistanceStart: 1
|
|
17
|
+
mipMapFadeDistanceEnd: 3
|
|
18
|
+
bumpmap:
|
|
19
|
+
convertToNormalMap: 0
|
|
20
|
+
externalNormalMap: 0
|
|
21
|
+
heightScale: 0.25
|
|
22
|
+
normalMapFilter: 0
|
|
23
|
+
isReadable: 0
|
|
24
|
+
streamingMipmaps: 0
|
|
25
|
+
streamingMipmapsPriority: 0
|
|
26
|
+
grayScaleToAlpha: 0
|
|
27
|
+
generateCubemap: 6
|
|
28
|
+
cubemapConvolution: 0
|
|
29
|
+
seamlessCubemap: 0
|
|
30
|
+
textureFormat: 1
|
|
31
|
+
maxTextureSize: 2048
|
|
32
|
+
textureSettings:
|
|
33
|
+
serializedVersion: 2
|
|
34
|
+
filterMode: 1
|
|
35
|
+
aniso: 1
|
|
36
|
+
mipBias: 0
|
|
37
|
+
wrapU: 1
|
|
38
|
+
wrapV: 1
|
|
39
|
+
wrapW: 1
|
|
40
|
+
nPOTScale: 0
|
|
41
|
+
lightmap: 0
|
|
42
|
+
compressionQuality: 50
|
|
43
|
+
spriteMode: 1
|
|
44
|
+
spriteExtrude: 1
|
|
45
|
+
spriteMeshType: 1
|
|
46
|
+
alignment: 0
|
|
47
|
+
spritePivot: {x: 0.5, y: 0.5}
|
|
48
|
+
spritePixelsToUnits: 100
|
|
49
|
+
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
|
50
|
+
spriteGenerateFallbackPhysicsShape: 1
|
|
51
|
+
alphaUsage: 1
|
|
52
|
+
alphaIsTransparency: 1
|
|
53
|
+
spriteTessellationDetail: -1
|
|
54
|
+
textureType: 8
|
|
55
|
+
textureShape: 1
|
|
56
|
+
singleChannelComponent: 0
|
|
57
|
+
maxTextureSizeSet: 0
|
|
58
|
+
compressionQualitySet: 0
|
|
59
|
+
textureFormatSet: 0
|
|
60
|
+
applyGammaDecoding: 0
|
|
61
|
+
platformSettings:
|
|
62
|
+
- serializedVersion: 3
|
|
63
|
+
buildTarget: DefaultTexturePlatform
|
|
64
|
+
maxTextureSize: 2048
|
|
65
|
+
resizeAlgorithm: 0
|
|
66
|
+
textureFormat: -1
|
|
67
|
+
textureCompression: 1
|
|
68
|
+
compressionQuality: 50
|
|
69
|
+
crunchedCompression: 0
|
|
70
|
+
allowsAlphaSplitting: 0
|
|
71
|
+
overridden: 0
|
|
72
|
+
androidETC2FallbackOverride: 0
|
|
73
|
+
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
74
|
+
- serializedVersion: 3
|
|
75
|
+
buildTarget: Standalone
|
|
76
|
+
maxTextureSize: 2048
|
|
77
|
+
resizeAlgorithm: 0
|
|
78
|
+
textureFormat: -1
|
|
79
|
+
textureCompression: 1
|
|
80
|
+
compressionQuality: 50
|
|
81
|
+
crunchedCompression: 0
|
|
82
|
+
allowsAlphaSplitting: 0
|
|
83
|
+
overridden: 0
|
|
84
|
+
androidETC2FallbackOverride: 0
|
|
85
|
+
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
86
|
+
- serializedVersion: 3
|
|
87
|
+
buildTarget: iPhone
|
|
88
|
+
maxTextureSize: 2048
|
|
89
|
+
resizeAlgorithm: 0
|
|
90
|
+
textureFormat: -1
|
|
91
|
+
textureCompression: 1
|
|
92
|
+
compressionQuality: 50
|
|
93
|
+
crunchedCompression: 0
|
|
94
|
+
allowsAlphaSplitting: 0
|
|
95
|
+
overridden: 0
|
|
96
|
+
androidETC2FallbackOverride: 0
|
|
97
|
+
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
98
|
+
- serializedVersion: 3
|
|
99
|
+
buildTarget: Android
|
|
100
|
+
maxTextureSize: 2048
|
|
101
|
+
resizeAlgorithm: 0
|
|
102
|
+
textureFormat: -1
|
|
103
|
+
textureCompression: 1
|
|
104
|
+
compressionQuality: 50
|
|
105
|
+
crunchedCompression: 0
|
|
106
|
+
allowsAlphaSplitting: 0
|
|
107
|
+
overridden: 0
|
|
108
|
+
androidETC2FallbackOverride: 0
|
|
109
|
+
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
110
|
+
spriteSheet:
|
|
111
|
+
serializedVersion: 2
|
|
112
|
+
sprites: []
|
|
113
|
+
outline: []
|
|
114
|
+
physicsShape: []
|
|
115
|
+
bones: []
|
|
116
|
+
spriteID: 5e97eb03825dee720800000000000000
|
|
117
|
+
internalID: 0
|
|
118
|
+
vertices: []
|
|
119
|
+
indices:
|
|
120
|
+
edges: []
|
|
121
|
+
weights: []
|
|
122
|
+
secondaryTextures: []
|
|
123
|
+
spritePackingTag:
|
|
124
|
+
pSDRemoveMatte: 0
|
|
125
|
+
pSDShowRemoveMatteOption: 0
|
|
126
|
+
userData:
|
|
127
|
+
assetBundleName:
|
|
128
|
+
assetBundleVariant:
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using Newtonsoft.Json;
|
|
4
|
+
|
|
5
|
+
namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
6
|
+
{
|
|
7
|
+
internal class TapCoreTracker
|
|
8
|
+
{
|
|
9
|
+
|
|
10
|
+
private const string ACTION_INIT = "init";
|
|
11
|
+
private const string ACTION_START = "start";
|
|
12
|
+
private const string ACTION_SUCCESS = "success";
|
|
13
|
+
private const string ACTION_FAIL = "fail";
|
|
14
|
+
private const string ACTION_CANCEL = "cancel";
|
|
15
|
+
|
|
16
|
+
internal static string SUCCESS_TYPE_RESTART = "restart";
|
|
17
|
+
internal static string SUCCESS_TYPE_INIT = "init";
|
|
18
|
+
|
|
19
|
+
internal static string METHOD_LAUNCHER = "isLaunchedFromTapTapPC";
|
|
20
|
+
|
|
21
|
+
private static TapCoreTracker instance;
|
|
22
|
+
|
|
23
|
+
private TapOpenlogStandalone openlog;
|
|
24
|
+
|
|
25
|
+
private TapCoreTracker()
|
|
26
|
+
{
|
|
27
|
+
openlog = new TapOpenlogStandalone("TapSDKCore", TapTapSDK.Version);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public static TapCoreTracker Instance
|
|
31
|
+
{
|
|
32
|
+
get
|
|
33
|
+
{
|
|
34
|
+
if (instance == null)
|
|
35
|
+
{
|
|
36
|
+
instance = new TapCoreTracker();
|
|
37
|
+
}
|
|
38
|
+
return instance;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
internal void TrackInit()
|
|
43
|
+
{
|
|
44
|
+
ReportLog(ACTION_INIT);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
internal void TrackStart(string funcNace, string seesionId)
|
|
48
|
+
{
|
|
49
|
+
Dictionary<string, string> parameters = new Dictionary<string, string>
|
|
50
|
+
{
|
|
51
|
+
{ "func_name", funcNace },
|
|
52
|
+
{ "session_id", seesionId },
|
|
53
|
+
};
|
|
54
|
+
ReportLog(ACTION_START, new Dictionary<string, string>()
|
|
55
|
+
{
|
|
56
|
+
{ "args", JsonConvert.SerializeObject(parameters) }
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
internal void TrackSuccess(string funcNace, string seesionId, string successType)
|
|
61
|
+
{
|
|
62
|
+
Dictionary<string, string> parameters = new Dictionary<string, string>
|
|
63
|
+
{
|
|
64
|
+
{ "func_name", funcNace },
|
|
65
|
+
{ "session_id", seesionId },
|
|
66
|
+
{ "launch_success_type", successType }
|
|
67
|
+
};
|
|
68
|
+
ReportLog(ACTION_SUCCESS, new Dictionary<string, string>()
|
|
69
|
+
{
|
|
70
|
+
{ "args", JsonConvert.SerializeObject(parameters) }
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
internal void TrackCancel(string funcNace, string seesionId)
|
|
75
|
+
{
|
|
76
|
+
Dictionary<string, string> parameters = new Dictionary<string, string>
|
|
77
|
+
{
|
|
78
|
+
{ "func_name", funcNace },
|
|
79
|
+
{ "session_id", seesionId },
|
|
80
|
+
};
|
|
81
|
+
ReportLog(ACTION_CANCEL, new Dictionary<string, string>()
|
|
82
|
+
{
|
|
83
|
+
{ "args", JsonConvert.SerializeObject(parameters) }
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
internal void TrackFailure(string funcNace, string seesionId, int errorCode = -1, string errorMessage = null)
|
|
88
|
+
{
|
|
89
|
+
Dictionary<string, string> parameters = new Dictionary<string, string>
|
|
90
|
+
{
|
|
91
|
+
{ "func_name", funcNace },
|
|
92
|
+
{ "session_id", seesionId },
|
|
93
|
+
{ "error_code", errorCode.ToString() },
|
|
94
|
+
{ "error_msg", errorMessage }
|
|
95
|
+
};
|
|
96
|
+
ReportLog(ACTION_FAIL, new Dictionary<string, string>()
|
|
97
|
+
{
|
|
98
|
+
{ "args", JsonConvert.SerializeObject(parameters) }
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private void ReportLog(string action, Dictionary<string, string> parameters = null)
|
|
103
|
+
{
|
|
104
|
+
openlog.LogBusiness(action, parameters);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.IO;
|
|
4
|
+
using System.Threading.Tasks;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
using System.Runtime.InteropServices;
|
|
7
|
+
using System.Text;
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
namespace TapSDK.Core.Standalone.Internal
|
|
12
|
+
{
|
|
13
|
+
|
|
14
|
+
internal enum TapSDKInitResult
|
|
15
|
+
{
|
|
16
|
+
// 初始化成功
|
|
17
|
+
kTapSDKInitResult_OK = 0,
|
|
18
|
+
// 其他错误
|
|
19
|
+
kTapSDKInitResult_FailedGeneric = 1,
|
|
20
|
+
// 未找到 TapTap,用户可能未安装,请引导用户下载安装 TapTap
|
|
21
|
+
kTapSDKInitResult_NoPlatform = 2,
|
|
22
|
+
// 已安装 TapTap,游戏未通过 TapTap 启动
|
|
23
|
+
kTapSDKInitResult_NotLaunchedByPlatform = 3,
|
|
24
|
+
|
|
25
|
+
// SDK 本地执行时未知错误
|
|
26
|
+
kTapSDKInitResult_Unknown = -1,
|
|
27
|
+
// SDK 本地执行时超时
|
|
28
|
+
kTapSDKInitResult_Timeout = -2,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
internal enum TapCallbackID
|
|
32
|
+
{
|
|
33
|
+
kTapCallbackIDUnknown = 0,
|
|
34
|
+
|
|
35
|
+
// [1, 2000), reserved for TapTap platform events
|
|
36
|
+
kTapCallbackIDSystemStateChanged = 1,
|
|
37
|
+
|
|
38
|
+
// [2001, 4000), reserved for TapTap user events
|
|
39
|
+
kTapCallbackIDAuthorizeFinished = 2001,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// 系统事件类型
|
|
43
|
+
internal enum SystemState
|
|
44
|
+
{
|
|
45
|
+
kSystemState_Unknown = 0, // 未知
|
|
46
|
+
kSystemState_PlatformExit = 1, // 平台退出
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// 是否触发授权的返回结果
|
|
50
|
+
internal enum AuthorizeResult
|
|
51
|
+
{
|
|
52
|
+
kAuthorizeResult_UNKNOWN = 0, // 未知
|
|
53
|
+
kAuthorizeResult_OK = 1, // 成功触发授权
|
|
54
|
+
kAuthorizeResult_FAILED = 2, // 授权失败
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// 完成授权后的返回结果
|
|
58
|
+
internal enum Result
|
|
59
|
+
{
|
|
60
|
+
kResult_OK = 0,
|
|
61
|
+
kResult_Failed = 1,
|
|
62
|
+
kResult_Canceled = 2,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
public class TapClientBridge
|
|
67
|
+
{
|
|
68
|
+
|
|
69
|
+
#if UNITY_STANDALONE_WIN
|
|
70
|
+
public const string DLL_NAME = "taptap_api";
|
|
71
|
+
#endif
|
|
72
|
+
|
|
73
|
+
#if UNITY_STANDALONE_WIN
|
|
74
|
+
[global::System.Runtime.InteropServices.DllImport(TapClientBridge.DLL_NAME, CharSet =CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
75
|
+
internal static extern bool TapSDK_RestartAppIfNecessary([MarshalAs( UnmanagedType.LPStr )]string clientId);
|
|
76
|
+
|
|
77
|
+
[global::System.Runtime.InteropServices.DllImport(TapClientBridge.DLL_NAME, CharSet =CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
78
|
+
internal static extern int TapSDK_Init(StringBuilder errMsg, [MarshalAs( UnmanagedType.LPStr )]string pubKey);
|
|
79
|
+
|
|
80
|
+
[global::System.Runtime.InteropServices.DllImport(TapClientBridge.DLL_NAME, CharSet =CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
81
|
+
internal static extern void TapSDK_Shutdown();
|
|
82
|
+
|
|
83
|
+
// 定义与 C 兼容的委托
|
|
84
|
+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
85
|
+
internal delegate void CallbackDelegate(int id, IntPtr userData);
|
|
86
|
+
|
|
87
|
+
// 系统状态返回结果结构体
|
|
88
|
+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
|
89
|
+
internal struct SystemStateResponse
|
|
90
|
+
{
|
|
91
|
+
public SystemState state; // 枚举直接映射
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
[global::System.Runtime.InteropServices.DllImport(TapClientBridge.DLL_NAME, CharSet =CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
95
|
+
internal static extern void TapSDK_RegisterCallback(int callbackId, IntPtr callback);
|
|
96
|
+
|
|
97
|
+
[global::System.Runtime.InteropServices.DllImport(TapClientBridge.DLL_NAME, CharSet =CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
98
|
+
internal static extern void TapSDK_RunCallbacks();
|
|
99
|
+
|
|
100
|
+
[global::System.Runtime.InteropServices.DllImport(TapClientBridge.DLL_NAME, CharSet =CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
101
|
+
internal static extern void TapSDK_UnregisterCallback(int callbackId, IntPtr callback);
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
// 登录相关接口
|
|
105
|
+
|
|
106
|
+
// 授权返回结果结构体
|
|
107
|
+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
|
108
|
+
public struct AuthorizeFinishedResponse
|
|
109
|
+
{
|
|
110
|
+
public int is_cancel ; // 是否取消
|
|
111
|
+
|
|
112
|
+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
|
|
113
|
+
public string callback_uri; // 256 字节的 C 端字符串
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
[global::System.Runtime.InteropServices.DllImport(TapClientBridge.DLL_NAME, CharSet =CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
118
|
+
internal static extern bool TapUser_GetOpenID(StringBuilder openId);
|
|
119
|
+
|
|
120
|
+
[global::System.Runtime.InteropServices.DllImport(TapClientBridge.DLL_NAME, CharSet =CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
121
|
+
internal static extern bool TapSDK_GetClientID(StringBuilder clientId);
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
[global::System.Runtime.InteropServices.DllImport(TapClientBridge.DLL_NAME, CharSet =CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
125
|
+
internal static extern int TapUser_AsyncAuthorize([MarshalAs( UnmanagedType.LPStr )] string scopeStrings, [MarshalAs( UnmanagedType.LPStr )] string responseType,
|
|
126
|
+
[MarshalAs( UnmanagedType.LPStr )] string redirectUri, [MarshalAs( UnmanagedType.LPStr )] string codeChallenge, [MarshalAs( UnmanagedType.LPStr )] string state,
|
|
127
|
+
[MarshalAs( UnmanagedType.LPStr )] string codeChallengeMethod, [MarshalAs( UnmanagedType.LPStr )] string versonCode, [MarshalAs( UnmanagedType.LPStr )] string sdkUa, [MarshalAs( UnmanagedType.LPStr )] string info);
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
// 初始化检查
|
|
131
|
+
internal static TapSDKInitResult CheckInitState(out string errMessage, string key)
|
|
132
|
+
{
|
|
133
|
+
StringBuilder errMsgBuffer = new StringBuilder(1024); // 分配 1024 字节缓冲区
|
|
134
|
+
int result = TapSDK_Init(errMsgBuffer, key);
|
|
135
|
+
errMessage = errMsgBuffer.ToString();
|
|
136
|
+
TapLogger.Debug("CheckInitState result = " + result);
|
|
137
|
+
return (TapSDKInitResult)result;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// 预防 GC 回收的静态变量
|
|
141
|
+
private static CallbackDelegate _callbackInstance ;
|
|
142
|
+
|
|
143
|
+
private static CallbackDelegate _userCallbackInstance ;
|
|
144
|
+
|
|
145
|
+
// 提供 C# 端的注册方法
|
|
146
|
+
/* 授权 callback 实现示例:
|
|
147
|
+
void MyCallback(TapCallbackID id, IntPtr userData){
|
|
148
|
+
AuthorizeFinishedResponse response = Marshal.PtrToStructure<AuthorizeFinishedResponse>(userData);
|
|
149
|
+
}
|
|
150
|
+
系统状态 callback 实现示例:
|
|
151
|
+
void SystemStateCallback(TapCallbackID id, IntPtr state){
|
|
152
|
+
SystemStateResponse response = Marshal.PtrToStructure<SystemStateResponse>(userData);
|
|
153
|
+
}
|
|
154
|
+
*/
|
|
155
|
+
internal static void RegisterCallback(int callbackId, CallbackDelegate callback)
|
|
156
|
+
{
|
|
157
|
+
|
|
158
|
+
TapLogger.Debug("start set delegate");
|
|
159
|
+
IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(callback);
|
|
160
|
+
if (callbackId == (int)TapCallbackID.kTapCallbackIDSystemStateChanged){
|
|
161
|
+
if(_callbackInstance!= null){
|
|
162
|
+
UnRegisterCallback(_callbackInstance, false);
|
|
163
|
+
}
|
|
164
|
+
_callbackInstance = callback; // 防止被 GC 回收
|
|
165
|
+
}else {
|
|
166
|
+
if(_userCallbackInstance!= null){
|
|
167
|
+
UnRegisterCallback(_userCallbackInstance, true);
|
|
168
|
+
}
|
|
169
|
+
_userCallbackInstance = callback;
|
|
170
|
+
}
|
|
171
|
+
TapLogger.Debug("start set delegate ptr " + funcPtr);
|
|
172
|
+
TapSDK_RegisterCallback(callbackId, funcPtr);
|
|
173
|
+
TapLogger.Debug("start set delegate ptr finish");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// 移除回调
|
|
177
|
+
internal static void UnRegisterCallback(CallbackDelegate callback, bool isUser)
|
|
178
|
+
{
|
|
179
|
+
|
|
180
|
+
IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(callback);
|
|
181
|
+
if (isUser){
|
|
182
|
+
_userCallbackInstance = null;
|
|
183
|
+
}else {
|
|
184
|
+
_callbackInstance = null;
|
|
185
|
+
}
|
|
186
|
+
TapLogger.Debug("start remove delegate ptr " + funcPtr);
|
|
187
|
+
TapSDK_UnregisterCallback(isUser? (int)TapCallbackID.kTapCallbackIDAuthorizeFinished :(int)TapCallbackID.kTapCallbackIDSystemStateChanged,funcPtr);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
internal static AuthorizeResult LoginWithScopes(string[] scopeStrings, string responseType, string redirectUri,
|
|
191
|
+
string codeChallenge, string state, string codeChallengeMethod, string versonCode, string sdkUa, string info) {
|
|
192
|
+
try
|
|
193
|
+
{
|
|
194
|
+
TapLogger.Debug("login start ==== "+ string.Join(",", scopeStrings));
|
|
195
|
+
int result = TapUser_AsyncAuthorize(string.Join(",", scopeStrings), responseType, redirectUri,
|
|
196
|
+
codeChallenge, state, codeChallengeMethod, versonCode, sdkUa, info);
|
|
197
|
+
TapLogger.Debug("login end === " + result);
|
|
198
|
+
return (AuthorizeResult)result;
|
|
199
|
+
}catch(Exception ex){
|
|
200
|
+
TapLogger.Debug("login crash = " + ex.StackTrace);
|
|
201
|
+
return AuthorizeResult.kAuthorizeResult_UNKNOWN;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
internal static bool GetTapUserOpenId(out string openId){
|
|
206
|
+
StringBuilder openIdBuffer = new StringBuilder(256); // 分配一个足够大的缓冲区
|
|
207
|
+
bool success = TapUser_GetOpenID(openIdBuffer); // 调用 C 函数
|
|
208
|
+
openId = openIdBuffer.ToString();
|
|
209
|
+
return success;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
internal static bool GetClientId(out string clientId){
|
|
213
|
+
StringBuilder clientIDBuffer = new StringBuilder(256); // 分配一个足够大的缓冲区
|
|
214
|
+
bool success = TapSDK_GetClientID(clientIDBuffer); // 调用 C 函数
|
|
215
|
+
clientId = clientIDBuffer.ToString();
|
|
216
|
+
return success;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
#endif
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace TapSDK.Core.Standalone.Internal
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// 防沉迷轮询器
|
|
8
|
+
/// </summary>
|
|
9
|
+
internal class TapClientBridgePoll : MonoBehaviour
|
|
10
|
+
{
|
|
11
|
+
static readonly string TAP_CLIENT_POLL_NAME = "TapClientBridgePoll";
|
|
12
|
+
|
|
13
|
+
static TapClientBridgePoll current;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
internal static void StartUp()
|
|
17
|
+
{
|
|
18
|
+
TapLogger.Debug("TapClientBridgePoll StartUp " );
|
|
19
|
+
if (current == null)
|
|
20
|
+
{
|
|
21
|
+
GameObject pollGo = new GameObject(TAP_CLIENT_POLL_NAME);
|
|
22
|
+
DontDestroyOnLoad(pollGo);
|
|
23
|
+
current = pollGo.AddComponent<TapClientBridgePoll>();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
private void Update()
|
|
29
|
+
{
|
|
30
|
+
#if UNITY_STANDALONE_WIN
|
|
31
|
+
TapClientBridge.TapSDK_RunCallbacks();
|
|
32
|
+
#endif
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine.UI;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
using TapSDK.UI;
|
|
5
|
+
|
|
6
|
+
namespace TapSDK.Core.Standalone.Internal {
|
|
7
|
+
public class TapClientConnectTipController : BasePanelController
|
|
8
|
+
{
|
|
9
|
+
public Button installTipButton;
|
|
10
|
+
public Button okButton;
|
|
11
|
+
|
|
12
|
+
public Text tipText;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/// <summary>
|
|
16
|
+
/// bind ugui components for every panel
|
|
17
|
+
/// </summary>
|
|
18
|
+
protected override void BindComponents()
|
|
19
|
+
{
|
|
20
|
+
okButton = transform.Find("Root/OKButton").GetComponent<Button>();
|
|
21
|
+
installTipButton = transform.Find("Root/InstallTipBtn").GetComponent<Button>();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
protected override void OnLoadSuccess()
|
|
25
|
+
{
|
|
26
|
+
base.OnLoadSuccess();
|
|
27
|
+
|
|
28
|
+
installTipButton.onClick.AddListener(OnInstallButtonClicked);
|
|
29
|
+
okButton.onClick.AddListener(OnOKButtonClicked);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
internal void Show(TapSDKInitResult errorType)
|
|
33
|
+
{
|
|
34
|
+
if (errorType == TapSDKInitResult.kTapSDKInitResult_NoPlatform){
|
|
35
|
+
tipText.text = "获取游戏信息失败,请下载 TapTap 客户端后重新启动游戏";
|
|
36
|
+
}else if (errorType == TapSDKInitResult.kTapSDKInitResult_NotLaunchedByPlatform){
|
|
37
|
+
tipText.text = "获取游戏信息失败,请从 TapTap 客户端重新启动游戏";
|
|
38
|
+
}else if (errorType == TapSDKInitResult.kTapSDKInitResult_Unknown){
|
|
39
|
+
tipText.text = "本地发生未知错误,请从 TapTap 客户端重新启动游戏";
|
|
40
|
+
}else if (errorType == TapSDKInitResult.kTapSDKInitResult_Timeout){
|
|
41
|
+
tipText.text = "获取游戏信息超时,请从 TapTap 客户端重新启动游戏";
|
|
42
|
+
}else {
|
|
43
|
+
tipText.text = "发生未知错误,请从 TapTap 客户端重新启动游戏";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private void OnOKButtonClicked()
|
|
48
|
+
{
|
|
49
|
+
Close();
|
|
50
|
+
Application.Quit();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private void OnInstallButtonClicked()
|
|
54
|
+
{
|
|
55
|
+
Application.OpenURL("https://www.taptap.cn/mobile?utm_medium=coop&utm_source=pc_toStart");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
}
|