com.beanbag.tiktokminigames 1.0.0
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/DefaultTemplate/backgroundlandscape.png +0 -0
- package/DefaultTemplate/backgroundlandscape.png.meta +159 -0
- package/DefaultTemplate/backgroundportrait.png +0 -0
- package/DefaultTemplate/backgroundportrait.png.meta +159 -0
- package/DefaultTemplate/game.js +151 -0
- package/DefaultTemplate/game.js.meta +7 -0
- package/DefaultTemplate/images/unity_logo.png +0 -0
- package/DefaultTemplate/images/unity_logo.png.meta +159 -0
- package/DefaultTemplate/images.meta +8 -0
- package/DefaultTemplate/plugin-config.js +23 -0
- package/DefaultTemplate/plugin-config.js.meta +7 -0
- package/DefaultTemplate/plugin.js +1 -0
- package/DefaultTemplate/plugin.js.meta +7 -0
- package/DefaultTemplate/unity-namespace.js +11 -0
- package/DefaultTemplate/unity-namespace.js.meta +7 -0
- package/DefaultTemplate/webgl-wasm-split.js +17 -0
- package/DefaultTemplate/webgl-wasm-split.js.meta +7 -0
- package/DefaultTemplate.meta +8 -0
- package/Editor/Extras/Integration/DouYinMiniGameSettings.cs +30 -0
- package/Editor/Extras/Integration/DouYinMiniGameSettings.cs.meta +11 -0
- package/Editor/Extras/Integration/DouYinMiniGameSettingsEditor.cs +354 -0
- package/Editor/Extras/Integration/DouYinMiniGameSettingsEditor.cs.meta +3 -0
- package/Editor/Extras/Integration/DouYinSubplatformInterface.cs +153 -0
- package/Editor/Extras/Integration/DouYinSubplatformInterface.cs.meta +3 -0
- package/Editor/Extras/Integration.meta +8 -0
- package/Editor/Extras/Providers/TTMiniGameSupportProvider.cs +148 -0
- package/Editor/Extras/Providers/TTMiniGameSupportProvider.cs.meta +3 -0
- package/Editor/Extras/Providers.meta +3 -0
- package/Editor/Extras/TTEditorSupportProviderRegister.cs +15 -0
- package/Editor/Extras/TTEditorSupportProviderRegister.cs.meta +3 -0
- package/Editor/Extras.meta +3 -0
- package/Editor/ttsdk_tools.dll +0 -0
- package/Editor/ttsdk_tools.dll.meta +33 -0
- package/Editor/ttsdk_tools.pdb +0 -0
- package/Editor/ttsdk_tools.pdb.meta +7 -0
- package/Editor.meta +8 -0
- package/LitJson/TTLitJson.dll +0 -0
- package/LitJson/TTLitJson.dll.meta +33 -0
- package/LitJson/TTLitJson.pdb +0 -0
- package/LitJson/TTLitJson.pdb.meta +7 -0
- package/LitJson.meta +8 -0
- package/TTSDK/ttsdk.dll +0 -0
- package/TTSDK/ttsdk.dll.meta +33 -0
- package/TTSDK/ttsdk.pdb +0 -0
- package/TTSDK/ttsdk.pdb.meta +7 -0
- package/TTSDK.meta +8 -0
- package/WebGL/AssetBundle/DownloadHandlerTTAssetBundle.cs +85 -0
- package/WebGL/AssetBundle/DownloadHandlerTTAssetBundle.cs.meta +3 -0
- package/WebGL/AssetBundle/TTAssetBundle.cs +72 -0
- package/WebGL/AssetBundle/TTAssetBundle.cs.meta +3 -0
- package/WebGL/AssetBundle/TTAssetBundleExtensions.cs +25 -0
- package/WebGL/AssetBundle/TTAssetBundleExtensions.cs.meta +3 -0
- package/WebGL/AssetBundle/TTAssetBundleProviders.cs.txt +1301 -0
- package/WebGL/AssetBundle/TTAssetBundleProviders.cs.txt.meta +3 -0
- package/WebGL/AssetBundle/TTAssetBundleRequest.cs +96 -0
- package/WebGL/AssetBundle/TTAssetBundleRequest.cs.meta +3 -0
- package/WebGL/AssetBundle.meta +8 -0
- package/WebGL/Compatibility/UnityCacheCompatibility.cs +49 -0
- package/WebGL/Compatibility/UnityCacheCompatibility.cs.meta +3 -0
- package/WebGL/Compatibility/UnityWebRequestCompatibility.cs +18 -0
- package/WebGL/Compatibility/UnityWebRequestCompatibility.cs.meta +3 -0
- package/WebGL/Compatibility.meta +3 -0
- package/WebGL/FileSystem/TTFileSystemManager.cs +460 -0
- package/WebGL/FileSystem/TTFileSystemManager.cs.meta +11 -0
- package/WebGL/FileSystem/TTFileSystemManagerDefault.cs +1039 -0
- package/WebGL/FileSystem/TTFileSystemManagerDefault.cs.meta +11 -0
- package/WebGL/FileSystem/TTFileSystemManagerWebGL.cs +1278 -0
- package/WebGL/FileSystem/TTFileSystemManagerWebGL.cs.meta +11 -0
- package/WebGL/FileSystem.meta +3 -0
- package/WebGL/Input/Input.cs +230 -0
- package/WebGL/Input/Input.cs.meta +3 -0
- package/WebGL/Input/TTPCInputHandler.cs +199 -0
- package/WebGL/Input/TTPCInputHandler.cs.meta +3 -0
- package/WebGL/Input.meta +3 -0
- package/WebGL/Network/TTUDPSocketHandler.cs +130 -0
- package/WebGL/Network/TTUDPSocketHandler.cs.meta +11 -0
- package/WebGL/Network.meta +3 -0
- package/WebGL/TTAssetBundle.jslib +33 -0
- package/WebGL/TTAssetBundle.jslib.meta +32 -0
- package/WebGL/TTCallbackHandler.cs +139 -0
- package/WebGL/TTCallbackHandler.cs.meta +3 -0
- package/WebGL/TTModel.cs +582 -0
- package/WebGL/TTModel.cs.meta +11 -0
- package/WebGL/TTSDK.jslib +592 -0
- package/WebGL/TTSDK.jslib.meta +32 -0
- package/WebGL/TTSDKType.cs +10 -0
- package/WebGL/TTSDKType.cs.meta +3 -0
- package/WebGL/TTStorageManager.cs +155 -0
- package/WebGL/TTStorageManager.cs.meta +11 -0
- package/WebGL/TTUNBridge.jslib +117 -0
- package/WebGL/TTUNBridge.jslib.meta +32 -0
- package/WebGL/TTVersionAttribute.cs +21 -0
- package/WebGL/TTVersionAttribute.cs.meta +11 -0
- package/WebGL/TTWebGL.asmdef +18 -0
- package/WebGL/TTWebGL.asmdef.meta +7 -0
- package/WebGL/TTWebGLInterface.cs +63 -0
- package/WebGL/TTWebGLInterface.cs.meta +11 -0
- package/WebGL.meta +8 -0
- package/package.json +13 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#if TUANJIE_1_5_OR_NEWER
|
|
2
|
+
#define TT_MINIGAME_BUILD_SUPPORTED
|
|
3
|
+
#endif
|
|
4
|
+
|
|
5
|
+
using UnityEditor;
|
|
6
|
+
using UnityEngine.Rendering;
|
|
7
|
+
#if !TT_MINIGAME_BUILD_SUPPORTED
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
namespace TTSDK.Tool
|
|
12
|
+
{
|
|
13
|
+
public class TTMiniGameSupportProvider : ITTMiniGameSupportProvider
|
|
14
|
+
{
|
|
15
|
+
|
|
16
|
+
private const string NotSupportedTips = "当前环境不支持 MiniGame 构建";
|
|
17
|
+
|
|
18
|
+
public bool SupportMiniGame()
|
|
19
|
+
{
|
|
20
|
+
#if TT_MINIGAME_BUILD_SUPPORTED
|
|
21
|
+
return true;
|
|
22
|
+
#else
|
|
23
|
+
return false;
|
|
24
|
+
#endif
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public int GetBuildTargetGroup(WasmSubFramework target)
|
|
28
|
+
{
|
|
29
|
+
if (target == WasmSubFramework.MiniGame)
|
|
30
|
+
{
|
|
31
|
+
#if TT_MINIGAME_BUILD_SUPPORTED
|
|
32
|
+
return (int)BuildTargetGroup.MiniGame;
|
|
33
|
+
#else
|
|
34
|
+
Debug.LogError(NotSupportedTips);
|
|
35
|
+
return (int)BuildTargetGroup.Unknown;
|
|
36
|
+
#endif
|
|
37
|
+
}
|
|
38
|
+
return (int)BuildTargetGroup.WebGL;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public int GetBuildTarget(WasmSubFramework target)
|
|
42
|
+
{
|
|
43
|
+
if (target == WasmSubFramework.MiniGame)
|
|
44
|
+
{
|
|
45
|
+
#if TT_MINIGAME_BUILD_SUPPORTED
|
|
46
|
+
return (int)BuildTarget.MiniGame;
|
|
47
|
+
#else
|
|
48
|
+
Debug.LogError(NotSupportedTips);
|
|
49
|
+
return (int)BuildTargetGroup.Unknown;
|
|
50
|
+
#endif
|
|
51
|
+
}
|
|
52
|
+
return (int)BuildTarget.WebGL;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public void SetPlayerSettingsMemorySize(WasmSubFramework target, int memorySize, bool profiling, PlayerSettings playerSettings = null)
|
|
56
|
+
{
|
|
57
|
+
if (memorySize <= 0)
|
|
58
|
+
return;
|
|
59
|
+
|
|
60
|
+
var emscriptenArgs = profiling ? $" -s TOTAL_MEMORY={memorySize}MB --memoryprofiler" : $" -s TOTAL_MEMORY={memorySize}MB";
|
|
61
|
+
if (target == WasmSubFramework.MiniGame)
|
|
62
|
+
{
|
|
63
|
+
#if TT_MINIGAME_BUILD_SUPPORTED
|
|
64
|
+
if (playerSettings != null)
|
|
65
|
+
{
|
|
66
|
+
PlayerSettings.MiniGame.SetMemorySize_Internal(playerSettings, (MiniGameDebugSymbolMode)memorySize);
|
|
67
|
+
PlayerSettings.MiniGame.SetEmscriptenArgs_Internal(playerSettings, emscriptenArgs);
|
|
68
|
+
}
|
|
69
|
+
else
|
|
70
|
+
{
|
|
71
|
+
PlayerSettings.MiniGame.memorySize = memorySize;
|
|
72
|
+
PlayerSettings.MiniGame.emscriptenArgs = emscriptenArgs;
|
|
73
|
+
}
|
|
74
|
+
#else
|
|
75
|
+
Debug.LogError(NotSupportedTips);
|
|
76
|
+
#endif
|
|
77
|
+
}
|
|
78
|
+
else
|
|
79
|
+
{
|
|
80
|
+
PlayerSettings.WebGL.memorySize = memorySize;
|
|
81
|
+
PlayerSettings.WebGL.emscriptenArgs = emscriptenArgs;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public void SetPlayerSettingsDebugSymbolMode(WasmSubFramework target, int mode, PlayerSettings playerSettings = null)
|
|
86
|
+
{
|
|
87
|
+
if (target == WasmSubFramework.MiniGame)
|
|
88
|
+
{
|
|
89
|
+
#if TT_MINIGAME_BUILD_SUPPORTED
|
|
90
|
+
if (playerSettings != null)
|
|
91
|
+
{
|
|
92
|
+
PlayerSettings.MiniGame.SetDebugSymbolMode_Internal(playerSettings, (MiniGameDebugSymbolMode)mode);
|
|
93
|
+
}
|
|
94
|
+
else
|
|
95
|
+
{
|
|
96
|
+
PlayerSettings.MiniGame.debugSymbolMode = (MiniGameDebugSymbolMode)mode;
|
|
97
|
+
}
|
|
98
|
+
#else
|
|
99
|
+
Debug.LogError(NotSupportedTips);
|
|
100
|
+
#endif
|
|
101
|
+
}
|
|
102
|
+
else
|
|
103
|
+
{
|
|
104
|
+
PlayerSettings.WebGL.debugSymbolMode = (WebGLDebugSymbolMode)mode;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public void SetPlayerSettingsRequiredModification(WasmSubFramework target, PlayerSettings playerSettings = null)
|
|
109
|
+
{
|
|
110
|
+
if (target == WasmSubFramework.MiniGame)
|
|
111
|
+
{
|
|
112
|
+
#if TT_MINIGAME_BUILD_SUPPORTED
|
|
113
|
+
if (playerSettings != null)
|
|
114
|
+
{
|
|
115
|
+
PlayerSettings.MiniGame.SetDataCaching_Internal(playerSettings, false);
|
|
116
|
+
PlayerSettings.MiniGame.SetNameFilesAsHashes_Internal(playerSettings, false);
|
|
117
|
+
PlayerSettings.MiniGame.SetCompressionFormat_Internal(playerSettings, MiniGameCompressionFormat.Disabled);
|
|
118
|
+
}
|
|
119
|
+
else
|
|
120
|
+
{
|
|
121
|
+
PlayerSettings.MiniGame.dataCaching = false;
|
|
122
|
+
PlayerSettings.MiniGame.nameFilesAsHashes = false;
|
|
123
|
+
PlayerSettings.MiniGame.compressionFormat = MiniGameCompressionFormat.Disabled;
|
|
124
|
+
}
|
|
125
|
+
#else
|
|
126
|
+
Debug.LogError(NotSupportedTips);
|
|
127
|
+
#endif
|
|
128
|
+
}
|
|
129
|
+
else
|
|
130
|
+
{
|
|
131
|
+
PlayerSettings.WebGL.dataCaching = false;
|
|
132
|
+
PlayerSettings.WebGL.nameFilesAsHashes = false;
|
|
133
|
+
PlayerSettings.WebGL.compressionFormat = WebGLCompressionFormat.Disabled;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public bool DetectWebGL2Required(WasmSubFramework target, PlayerSettings playerSettings = null)
|
|
138
|
+
{
|
|
139
|
+
#if TT_MINIGAME_BUILD_SUPPORTED
|
|
140
|
+
var targets = PlayerSettings.GetGraphicsAPIs_Internal(playerSettings, (BuildTarget)GetBuildTarget(target));
|
|
141
|
+
return targets.Length > 0 && targets[0] == GraphicsDeviceType.OpenGLES3;
|
|
142
|
+
#else
|
|
143
|
+
return false;
|
|
144
|
+
#endif
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
using UnityEditor;
|
|
2
|
+
|
|
3
|
+
namespace TTSDK.Tool
|
|
4
|
+
{
|
|
5
|
+
[InitializeOnLoad]
|
|
6
|
+
public class TTEditorSupportProviderRegister
|
|
7
|
+
{
|
|
8
|
+
static TTEditorSupportProviderRegister()
|
|
9
|
+
{
|
|
10
|
+
if (TTEditorSupportProvider.MiniGame == null)
|
|
11
|
+
TTEditorSupportProvider.RegisterMiniGameSupportProvider(new TTMiniGameSupportProvider());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: fffba5e91787b41d6b44b109cfacc7ce
|
|
3
|
+
PluginImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
iconMap: {}
|
|
7
|
+
executionOrder: {}
|
|
8
|
+
defineConstraints: []
|
|
9
|
+
isPreloaded: 0
|
|
10
|
+
isOverridable: 0
|
|
11
|
+
isExplicitlyReferenced: 0
|
|
12
|
+
validateReferences: 1
|
|
13
|
+
platformData:
|
|
14
|
+
- first:
|
|
15
|
+
Any:
|
|
16
|
+
second:
|
|
17
|
+
enabled: 0
|
|
18
|
+
settings: {}
|
|
19
|
+
- first:
|
|
20
|
+
Editor: Editor
|
|
21
|
+
second:
|
|
22
|
+
enabled: 1
|
|
23
|
+
settings:
|
|
24
|
+
DefaultValueInitialized: true
|
|
25
|
+
- first:
|
|
26
|
+
Windows Store Apps: WindowsStoreApps
|
|
27
|
+
second:
|
|
28
|
+
enabled: 0
|
|
29
|
+
settings:
|
|
30
|
+
CPU: AnyCPU
|
|
31
|
+
userData:
|
|
32
|
+
assetBundleName:
|
|
33
|
+
assetBundleVariant:
|
|
Binary file
|
package/Editor.meta
ADDED
|
Binary file
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 9c04f317d5eed4353b6d0d2142fe0503
|
|
3
|
+
PluginImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
iconMap: {}
|
|
7
|
+
executionOrder: {}
|
|
8
|
+
defineConstraints: []
|
|
9
|
+
isPreloaded: 0
|
|
10
|
+
isOverridable: 0
|
|
11
|
+
isExplicitlyReferenced: 0
|
|
12
|
+
validateReferences: 1
|
|
13
|
+
platformData:
|
|
14
|
+
- first:
|
|
15
|
+
Any:
|
|
16
|
+
second:
|
|
17
|
+
enabled: 1
|
|
18
|
+
settings: {}
|
|
19
|
+
- first:
|
|
20
|
+
Editor: Editor
|
|
21
|
+
second:
|
|
22
|
+
enabled: 0
|
|
23
|
+
settings:
|
|
24
|
+
DefaultValueInitialized: true
|
|
25
|
+
- first:
|
|
26
|
+
Windows Store Apps: WindowsStoreApps
|
|
27
|
+
second:
|
|
28
|
+
enabled: 0
|
|
29
|
+
settings:
|
|
30
|
+
CPU: AnyCPU
|
|
31
|
+
userData:
|
|
32
|
+
assetBundleName:
|
|
33
|
+
assetBundleVariant:
|
|
Binary file
|
package/LitJson.meta
ADDED
package/TTSDK/ttsdk.dll
ADDED
|
Binary file
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: ef1480e5e8dce479bbc02afd5d959d2a
|
|
3
|
+
PluginImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
iconMap: {}
|
|
7
|
+
executionOrder: {}
|
|
8
|
+
defineConstraints: []
|
|
9
|
+
isPreloaded: 0
|
|
10
|
+
isOverridable: 0
|
|
11
|
+
isExplicitlyReferenced: 0
|
|
12
|
+
validateReferences: 1
|
|
13
|
+
platformData:
|
|
14
|
+
- first:
|
|
15
|
+
Any:
|
|
16
|
+
second:
|
|
17
|
+
enabled: 1
|
|
18
|
+
settings: {}
|
|
19
|
+
- first:
|
|
20
|
+
Editor: Editor
|
|
21
|
+
second:
|
|
22
|
+
enabled: 0
|
|
23
|
+
settings:
|
|
24
|
+
DefaultValueInitialized: true
|
|
25
|
+
- first:
|
|
26
|
+
Windows Store Apps: WindowsStoreApps
|
|
27
|
+
second:
|
|
28
|
+
enabled: 0
|
|
29
|
+
settings:
|
|
30
|
+
CPU: AnyCPU
|
|
31
|
+
userData:
|
|
32
|
+
assetBundleName:
|
|
33
|
+
assetBundleVariant:
|
package/TTSDK/ttsdk.pdb
ADDED
|
Binary file
|
package/TTSDK.meta
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.IO;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
using UnityEngine.Networking;
|
|
5
|
+
using UnityEngine.Scripting;
|
|
6
|
+
|
|
7
|
+
namespace TTSDK
|
|
8
|
+
{
|
|
9
|
+
/**
|
|
10
|
+
* 只是用来承载 asset bundle 的获取,
|
|
11
|
+
* TTAssetBundle.load 触发下载后,这里并不会获取到真正的 Asset Bundle 数据
|
|
12
|
+
*/
|
|
13
|
+
public class DownloadHandlerTTAssetBundle : DownloadHandlerScript
|
|
14
|
+
{
|
|
15
|
+
public bool isDone;
|
|
16
|
+
|
|
17
|
+
private string _uri;
|
|
18
|
+
private uint _crc;
|
|
19
|
+
private AssetBundle _assetBundle;
|
|
20
|
+
private MemoryStream _contentStream;
|
|
21
|
+
private int _contentLength;
|
|
22
|
+
|
|
23
|
+
private static bool _isFallbackNoticed = false;
|
|
24
|
+
|
|
25
|
+
public DownloadHandlerTTAssetBundle(string uri, uint crc)
|
|
26
|
+
{
|
|
27
|
+
_uri = uri;
|
|
28
|
+
_crc = crc;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[Preserve]
|
|
32
|
+
public AssetBundle assetBundle
|
|
33
|
+
{
|
|
34
|
+
get
|
|
35
|
+
{
|
|
36
|
+
if (_assetBundle == null)
|
|
37
|
+
{
|
|
38
|
+
if (TTAssetBundle.isAbfsReady)
|
|
39
|
+
{
|
|
40
|
+
if (_contentLength != 0)
|
|
41
|
+
{
|
|
42
|
+
Debug.LogError($"DownloadHandlerTTAssetBundle contentLength not 0!");
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
_assetBundle = AssetBundle.LoadFromFile(_uri, _crc);
|
|
46
|
+
TTAssetBundle.bundle2path.Add(_assetBundle, _uri);
|
|
47
|
+
}
|
|
48
|
+
else
|
|
49
|
+
{
|
|
50
|
+
_assetBundle = AssetBundle.LoadFromMemory(_contentStream != null ? _contentStream.ToArray() : Array.Empty<byte>());
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return _assetBundle;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
[Preserve]
|
|
58
|
+
protected override byte[] GetData() => _contentStream != null ? _contentStream.ToArray() : null;
|
|
59
|
+
|
|
60
|
+
[Preserve]
|
|
61
|
+
protected override bool ReceiveData(byte[] data, int dataLength)
|
|
62
|
+
{
|
|
63
|
+
if (data == null || dataLength < 1)
|
|
64
|
+
return false;
|
|
65
|
+
|
|
66
|
+
#if !(UNITY_WEBGL && !UNITY_EDITOR)
|
|
67
|
+
if (!_isFallbackNoticed)
|
|
68
|
+
{
|
|
69
|
+
_isFallbackNoticed = true;
|
|
70
|
+
Debug.LogWarning("TTAssetBundle 仅在 WebGL 方案有优化效果,当前环境下回滚到 UnityWebRequestAssetBundle 加载实现。");
|
|
71
|
+
}
|
|
72
|
+
#endif
|
|
73
|
+
|
|
74
|
+
if (_contentStream == null)
|
|
75
|
+
_contentStream = new MemoryStream();
|
|
76
|
+
_contentStream.Write(data, 0, dataLength);
|
|
77
|
+
_contentLength += dataLength;
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
[Preserve]
|
|
82
|
+
protected override void CompleteContent() => isDone = true;
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
using UnityEngine.Networking;
|
|
4
|
+
#if UNITY_WEBGL && !UNITY_EDITOR
|
|
5
|
+
using System.Runtime.InteropServices;
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
namespace TTSDK
|
|
9
|
+
{
|
|
10
|
+
public class TTAssetBundle
|
|
11
|
+
{
|
|
12
|
+
|
|
13
|
+
public static Dictionary<AssetBundle, string> bundle2path = new Dictionary<AssetBundle, string>();
|
|
14
|
+
|
|
15
|
+
public static bool isAbfsReady = CheckReady();
|
|
16
|
+
|
|
17
|
+
#if UNITY_WEBGL && !UNITY_EDITOR
|
|
18
|
+
[DllImport("__Internal", EntryPoint = "StarkAbfsCheckReady")]
|
|
19
|
+
public static extern bool CheckReady();
|
|
20
|
+
#else
|
|
21
|
+
public static bool CheckReady()
|
|
22
|
+
{
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
#if UNITY_WEBGL && !UNITY_EDITOR
|
|
28
|
+
[DllImport("__Internal", EntryPoint = "StarkAbfsRegisterAssetBundleUrl")]
|
|
29
|
+
public static extern void RegisterAssetBundleUrl(string path);
|
|
30
|
+
#else
|
|
31
|
+
public static void RegisterAssetBundleUrl(string path) {
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
#endif
|
|
35
|
+
|
|
36
|
+
#if UNITY_WEBGL && !UNITY_EDITOR
|
|
37
|
+
[DllImport("__Internal", EntryPoint = "StarkAbfsUnregisterAssetBundleUrl")]
|
|
38
|
+
public static extern void UnregisterAssetBundleUrl(string path);
|
|
39
|
+
#else
|
|
40
|
+
public static void UnregisterAssetBundleUrl(string path) {
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
#endif
|
|
44
|
+
|
|
45
|
+
public static UnityWebRequest GetAssetBundle(string uri) => GetAssetBundle(uri, 0U);
|
|
46
|
+
|
|
47
|
+
public static UnityWebRequest GetAssetBundle(string uri, uint crc)
|
|
48
|
+
{
|
|
49
|
+
if (isAbfsReady)
|
|
50
|
+
RegisterAssetBundleUrl(uri);
|
|
51
|
+
|
|
52
|
+
return new UnityWebRequest(uri, "GET", new DownloadHandlerTTAssetBundle(uri, crc), null);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/// <summary>
|
|
56
|
+
/// Unload an AssetBundle and clean up the bundle2path tracking entry.
|
|
57
|
+
/// </summary>
|
|
58
|
+
public static void Unload(AssetBundle bundle, bool unloadAllLoadedObjects)
|
|
59
|
+
{
|
|
60
|
+
if (bundle == null) return;
|
|
61
|
+
if (bundle2path.ContainsKey(bundle))
|
|
62
|
+
{
|
|
63
|
+
string path = bundle2path[bundle];
|
|
64
|
+
bundle2path.Remove(bundle);
|
|
65
|
+
if (isAbfsReady)
|
|
66
|
+
UnregisterAssetBundleUrl(path);
|
|
67
|
+
}
|
|
68
|
+
bundle.Unload(unloadAllLoadedObjects);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
|
|
3
|
+
namespace TTSDK
|
|
4
|
+
{
|
|
5
|
+
public static class TTAssetBundleExtensions
|
|
6
|
+
{
|
|
7
|
+
public static void TTUnload(this AssetBundle ab, bool unloadAllLoadedObjects)
|
|
8
|
+
{
|
|
9
|
+
ab.Unload(unloadAllLoadedObjects);
|
|
10
|
+
|
|
11
|
+
if (!TTAssetBundle.isAbfsReady)
|
|
12
|
+
return;
|
|
13
|
+
|
|
14
|
+
if (TTAssetBundle.bundle2path.TryGetValue(ab, out var path))
|
|
15
|
+
{
|
|
16
|
+
TTAssetBundle.UnregisterAssetBundleUrl(path);
|
|
17
|
+
TTAssetBundle.bundle2path.Remove(ab);
|
|
18
|
+
}
|
|
19
|
+
else
|
|
20
|
+
{
|
|
21
|
+
Debug.LogError("AssetBundle.TTUnload() Failure: Unregistered Asset Bundle. Loaded without TTAssetBundle methods?");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|