com.taptap.sdk.core 4.3.0-aplha.5
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/Editor/BuildTargetUtils.cs +14 -0
- package/Editor/BuildTargetUtils.cs.meta +11 -0
- package/Editor/LinkXMLGenerator.cs +70 -0
- package/Editor/LinkXMLGenerator.cs.meta +11 -0
- package/Editor/Plist.cs +954 -0
- package/Editor/Plist.cs.meta +3 -0
- package/Editor/SDKLinkProcessBuild.cs +119 -0
- package/Editor/SDKLinkProcessBuild.cs.meta +11 -0
- package/Editor/TapFileHelper.cs +168 -0
- package/Editor/TapFileHelper.cs.meta +3 -0
- package/Editor/TapSDK.Core.Editor.asmdef +15 -0
- package/Editor/TapSDK.Core.Editor.asmdef.meta +7 -0
- package/Editor/TapSDKCoreCompile.cs +284 -0
- package/Editor/TapSDKCoreCompile.cs.meta +3 -0
- package/Editor/TapSDKCoreIOSProcessor.cs +74 -0
- package/Editor/TapSDKCoreIOSProcessor.cs.meta +3 -0
- package/Editor/UI/ScrollViewEditor.cs +267 -0
- package/Editor/UI/ScrollViewEditor.cs.meta +12 -0
- package/Editor/UI/ScrollViewExEditor.cs +34 -0
- package/Editor/UI/ScrollViewExEditor.cs.meta +12 -0
- package/Editor/UI/TapSDK.UI.Editor.asmdef +17 -0
- package/Editor/UI/TapSDK.UI.Editor.asmdef.meta +7 -0
- package/Editor/UI.meta +9 -0
- package/Editor.meta +8 -0
- package/Mobile/Editor/NativeDependencies.xml +22 -0
- package/Mobile/Editor/NativeDependencies.xml.meta +7 -0
- package/Mobile/Editor/TapCommonMobileProcessBuild.cs +20 -0
- package/Mobile/Editor/TapCommonMobileProcessBuild.cs.meta +11 -0
- package/Mobile/Editor/TapSDK.Core.Mobile.Editor.asmdef +17 -0
- package/Mobile/Editor/TapSDK.Core.Mobile.Editor.asmdef.meta +7 -0
- package/Mobile/Editor.meta +8 -0
- package/Mobile/Runtime/AndroidNativeWrapper.cs +50 -0
- package/Mobile/Runtime/AndroidNativeWrapper.cs.meta +11 -0
- package/Mobile/Runtime/Bridge.cs +84 -0
- package/Mobile/Runtime/Bridge.cs.meta +11 -0
- package/Mobile/Runtime/BridgeAndroid.cs +73 -0
- package/Mobile/Runtime/BridgeAndroid.cs.meta +11 -0
- package/Mobile/Runtime/BridgeCallback.cs +35 -0
- package/Mobile/Runtime/BridgeCallback.cs.meta +11 -0
- package/Mobile/Runtime/BridgeIOS.cs +113 -0
- package/Mobile/Runtime/BridgeIOS.cs.meta +11 -0
- package/Mobile/Runtime/Command.cs +119 -0
- package/Mobile/Runtime/Command.cs.meta +11 -0
- package/Mobile/Runtime/Constants.cs +9 -0
- package/Mobile/Runtime/Constants.cs.meta +11 -0
- package/Mobile/Runtime/EngineBridgeInitializer.cs +33 -0
- package/Mobile/Runtime/EngineBridgeInitializer.cs.meta +11 -0
- package/Mobile/Runtime/IBridge.cs +15 -0
- package/Mobile/Runtime/IBridge.cs.meta +11 -0
- package/Mobile/Runtime/IOSNativeWrapper.cs +273 -0
- package/Mobile/Runtime/IOSNativeWrapper.cs.meta +11 -0
- package/Mobile/Runtime/Result.cs +37 -0
- package/Mobile/Runtime/Result.cs.meta +11 -0
- package/Mobile/Runtime/TapCoreMobile.cs +71 -0
- package/Mobile/Runtime/TapCoreMobile.cs.meta +11 -0
- package/Mobile/Runtime/TapEventMobile.cs +265 -0
- package/Mobile/Runtime/TapEventMobile.cs.meta +11 -0
- package/Mobile/Runtime/TapSDK.Core.Mobile.Runtime.asmdef +18 -0
- package/Mobile/Runtime/TapSDK.Core.Mobile.Runtime.asmdef.meta +7 -0
- package/Mobile/Runtime/TapUUID.cs +9 -0
- package/Mobile/Runtime/TapUUID.cs.meta +11 -0
- package/Mobile/Runtime.meta +8 -0
- package/Mobile.meta +8 -0
- package/Plugins/iOS.meta +8 -0
- package/Plugins.meta +8 -0
- package/Resources/Fonts/taptap-sdk-bold.ttf +0 -0
- package/Resources/Fonts/taptap-sdk-bold.ttf.meta +22 -0
- package/Resources/Fonts/taptap-sdk.ttf +0 -0
- package/Resources/Fonts/taptap-sdk.ttf.meta +21 -0
- package/Resources/Fonts.meta +8 -0
- package/Resources/Loading.prefab +260 -0
- package/Resources/Loading.prefab.meta +7 -0
- package/Resources/TapCommonTip.prefab +194 -0
- package/Resources/TapCommonTip.prefab.meta +7 -0
- package/Resources/TapCommonToastBlack.prefab +528 -0
- package/Resources/TapCommonToastBlack.prefab.meta +7 -0
- package/Resources/TapCommonToastWhite.prefab +411 -0
- package/Resources/TapCommonToastWhite.prefab.meta +7 -0
- package/Resources/TapSDKCommonTapIcon-v2.png +0 -0
- package/Resources/TapSDKCommonTapIcon-v2.png.meta +128 -0
- package/Resources/TapSDKCommonTapIcon.png +0 -0
- package/Resources/TapSDKCommonTapIcon.png.meta +128 -0
- package/Resources/TapSDKCommonToastBg.png +0 -0
- package/Resources/TapSDKCommonToastBg.png.meta +128 -0
- package/Resources/TapSDKConstantUIRoot.prefab +100 -0
- package/Resources/TapSDKConstantUIRoot.prefab.meta +7 -0
- package/Resources/TapSDKUIRoot.prefab +100 -0
- package/Resources/TapSDKUIRoot.prefab.meta +7 -0
- package/Resources/TapTapBtn_White.png +0 -0
- package/Resources/TapTapBtn_White.png.meta +128 -0
- package/Resources/TapTapBtn_White_2.png +0 -0
- package/Resources/TapTapBtn_White_2.png.meta +128 -0
- package/Resources/ToastBackground.png +0 -0
- package/Resources/ToastBackground.png.meta +128 -0
- package/Resources/detail_bg.png +0 -0
- package/Resources/detail_bg.png.meta +92 -0
- package/Resources/success.png +0 -0
- package/Resources/success.png.meta +128 -0
- package/Resources/taptap-bg.png +0 -0
- package/Resources/taptap-bg.png.meta +140 -0
- package/Resources/taptap-close.png +0 -0
- package/Resources/taptap-close.png.meta +146 -0
- package/Resources/taptap-router-v2.png +0 -0
- package/Resources/taptap-router-v2.png.meta +128 -0
- package/Resources/taptap-router.png +0 -0
- package/Resources/taptap-router.png.meta +146 -0
- package/Resources/taptap-sdk-refresh 1.png +0 -0
- package/Resources/taptap-sdk-refresh 1.png.meta +128 -0
- package/Resources/taptap-toast-error.png +0 -0
- package/Resources/taptap-toast-error.png.meta +128 -0
- package/Resources/taptap-toast-info.png +0 -0
- package/Resources/taptap-toast-info.png.meta +128 -0
- package/Resources/taptap-toast-success.png +0 -0
- package/Resources/taptap-toast-success.png.meta +128 -0
- package/Resources/taptap-toast-warning.png +0 -0
- package/Resources/taptap-toast-warning.png.meta +128 -0
- package/Resources.meta +8 -0
- package/Runtime/Internal/Http/TapHttpClient.cs +176 -0
- package/Runtime/Internal/Http/TapHttpClient.cs.meta +11 -0
- package/Runtime/Internal/Http/TapHttpUtils.cs +83 -0
- package/Runtime/Internal/Http/TapHttpUtils.cs.meta +11 -0
- package/Runtime/Internal/Http.meta +8 -0
- package/Runtime/Internal/Init/IInitTask.cs +18 -0
- package/Runtime/Internal/Init/IInitTask.cs.meta +11 -0
- package/Runtime/Internal/Init.meta +8 -0
- package/Runtime/Internal/Json/TapJsonConverter.cs +40 -0
- package/Runtime/Internal/Json/TapJsonConverter.cs.meta +11 -0
- package/Runtime/Internal/Json.meta +8 -0
- package/Runtime/Internal/Platform/ITapCorePlatform.cs +12 -0
- package/Runtime/Internal/Platform/ITapCorePlatform.cs.meta +11 -0
- package/Runtime/Internal/Platform/ITapEventPlatform.cs +37 -0
- package/Runtime/Internal/Platform/ITapEventPlatform.cs.meta +11 -0
- package/Runtime/Internal/Platform/PlatformTypeUtils.cs +46 -0
- package/Runtime/Internal/Platform/PlatformTypeUtils.cs.meta +11 -0
- package/Runtime/Internal/Platform.meta +8 -0
- package/Runtime/Internal/UI/Base/Const.cs +27 -0
- package/Runtime/Internal/UI/Base/Const.cs.meta +11 -0
- package/Runtime/Internal/UI/Base/GraphicRaycasterBugFixed.cs +240 -0
- package/Runtime/Internal/UI/Base/GraphicRaycasterBugFixed.cs.meta +3 -0
- package/Runtime/Internal/UI/Base/LoadingPanelController.cs +29 -0
- package/Runtime/Internal/UI/Base/LoadingPanelController.cs.meta +11 -0
- package/Runtime/Internal/UI/Base/MonoSingleton.cs +102 -0
- package/Runtime/Internal/UI/Base/MonoSingleton.cs.meta +11 -0
- package/Runtime/Internal/UI/Base/Singleton.cs +29 -0
- package/Runtime/Internal/UI/Base/Singleton.cs.meta +11 -0
- package/Runtime/Internal/UI/Base/TipPanelController.cs +45 -0
- package/Runtime/Internal/UI/Base/TipPanelController.cs.meta +3 -0
- package/Runtime/Internal/UI/Base/ToastBlackPanelController.cs +95 -0
- package/Runtime/Internal/UI/Base/ToastBlackPanelController.cs.meta +11 -0
- package/Runtime/Internal/UI/Base/ToastWhitePanelController.cs +79 -0
- package/Runtime/Internal/UI/Base/ToastWhitePanelController.cs.meta +3 -0
- package/Runtime/Internal/UI/Base/UIManager.cs +724 -0
- package/Runtime/Internal/UI/Base/UIManager.cs.meta +11 -0
- package/Runtime/Internal/UI/Base.meta +8 -0
- package/Runtime/Internal/UI/BasePanel/BasePanelController.cs +385 -0
- package/Runtime/Internal/UI/BasePanel/BasePanelController.cs.meta +11 -0
- package/Runtime/Internal/UI/BasePanel.meta +8 -0
- package/Runtime/Internal/UI/Params/BasePanelConfig.cs +18 -0
- package/Runtime/Internal/UI/Params/BasePanelConfig.cs.meta +11 -0
- package/Runtime/Internal/UI/Params/IOpenPanelParameter.cs +7 -0
- package/Runtime/Internal/UI/Params/IOpenPanelParameter.cs.meta +11 -0
- package/Runtime/Internal/UI/Params.meta +8 -0
- package/Runtime/Internal/UI/ScrollViewEx/ObjPool/SimpleObjPool.cs +76 -0
- package/Runtime/Internal/UI/ScrollViewEx/ObjPool/SimpleObjPool.cs.meta +12 -0
- package/Runtime/Internal/UI/ScrollViewEx/ObjPool.meta +9 -0
- package/Runtime/Internal/UI/ScrollViewEx/ScrollView/ScrollView.cs +828 -0
- package/Runtime/Internal/UI/ScrollViewEx/ScrollView/ScrollView.cs.meta +12 -0
- package/Runtime/Internal/UI/ScrollViewEx/ScrollView/ScrollViewEx.cs +245 -0
- package/Runtime/Internal/UI/ScrollViewEx/ScrollView/ScrollViewEx.cs.meta +12 -0
- package/Runtime/Internal/UI/ScrollViewEx/ScrollView.meta +9 -0
- package/Runtime/Internal/UI/ScrollViewEx.meta +8 -0
- package/Runtime/Internal/UI.meta +8 -0
- package/Runtime/Internal/Utils/BridgeUtils.cs +29 -0
- package/Runtime/Internal/Utils/BridgeUtils.cs.meta +11 -0
- package/Runtime/Internal/Utils/ImageUtils.cs +147 -0
- package/Runtime/Internal/Utils/ImageUtils.cs.meta +11 -0
- package/Runtime/Internal/Utils/TapLoom.cs +155 -0
- package/Runtime/Internal/Utils/TapLoom.cs.meta +11 -0
- package/Runtime/Internal/Utils/UrlUtils.cs +34 -0
- package/Runtime/Internal/Utils/UrlUtils.cs.meta +11 -0
- package/Runtime/Internal/Utils.meta +8 -0
- package/Runtime/Internal.meta +8 -0
- package/Runtime/Public/DataStorage.cs +141 -0
- package/Runtime/Public/DataStorage.cs.meta +11 -0
- package/Runtime/Public/ITapPropertiesProxy.cs +6 -0
- package/Runtime/Public/ITapPropertiesProxy.cs.meta +11 -0
- package/Runtime/Public/Json.cs +636 -0
- package/Runtime/Public/Json.cs.meta +11 -0
- package/Runtime/Public/Log/TapLogLevel.cs +7 -0
- package/Runtime/Public/Log/TapLogLevel.cs.meta +11 -0
- package/Runtime/Public/Log/TapLogger.cs +48 -0
- package/Runtime/Public/Log/TapLogger.cs.meta +11 -0
- package/Runtime/Public/Log.meta +8 -0
- package/Runtime/Public/Platform.cs +27 -0
- package/Runtime/Public/Platform.cs.meta +11 -0
- package/Runtime/Public/RegionType.cs +8 -0
- package/Runtime/Public/RegionType.cs.meta +11 -0
- package/Runtime/Public/SafeDictionary.cs +27 -0
- package/Runtime/Public/SafeDictionary.cs.meta +11 -0
- package/Runtime/Public/TapError.cs +62 -0
- package/Runtime/Public/TapError.cs.meta +11 -0
- package/Runtime/Public/TapErrorCode.cs +44 -0
- package/Runtime/Public/TapErrorCode.cs.meta +11 -0
- package/Runtime/Public/TapException.cs +24 -0
- package/Runtime/Public/TapException.cs.meta +11 -0
- package/Runtime/Public/TapLanguage.cs +21 -0
- package/Runtime/Public/TapLanguage.cs.meta +11 -0
- package/Runtime/Public/TapLocalizeManager.cs +128 -0
- package/Runtime/Public/TapLocalizeManager.cs.meta +11 -0
- package/Runtime/Public/TapTapEvent.cs +93 -0
- package/Runtime/Public/TapTapEvent.cs.meta +11 -0
- package/Runtime/Public/TapTapSDK.cs +96 -0
- package/Runtime/Public/TapTapSDK.cs.meta +11 -0
- package/Runtime/Public/TapTapSDKCoreOptions.cs +104 -0
- package/Runtime/Public/TapTapSDKCoreOptions.cs.meta +11 -0
- package/Runtime/Public.meta +8 -0
- package/Runtime/TapSDK.Core.Runtime.asmdef +3 -0
- package/Runtime/TapSDK.Core.Runtime.asmdef.meta +7 -0
- package/Runtime.meta +8 -0
- package/Standalone/Editor/TapCoreStandaloneProcessBuild.cs +20 -0
- package/Standalone/Editor/TapCoreStandaloneProcessBuild.cs.meta +11 -0
- package/Standalone/Editor/TapSDK.Core.Standalone.Editor.asmdef +17 -0
- package/Standalone/Editor/TapSDK.Core.Standalone.Editor.asmdef.meta +7 -0
- package/Standalone/Editor.meta +8 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/Info.plist +46 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/Info.plist.meta +7 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/MacOS/TapDBDeviceInfo +0 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/MacOS/TapDBDeviceInfo.meta +7 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/MacOS.meta +8 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/_CodeSignature/CodeResources +115 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/_CodeSignature/CodeResources.meta +7 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/_CodeSignature.meta +8 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents.meta +8 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle.meta +33 -0
- package/Standalone/Plugins/macOS.meta +8 -0
- package/Standalone/Plugins.meta +8 -0
- package/Standalone/Runtime/Internal/Constants.cs +37 -0
- package/Standalone/Runtime/Internal/Constants.cs.meta +11 -0
- package/Standalone/Runtime/Internal/DeviceInfo.cs +152 -0
- package/Standalone/Runtime/Internal/DeviceInfo.cs.meta +11 -0
- package/Standalone/Runtime/Internal/EventSender.cs +239 -0
- package/Standalone/Runtime/Internal/EventSender.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Http/HttpClient.cs +211 -0
- package/Standalone/Runtime/Internal/Http/HttpClient.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Http/NetUtils.cs +48 -0
- package/Standalone/Runtime/Internal/Http/NetUtils.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Http/TimeUtil.cs +30 -0
- package/Standalone/Runtime/Internal/Http/TimeUtil.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Http.meta +8 -0
- package/Standalone/Runtime/Internal/Identity.cs +43 -0
- package/Standalone/Runtime/Internal/Identity.cs.meta +11 -0
- package/Standalone/Runtime/Internal/PlayRecorder.cs +53 -0
- package/Standalone/Runtime/Internal/PlayRecorder.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Prefs.cs +85 -0
- package/Standalone/Runtime/Internal/Prefs.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Tracker.cs +318 -0
- package/Standalone/Runtime/Internal/Tracker.cs.meta +11 -0
- package/Standalone/Runtime/Internal/User.cs +51 -0
- package/Standalone/Runtime/Internal/User.cs.meta +11 -0
- package/Standalone/Runtime/Internal.meta +8 -0
- package/Standalone/Runtime/Public/EventManager.cs +41 -0
- package/Standalone/Runtime/Public/EventManager.cs.meta +11 -0
- package/Standalone/Runtime/Public/TapCoreStandalone.cs +197 -0
- package/Standalone/Runtime/Public/TapCoreStandalone.cs.meta +11 -0
- package/Standalone/Runtime/Public/TapEventStandalone.cs +281 -0
- package/Standalone/Runtime/Public/TapEventStandalone.cs.meta +11 -0
- package/Standalone/Runtime/Public.meta +8 -0
- package/Standalone/Runtime/TapSDK.Core.Standalone.Runtime.asmdef +21 -0
- package/Standalone/Runtime/TapSDK.Core.Standalone.Runtime.asmdef.meta +7 -0
- package/Standalone/Runtime.meta +8 -0
- package/Standalone.meta +8 -0
- package/package.json +8 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace TapSDK.Core
|
|
5
|
+
{
|
|
6
|
+
public class BridgeAndroid : IBridge
|
|
7
|
+
{
|
|
8
|
+
private string bridgeJavaClz = "com.taptap.sdk.kit.internal.enginebridge.EngineBridge";
|
|
9
|
+
|
|
10
|
+
private string instanceField = "INSTANCE";
|
|
11
|
+
|
|
12
|
+
private string registerHandlerMethod = "registerHandler";
|
|
13
|
+
|
|
14
|
+
private string callHandlerMethod = "execCommand";
|
|
15
|
+
|
|
16
|
+
private string callHandlerAsyncMethod = "execCommandAsync";
|
|
17
|
+
|
|
18
|
+
private string initMethod = "init";
|
|
19
|
+
|
|
20
|
+
private string registerMethod = "registerService";
|
|
21
|
+
|
|
22
|
+
private readonly AndroidJavaObject _mAndroidBridge;
|
|
23
|
+
|
|
24
|
+
private static readonly BridgeAndroid SInstance = new BridgeAndroid();
|
|
25
|
+
|
|
26
|
+
public static BridgeAndroid GetInstance()
|
|
27
|
+
{
|
|
28
|
+
return SInstance;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private BridgeAndroid()
|
|
32
|
+
{
|
|
33
|
+
var mCurrentActivity =
|
|
34
|
+
new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity");
|
|
35
|
+
_mAndroidBridge = new AndroidJavaClass(bridgeJavaClz).GetStatic<AndroidJavaObject>(instanceField);
|
|
36
|
+
_mAndroidBridge.Call(initMethod, mCurrentActivity);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public void Register(string serviceClzName, string serviceImplName)
|
|
40
|
+
{
|
|
41
|
+
if (_mAndroidBridge == null)
|
|
42
|
+
{
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
try
|
|
47
|
+
{
|
|
48
|
+
var serviceClass = new AndroidJavaClass(serviceClzName);
|
|
49
|
+
var serviceImpl = new AndroidJavaObject(serviceImplName);
|
|
50
|
+
_mAndroidBridge.Call(registerMethod, serviceClass, serviceImpl);
|
|
51
|
+
}
|
|
52
|
+
catch (Exception e)
|
|
53
|
+
{
|
|
54
|
+
Debug.Log("register Failed:" + e);
|
|
55
|
+
//
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public void Call(Command command, Action<Result> action)
|
|
60
|
+
{
|
|
61
|
+
_mAndroidBridge?.Call(callHandlerMethod, command.ToJSON(), new BridgeCallback(action));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public void Call(Command command)
|
|
65
|
+
{
|
|
66
|
+
_mAndroidBridge?.Call(callHandlerMethod, command.ToJSON(), null);
|
|
67
|
+
}
|
|
68
|
+
public string CallWithReturnValue(Command command, Action<Result> action)
|
|
69
|
+
{
|
|
70
|
+
return _mAndroidBridge?.Call<string>(callHandlerAsyncMethod, command.ToJSON());
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
using System.Threading;
|
|
4
|
+
using TapSDK.Core.Internal.Utils;
|
|
5
|
+
|
|
6
|
+
namespace TapSDK.Core
|
|
7
|
+
{
|
|
8
|
+
|
|
9
|
+
public class BridgeCallback : AndroidJavaProxy
|
|
10
|
+
{
|
|
11
|
+
Action<Result> callback;
|
|
12
|
+
|
|
13
|
+
public BridgeCallback(Action<Result> action) :
|
|
14
|
+
base(new AndroidJavaClass("com.taptap.sdk.kit.internal.enginebridge.EngineBridgeCallback"))
|
|
15
|
+
{
|
|
16
|
+
this.callback = action;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public override AndroidJavaObject Invoke(string method, object[] args)
|
|
20
|
+
{
|
|
21
|
+
if (method.Equals("onResult"))
|
|
22
|
+
{
|
|
23
|
+
if (args[0] is string)
|
|
24
|
+
{
|
|
25
|
+
string result = (string)(args[0]);
|
|
26
|
+
TapLoom.QueueOnMainThread(() =>
|
|
27
|
+
{
|
|
28
|
+
callback(new Result(result));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Concurrent;
|
|
3
|
+
using System.Runtime.InteropServices;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
namespace TapSDK.Core
|
|
7
|
+
{
|
|
8
|
+
public class BridgeIOS : IBridge
|
|
9
|
+
{
|
|
10
|
+
private static readonly BridgeIOS SInstance = new BridgeIOS();
|
|
11
|
+
|
|
12
|
+
private readonly ConcurrentDictionary<string, Action<Result>> dic;
|
|
13
|
+
|
|
14
|
+
public static BridgeIOS GetInstance()
|
|
15
|
+
{
|
|
16
|
+
return SInstance;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
private BridgeIOS()
|
|
20
|
+
{
|
|
21
|
+
dic = new ConcurrentDictionary<string, Action<Result>>();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private ConcurrentDictionary<string, Action<Result>> GetConcurrentDictionary()
|
|
25
|
+
{
|
|
26
|
+
return dic;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private delegate void EngineBridgeDelegate(string result);
|
|
30
|
+
|
|
31
|
+
[AOT.MonoPInvokeCallbackAttribute(typeof(EngineBridgeDelegate))]
|
|
32
|
+
static void engineBridgeDelegate(string resultJson)
|
|
33
|
+
{
|
|
34
|
+
var result = new Result(resultJson);
|
|
35
|
+
|
|
36
|
+
var actionDic = GetInstance().GetConcurrentDictionary();
|
|
37
|
+
|
|
38
|
+
Action<Result> action = null;
|
|
39
|
+
|
|
40
|
+
if (actionDic != null && actionDic.ContainsKey(result.callbackId))
|
|
41
|
+
{
|
|
42
|
+
action = actionDic[result.callbackId];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (action != null)
|
|
46
|
+
{
|
|
47
|
+
action(result);
|
|
48
|
+
if (result.onceTime && BridgeIOS.GetInstance().GetConcurrentDictionary()
|
|
49
|
+
.TryRemove(result.callbackId, out Action<Result> outAction))
|
|
50
|
+
{
|
|
51
|
+
Debug.Log($"TapSDK resolved current Action:{result.callbackId}");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
Debug.Log($"TapSDK iOS BridgeAction last Count:{BridgeIOS.GetInstance().GetConcurrentDictionary().Count}");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
public void Register(string serviceClz, string serviceImp)
|
|
61
|
+
{
|
|
62
|
+
//IOS无需注册
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public void Call(Command command)
|
|
66
|
+
{
|
|
67
|
+
#if UNITY_IOS
|
|
68
|
+
callHandler(command.ToJSON());
|
|
69
|
+
#endif
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public void Call(Command command, Action<Result> action)
|
|
73
|
+
{
|
|
74
|
+
if (!command.withCallback || string.IsNullOrEmpty(command.callbackId)) return;
|
|
75
|
+
if (!dic.ContainsKey(command.callbackId))
|
|
76
|
+
{
|
|
77
|
+
dic.GetOrAdd(command.callbackId, action);
|
|
78
|
+
}
|
|
79
|
+
#if UNITY_IOS
|
|
80
|
+
registerHandler(command.ToJSON(), engineBridgeDelegate);
|
|
81
|
+
#endif
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public string CallWithReturnValue(Command command, Action<Result> action)
|
|
85
|
+
{
|
|
86
|
+
if (command.callbackId != null && !dic.ContainsKey(command.callbackId))
|
|
87
|
+
{
|
|
88
|
+
dic.GetOrAdd(command.callbackId, action);
|
|
89
|
+
}
|
|
90
|
+
#if UNITY_IOS
|
|
91
|
+
if (action == null)
|
|
92
|
+
{
|
|
93
|
+
return callWithReturnValue(command.ToJSON(), null);
|
|
94
|
+
} else {
|
|
95
|
+
return callWithReturnValue(command.ToJSON(), engineBridgeDelegate);
|
|
96
|
+
}
|
|
97
|
+
#else
|
|
98
|
+
return null;
|
|
99
|
+
#endif
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
#if UNITY_IOS
|
|
103
|
+
[DllImport("__Internal")]
|
|
104
|
+
private static extern string callWithReturnValue(string command, EngineBridgeDelegate engineBridgeDelegate);
|
|
105
|
+
|
|
106
|
+
[DllImport("__Internal")]
|
|
107
|
+
private static extern void callHandler(string command);
|
|
108
|
+
|
|
109
|
+
[DllImport("__Internal")]
|
|
110
|
+
private static extern void registerHandler(string command, EngineBridgeDelegate engineBridgeDelegate);
|
|
111
|
+
#endif
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace TapSDK.Core
|
|
5
|
+
{
|
|
6
|
+
public class Command
|
|
7
|
+
{
|
|
8
|
+
[SerializeField] public string service;
|
|
9
|
+
[SerializeField] public string method;
|
|
10
|
+
[SerializeField] public string args;
|
|
11
|
+
[SerializeField] public bool withCallback;
|
|
12
|
+
[SerializeField] public string callbackId;
|
|
13
|
+
[SerializeField] public bool disposable;
|
|
14
|
+
|
|
15
|
+
public Command()
|
|
16
|
+
{
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public Command(string json)
|
|
21
|
+
{
|
|
22
|
+
JsonUtility.FromJsonOverwrite(json, this);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public string ToJSON()
|
|
26
|
+
{
|
|
27
|
+
return JsonUtility.ToJson(this);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public Command(string service, string method, bool callback, Dictionary<string, object> dic)
|
|
31
|
+
{
|
|
32
|
+
this.args = dic == null ? null : Json.Serialize(dic);
|
|
33
|
+
this.service = service;
|
|
34
|
+
this.method = method;
|
|
35
|
+
this.withCallback = callback;
|
|
36
|
+
this.callbackId = this.withCallback ? TapUUID.UUID() : null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public Command(string service, string method, bool callback, bool onceTime, Dictionary<string, object> dic)
|
|
40
|
+
{
|
|
41
|
+
this.args = dic == null ? null : Json.Serialize(dic);
|
|
42
|
+
this.service = service;
|
|
43
|
+
this.method = method;
|
|
44
|
+
this.withCallback = callback;
|
|
45
|
+
this.callbackId = this.withCallback ? TapUUID.UUID() : null;
|
|
46
|
+
this.disposable = onceTime;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public class Builder
|
|
50
|
+
{
|
|
51
|
+
private string service;
|
|
52
|
+
|
|
53
|
+
private string method;
|
|
54
|
+
|
|
55
|
+
private bool withCallback;
|
|
56
|
+
|
|
57
|
+
private string callbackId;
|
|
58
|
+
|
|
59
|
+
private bool disposable;
|
|
60
|
+
|
|
61
|
+
private Dictionary<string, object> args;
|
|
62
|
+
|
|
63
|
+
public Builder()
|
|
64
|
+
{
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public Builder Service(string service)
|
|
69
|
+
{
|
|
70
|
+
this.service = service;
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public Builder Method(string method)
|
|
75
|
+
{
|
|
76
|
+
this.method = method;
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public Builder OnceTime(bool onceTime)
|
|
81
|
+
{
|
|
82
|
+
this.disposable = onceTime;
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public Builder Args(Dictionary<string, object> dic)
|
|
87
|
+
{
|
|
88
|
+
this.args = dic;
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public Builder Args(string key, object value)
|
|
93
|
+
{
|
|
94
|
+
if (this.args == null)
|
|
95
|
+
{
|
|
96
|
+
this.args = new Dictionary<string, object>();
|
|
97
|
+
}
|
|
98
|
+
if(value is Dictionary<string,object>)
|
|
99
|
+
{
|
|
100
|
+
value = Json.Serialize(value);
|
|
101
|
+
}
|
|
102
|
+
this.args.Add(key, value);
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public Builder Callback(bool callback)
|
|
107
|
+
{
|
|
108
|
+
this.withCallback = callback;
|
|
109
|
+
this.callbackId = this.withCallback ? TapUUID.UUID() : null;
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public Command CommandBuilder()
|
|
114
|
+
{
|
|
115
|
+
return new Command(this.service, this.method, this.withCallback, this.disposable, this.args);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using TapSDK.Core.Internal;
|
|
3
|
+
|
|
4
|
+
namespace TapSDK.Core.Mobile
|
|
5
|
+
{
|
|
6
|
+
public static class EngineBridgeInitializer
|
|
7
|
+
{
|
|
8
|
+
private static bool isInitialized = false;
|
|
9
|
+
private const string SERVICE_NAME = "BridgeCoreService";
|
|
10
|
+
|
|
11
|
+
public static void Initialize()
|
|
12
|
+
{
|
|
13
|
+
if (!isInitialized)
|
|
14
|
+
{
|
|
15
|
+
Debug.Log("Initializing EngineBridge");
|
|
16
|
+
|
|
17
|
+
// TODO: android 注册桥接
|
|
18
|
+
// #if UNITY_ANDROID
|
|
19
|
+
EngineBridge.GetInstance().Register(
|
|
20
|
+
"com.taptap.sdk.core.unity.BridgeCoreService",
|
|
21
|
+
"com.taptap.sdk.core.unity.BridgeCoreServiceImpl");
|
|
22
|
+
// #endif
|
|
23
|
+
|
|
24
|
+
isInitialized = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public static Command.Builder GetBridgeServer()
|
|
29
|
+
{
|
|
30
|
+
return new Command.Builder().Service(SERVICE_NAME);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
|
|
3
|
+
namespace TapSDK.Core
|
|
4
|
+
{
|
|
5
|
+
public interface IBridge
|
|
6
|
+
{
|
|
7
|
+
void Register(string serviceClzName, string serviceImplName);
|
|
8
|
+
|
|
9
|
+
void Call(Command command);
|
|
10
|
+
|
|
11
|
+
void Call(Command command, Action<Result> action);
|
|
12
|
+
string CallWithReturnValue(Command command, Action<Result> action);
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
}
|