com.taptap.sdk.core 4.6.1-beta.1 → 4.6.1-beta.11

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.
@@ -4,7 +4,7 @@
4
4
  <repositories>
5
5
  <repository>https://repo.maven.apache.org/maven2</repository>
6
6
  </repositories>
7
- <androidPackage spec="com.taptap.sdk:tap-core-unity:4.6.1-beta.1"/>
7
+ <androidPackage spec="com.taptap.sdk:tap-core-unity:4.6.1-beta.11"/>
8
8
  </androidPackages>
9
9
  <iosPods>
10
10
  <sources>
@@ -1,5 +1,6 @@
1
1
  using System;
2
2
  using System.Linq;
3
+ using System.Collections.Generic;
3
4
  using UnityEngine;
4
5
 
5
6
  namespace TapSDK.Core.Internal.Utils {
@@ -12,18 +13,135 @@ namespace TapSDK.Core.Internal.Utils {
12
13
  Application.platform == RuntimePlatform.LinuxPlayer;
13
14
 
14
15
  public static object CreateBridgeImplementation(Type interfaceType, string startWith) {
16
+ Debug.Log($"[TapTap] 开始查找实现类: interfaceType={interfaceType.FullName}, startWith={startWith}, 当前平台={Application.platform}");
17
+
15
18
  // 跳过初始化直接使用 TapLoom会在子线程被TapSDK.Core.BridgeCallback.Invoke 初始化
16
19
  TapLoom.Initialize();
17
- Type bridgeImplementationType = AppDomain.CurrentDomain.GetAssemblies()
18
- .Where(asssembly => asssembly.GetName().FullName.StartsWith(startWith))
19
- .SelectMany(assembly => assembly.GetTypes())
20
- .SingleOrDefault(clazz => interfaceType.IsAssignableFrom(clazz) && clazz.IsClass);
21
- if (bridgeImplementationType == null){
22
- Debug.LogWarningFormat(
23
- $"[TapTap] TapSDK Can't find bridge implementation for {interfaceType} on platform {Application.platform}.");
20
+
21
+ // 获取所有程序集
22
+ var allAssemblies = AppDomain.CurrentDomain.GetAssemblies();
23
+ Debug.Log($"[TapTap] 已加载的程序集总数: {allAssemblies.Length}");
24
+
25
+ // 查找以 startWith 开头的程序集
26
+ var matchingAssemblies = allAssemblies
27
+ .Where(assembly => assembly.GetName().FullName.StartsWith(startWith))
28
+ .ToList();
29
+
30
+ Debug.Log($"[TapTap] 找到匹配 '{startWith}' 的程序集数量: {matchingAssemblies.Count}");
31
+
32
+ // 打印匹配的程序集名称
33
+ foreach (var assembly in matchingAssemblies) {
34
+ Debug.Log($"[TapTap] 匹配的程序集: {assembly.GetName().FullName}");
35
+ }
36
+
37
+ // 如果没有找到匹配的程序集,打印所有TapSDK相关的程序集
38
+ if (matchingAssemblies.Count == 0) {
39
+ var tapAssemblies = allAssemblies
40
+ .Where(assembly => assembly.GetName().FullName.Contains("TapSDK") ||
41
+ assembly.GetName().FullName.Contains("TapTap"))
42
+ .ToList();
43
+
44
+ Debug.Log($"[TapTap] 未找到匹配的程序集,但找到 {tapAssemblies.Count} 个相关程序集:");
45
+ foreach (var assembly in tapAssemblies) {
46
+ Debug.Log($"[TapTap] - {assembly.GetName().FullName}");
47
+ }
48
+ }
49
+
50
+ // 从匹配的程序集中查找实现指定接口的类
51
+ List<Type> allCandidateTypes = new List<Type>();
52
+ foreach (var assembly in matchingAssemblies) {
53
+ try {
54
+ var types = assembly.GetTypes()
55
+ .Where(type => type.IsClass && interfaceType.IsAssignableFrom(type))
56
+ .ToList();
57
+
58
+ Debug.Log($"[TapTap] 在程序集 {assembly.GetName().Name} 中找到 {types.Count} 个实现 {interfaceType.Name} 的类");
59
+
60
+ foreach (var type in types) {
61
+ Debug.Log($"[TapTap] - {type.FullName} (IsPublic: {type.IsPublic}, IsAbstract: {type.IsAbstract})");
62
+ allCandidateTypes.Add(type);
63
+ }
64
+ }
65
+ catch (Exception ex) {
66
+ Debug.LogError($"[TapTap] 获取程序集 {assembly.GetName().Name} 中的类型时出错: {ex.Message}");
67
+ }
68
+ }
69
+
70
+ // 使用原始逻辑查找实现类
71
+ Type bridgeImplementationType = null;
72
+ try {
73
+ bridgeImplementationType = matchingAssemblies
74
+ .SelectMany(assembly => {
75
+ try {
76
+ return assembly.GetTypes();
77
+ } catch {
78
+ return Type.EmptyTypes;
79
+ }
80
+ })
81
+ .SingleOrDefault(clazz => interfaceType.IsAssignableFrom(clazz) && clazz.IsClass);
82
+
83
+ Debug.Log($"[TapTap] SingleOrDefault 查找结果: {(bridgeImplementationType != null ? bridgeImplementationType.FullName : "null")}");
84
+
85
+ // 如果使用 SingleOrDefault 没找到,尝试使用 FirstOrDefault
86
+ if (bridgeImplementationType == null && allCandidateTypes.Count > 0) {
87
+ Debug.Log($"[TapTap] SingleOrDefault 未找到实现,但有 {allCandidateTypes.Count} 个候选类型,尝试使用 FirstOrDefault");
88
+ bridgeImplementationType = allCandidateTypes.FirstOrDefault();
89
+ Debug.Log($"[TapTap] FirstOrDefault 查找结果: {(bridgeImplementationType != null ? bridgeImplementationType.FullName : "null")}");
90
+ }
91
+
92
+ // 如果找到多个实现,可能是 SingleOrDefault 失败的原因
93
+ if (allCandidateTypes.Count > 1) {
94
+ Debug.LogWarning($"[TapTap] 找到多个实现 {interfaceType.Name} 的类,这可能导致 SingleOrDefault 返回 null");
95
+ foreach (var type in allCandidateTypes) {
96
+ Debug.LogWarning($"[TapTap] - {type.FullName}");
97
+ }
98
+ }
99
+ }
100
+ catch (Exception ex) {
101
+ Debug.LogError($"[TapTap] 在查找实现类时发生异常: {ex.Message}\n{ex.StackTrace}");
102
+ }
103
+
104
+ if (bridgeImplementationType == null) {
105
+ Debug.LogWarning($"[TapTap] TapSDK 无法为 {interfaceType} 找到平台 {Application.platform} 上的实现类。");
106
+
107
+ // 尝试在所有程序集中查找实现(不限制命名空间前缀)
108
+ if (matchingAssemblies.Count == 0) {
109
+ Debug.Log("[TapTap] 尝试在所有程序集中查找实现...");
110
+ List<Type> implementationsInAllAssemblies = new List<Type>();
111
+
112
+ foreach (var assembly in allAssemblies) {
113
+ try {
114
+ var types = assembly.GetTypes()
115
+ .Where(type => type.IsClass && !type.IsAbstract && interfaceType.IsAssignableFrom(type))
116
+ .ToList();
117
+
118
+ if (types.Count > 0) {
119
+ Debug.Log($"[TapTap] 在程序集 {assembly.GetName().Name} 中找到 {types.Count} 个实现");
120
+ implementationsInAllAssemblies.AddRange(types);
121
+ }
122
+ }
123
+ catch { /* 忽略错误 */ }
124
+ }
125
+
126
+ if (implementationsInAllAssemblies.Count > 0) {
127
+ Debug.Log($"[TapTap] 在所有程序集中找到 {implementationsInAllAssemblies.Count} 个实现:");
128
+ foreach (var type in implementationsInAllAssemblies) {
129
+ Debug.Log($"[TapTap] - {type.FullName} (在程序集 {type.Assembly.GetName().Name} 中)");
130
+ }
131
+ }
132
+ }
133
+
134
+ return null;
135
+ }
136
+
137
+ try {
138
+ Debug.Log($"[TapTap] 创建 {bridgeImplementationType.FullName} 的实例");
139
+ return Activator.CreateInstance(bridgeImplementationType);
140
+ }
141
+ catch (Exception ex) {
142
+ Debug.LogError($"[TapTap] 创建实例时出错: {ex.Message}");
24
143
  return null;
25
144
  }
26
- return Activator.CreateInstance(bridgeImplementationType);
27
145
  }
28
146
  }
29
147
  }
@@ -12,7 +12,7 @@ using System.ComponentModel;
12
12
 
13
13
  namespace TapSDK.Core {
14
14
  public class TapTapSDK {
15
- public static readonly string Version = "4.6.1-beta.1";
15
+ public static readonly string Version = "4.6.1-beta.11";
16
16
 
17
17
  public static string SDKPlatform = "TapSDK-Unity";
18
18
 
package/link.xml.meta CHANGED
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: 0ca12439a4b20437599a1ab394f65614
2
+ guid: 5524b4ff0e63942b7bb0efdbea294795
3
3
  TextScriptImporter:
4
4
  externalObjects: {}
5
5
  userData:
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "com.taptap.sdk.core",
3
3
  "displayName": "TapTapSDK Core",
4
4
  "description": "TapTapSDK Core",
5
- "version": "4.6.1-beta.1",
5
+ "version": "4.6.1-beta.11",
6
6
  "unity": "2019.4",
7
7
  "license": "MIT",
8
8
  "dependencies": {