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,11 @@
|
|
|
1
|
+
const unityNamespace = {
|
|
2
|
+
unityVersion: '$UNITY_VERSION',
|
|
3
|
+
assetBundleFSEnabled: $ASSET_BUNDLEFS_ENABLED,
|
|
4
|
+
assetBundleBufferCapacity: $ASSET_BUNDLE_BUFFER_CAPACITY,
|
|
5
|
+
assetBundleBufferTTL: $ASSET_BUNDLE_BUFFERTTL,
|
|
6
|
+
optimizeWebGLMemoryInBackground: $OPTIMIZE_WEBGL_MEMORY_INBACKGROUND,
|
|
7
|
+
bootConfig: '$BOOT_CONFIG_INFO',
|
|
8
|
+
UnityModule: null,
|
|
9
|
+
}
|
|
10
|
+
GameGlobal.unityNamespace = GameGlobal.unityNamespace || unityNamespace;
|
|
11
|
+
module.exports = unityNamespace;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
originalWasmMd5: "$ORIGINALWASMMD5",
|
|
3
|
+
wasmTableSize: "$WASMTABLESIZE",
|
|
4
|
+
wasmSplitVersion: "$WASMSPLITVERSION",
|
|
5
|
+
subJsUrl: "$SUBJSURL",
|
|
6
|
+
usingWasmH5: "$USINGWASMH5",
|
|
7
|
+
enableWasmCollect: "$ENABLEWASMCOLLECT",
|
|
8
|
+
enableWasmSplit: "$ENABLEWASMSPLIT",
|
|
9
|
+
globalVarList: ["$GLOBALVARLIST"],
|
|
10
|
+
wasmCollectAPIVer: "v4",
|
|
11
|
+
|
|
12
|
+
ANDROID_CODE_FILE_MD5: "$ANDROID_CODE_FILE_MD5",
|
|
13
|
+
ANDROID_SUB_CODE_FILE_MD5: "$SUB_CODE_FILE_MD5",
|
|
14
|
+
ARCHIVE_CODE_FILE_MD5: "$ARCHIVE_CODE_FILE_MD5",
|
|
15
|
+
IOS_CODE_FILE_MD5: "$IOS_CODE_FILE_MD5",
|
|
16
|
+
enableArchiveMode: "$ENABLEARCHIVEMODE"
|
|
17
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#if TUANJIE_1_5_OR_NEWER
|
|
2
|
+
using UnityEditor.Build.Profile;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace TTSDK.Tool
|
|
6
|
+
{
|
|
7
|
+
class DouYinMiniGameSettings: MiniGameSettings
|
|
8
|
+
{
|
|
9
|
+
[SerializeField] public string appId = "";
|
|
10
|
+
[SerializeField] public int wasmMemorySize = 128;
|
|
11
|
+
[SerializeField] public string[] urlCacheList;
|
|
12
|
+
[SerializeField] public string[] dontCacheFileNames;
|
|
13
|
+
[SerializeField] public bool needCompress = true;
|
|
14
|
+
[SerializeField] public bool profiling = false;
|
|
15
|
+
[SerializeField] public bool iOSPerformancePlus = false;
|
|
16
|
+
[SerializeField] public int orientation = (int)TTDeviceOrientation.Portrait;
|
|
17
|
+
|
|
18
|
+
[SerializeField] public string CDN = "";
|
|
19
|
+
[SerializeField] public string preloadFiles = "";
|
|
20
|
+
[SerializeField] public string preloadDataListUrl = "";
|
|
21
|
+
[SerializeField] public bool clearStreamingAssets = false;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
[SerializeField] public bool isOldBuildFormat = false;
|
|
25
|
+
public DouYinMiniGameSettings(MiniGameSettingsEditor editor) : base(editor)
|
|
26
|
+
{
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
#endif
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
#if TUANJIE_1_5_OR_NEWER
|
|
2
|
+
using System;
|
|
3
|
+
using UnityEditor;
|
|
4
|
+
using UnityEditor.Build.Profile;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
using System.Collections.Generic;
|
|
7
|
+
using UnityEngine.Rendering;
|
|
8
|
+
using System.Linq;
|
|
9
|
+
|
|
10
|
+
namespace TTSDK.Tool
|
|
11
|
+
{
|
|
12
|
+
class DouYinMiniGameSettingsEditor : MiniGameSettingsEditor
|
|
13
|
+
{
|
|
14
|
+
private readonly Dictionary<string, string> _editingInputData = new Dictionary<string, string>();
|
|
15
|
+
private readonly Dictionary<string, bool> _editingBooleanData = new Dictionary<string, bool>();
|
|
16
|
+
private readonly Dictionary<string, int> _editingEnumData = new Dictionary<string, int>();
|
|
17
|
+
|
|
18
|
+
private bool _isFoldInfoOptions = true;
|
|
19
|
+
private bool _isFoldLaunchOptions = true;
|
|
20
|
+
private bool _isFoldPreloadOptions = true;
|
|
21
|
+
private bool _isFoldCompileOptions = true;
|
|
22
|
+
|
|
23
|
+
private static int _textareaHeight = 50;
|
|
24
|
+
private static float _labelWidth = 140;
|
|
25
|
+
private static float _toggleWidth = 16;
|
|
26
|
+
private static float _snapPadding = 10;
|
|
27
|
+
private static float _fieldWidth => EditorGUIUtility.currentViewWidth - (_labelWidth + _snapPadding * 2 + 35);
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
public override void OnMiniGameSettingsIMGUI(SerializedObject serializedObject, SerializedProperty miniGameProperty)
|
|
31
|
+
{
|
|
32
|
+
ReadSettingsProperties(miniGameProperty);
|
|
33
|
+
serializedObject.UpdateIfRequiredOrScript();
|
|
34
|
+
|
|
35
|
+
DrawDouYinSettingsGUI(serializedObject, miniGameProperty);
|
|
36
|
+
|
|
37
|
+
SaveSettingsModifiedProperties(miniGameProperty);
|
|
38
|
+
serializedObject.ApplyModifiedProperties();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#region Style
|
|
42
|
+
|
|
43
|
+
private void DrawDouYinSettingsGUI(SerializedObject serializedObject, SerializedProperty miniGameProperty)
|
|
44
|
+
{
|
|
45
|
+
_isFoldInfoOptions = EditorGUILayout.Foldout(_isFoldInfoOptions, "基本信息");
|
|
46
|
+
if (_isFoldInfoOptions)
|
|
47
|
+
{
|
|
48
|
+
EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true));
|
|
49
|
+
|
|
50
|
+
CreateInput("appId", "Game AppID");
|
|
51
|
+
CreateEnumPopup("orientation", "游戏方向", new[] { "Portrait", "Landscape" }, new[] { 0, 1 });
|
|
52
|
+
CreateInput("wasmMemorySize", "UnityHeap 内存 (?)", "UnityHeap预留内存大小。根据游戏而定,默认128M.调试期间开启Profiler时,TotalMemory的值即代表此值,此值的设定遵循以下原则:\n1.请勿设置过小或过大,尽量不低于32或大于2048,否则游戏运行会有问题。\n2.运行完所有场景期间都不触发TotalMemory的增长,\n3.此值不宜设置过大,越大代表能运行的玩家所少,越容易出现内存不足的问题。\n因此如果TotalMemory有增长,那么设置一个稍大于TotalMemory的整数即可");
|
|
53
|
+
|
|
54
|
+
EditorGUILayout.EndVertical();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
_isFoldLaunchOptions = EditorGUILayout.Foldout(_isFoldLaunchOptions, "启动加载配置");
|
|
58
|
+
if (_isFoldLaunchOptions)
|
|
59
|
+
{
|
|
60
|
+
EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true));
|
|
61
|
+
|
|
62
|
+
CreateBoolean("needCompress", "压缩首包资源");
|
|
63
|
+
CreateTextarea("urlCacheList", "缓存资源域名 (?)", "配置的域名下资源会使用缓存\n一个域名占一行\n示例: douyin.com");
|
|
64
|
+
CreateTextarea("dontCacheFileNames", "不缓存的文件 (?)", "配置的文件名每次都会重新下载,不会缓存\n一个文件名一行,可填写后缀名匹配,不支持通配符。\n示例: json");
|
|
65
|
+
|
|
66
|
+
EditorGUILayout.EndVertical();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_isFoldPreloadOptions = EditorGUILayout.Foldout(_isFoldPreloadOptions, new UnityEngine.GUIContent("预下载配置 (Experimental)", "小游戏提供游戏启动前以及游戏启动后对指定资源预下载的能力,提升游戏加载速度。"));
|
|
70
|
+
if (_isFoldPreloadOptions)
|
|
71
|
+
{
|
|
72
|
+
EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true));
|
|
73
|
+
|
|
74
|
+
CreateInput("preloadFiles", "文件列表 (?)", "使用;间隔,支持模糊匹配");
|
|
75
|
+
CreateInput("CDN", "游戏资源 CDN", "资源部署 CDN 的前缀,仅用于预下载");
|
|
76
|
+
CreateInput("preloadDataListUrl", "动态资源列表接口", "开发者自行实现的接口,其接口返回结构需满足预下载能力要求");
|
|
77
|
+
|
|
78
|
+
EditorGUILayout.EndVertical();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
_isFoldCompileOptions = EditorGUILayout.Foldout(_isFoldCompileOptions, "调试编译选项");
|
|
82
|
+
if (_isFoldCompileOptions)
|
|
83
|
+
{
|
|
84
|
+
EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(false));
|
|
85
|
+
|
|
86
|
+
var graphicsAPIs = PlayerSettings.GetGraphicsAPIs(BuildTarget.MiniGame);
|
|
87
|
+
_editingBooleanData["isWebGL2"] = graphicsAPIs.Length > 0 && graphicsAPIs[0] == GraphicsDeviceType.OpenGLES3;
|
|
88
|
+
CreateBoolean("isWebGL2", "WebGL2.0 (beta)", null, true, "Managed via PlayerSettings", "WebGL2.0 配置现在由引擎管理,请在 Player Settings 中配置 Graphics APIs,此处不再生效");
|
|
89
|
+
CreateBoolean("clearStreamingAssets", "Clear Streaming Assets", "构建时移除产物中 StreamingAssets 目录下的文件");
|
|
90
|
+
CreateBoolean("iOSPerformancePlus", "开启高性能+模式", "针对iOS系统开启高性能+模式,降低游戏内存压力、提升渲染兼容性和效率", false, null, null,
|
|
91
|
+
() =>
|
|
92
|
+
{
|
|
93
|
+
EditorGUILayout.LabelField(string.Empty, GUILayout.Width(_snapPadding));
|
|
94
|
+
if (GUILayout.Button("什么是高性能+模式?", EditorStyles.linkLabel))
|
|
95
|
+
{
|
|
96
|
+
Application.OpenURL("https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/develop/guide/performance-optimization/high-performance-plus-mode");
|
|
97
|
+
}
|
|
98
|
+
EditorGUILayout.LabelField(string.Empty, GUILayout.Width(_snapPadding));
|
|
99
|
+
});
|
|
100
|
+
CreateBoolean("profiling", "显示性能面板");
|
|
101
|
+
CreateBoolean("isOldBuildFormat", "是否采用旧格式打包");
|
|
102
|
+
|
|
103
|
+
EditorGUILayout.EndVertical();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/// <summary>
|
|
109
|
+
/// 创建配置项标签
|
|
110
|
+
/// </summary>
|
|
111
|
+
private void CreateFieldLabel(string label, string tooltip = null)
|
|
112
|
+
{
|
|
113
|
+
EditorGUILayout.LabelField(string.Empty, GUILayout.Width(_snapPadding));
|
|
114
|
+
if (tooltip == null)
|
|
115
|
+
{
|
|
116
|
+
GUILayout.Label(label, GUILayout.Width(_labelWidth));
|
|
117
|
+
}
|
|
118
|
+
else
|
|
119
|
+
{
|
|
120
|
+
GUILayout.Label(new GUIContent(label, tooltip), GUILayout.Width(_labelWidth));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/// <summary>
|
|
125
|
+
/// 创建单行输入控件
|
|
126
|
+
/// </summary>
|
|
127
|
+
private void CreateInput(string name, string label, string tooltip = null)
|
|
128
|
+
{
|
|
129
|
+
if (!_editingInputData.TryGetValue(name, out var value))
|
|
130
|
+
_editingInputData[name] = value = "";
|
|
131
|
+
|
|
132
|
+
GUILayout.BeginHorizontal();
|
|
133
|
+
CreateFieldLabel(label, tooltip);
|
|
134
|
+
_editingInputData[name] = GUILayout.TextField(value, GUILayout.MaxWidth(_fieldWidth));
|
|
135
|
+
GUILayout.EndHorizontal();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/// <summary>
|
|
139
|
+
/// 创建多行输入控件
|
|
140
|
+
/// </summary>
|
|
141
|
+
private void CreateTextarea(string name, string label, string tooltip = null)
|
|
142
|
+
{
|
|
143
|
+
if (!_editingInputData.TryGetValue(name, out var value))
|
|
144
|
+
_editingInputData[name] = value = "";
|
|
145
|
+
|
|
146
|
+
GUILayout.BeginHorizontal();
|
|
147
|
+
CreateFieldLabel(label, tooltip);
|
|
148
|
+
EditorGUI.BeginDisabledGroup(false);
|
|
149
|
+
_editingInputData[name] = EditorGUILayout.TextArea(value,
|
|
150
|
+
GUILayout.MaxWidth(_fieldWidth), GUILayout.MinHeight(_textareaHeight));
|
|
151
|
+
EditorGUI.EndDisabledGroup();
|
|
152
|
+
GUILayout.EndHorizontal();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
/// <summary>
|
|
157
|
+
/// 创建布尔型复选框控件
|
|
158
|
+
/// </summary>
|
|
159
|
+
private void CreateBoolean(string name, string label, string tooltip = null, bool disabled = false, string disabledLabel = null, string disabledTooltip = null, Action createAction = null)
|
|
160
|
+
{
|
|
161
|
+
if (!_editingBooleanData.TryGetValue(name, out var value))
|
|
162
|
+
_editingBooleanData[name] = value = false;
|
|
163
|
+
|
|
164
|
+
GUILayout.BeginHorizontal();
|
|
165
|
+
CreateFieldLabel(label, tooltip);
|
|
166
|
+
EditorGUI.BeginDisabledGroup(disabled);
|
|
167
|
+
_editingBooleanData[name] = EditorGUILayout.Toggle(value, GUILayout.Width(_toggleWidth));
|
|
168
|
+
if (disabled && disabledLabel != null)
|
|
169
|
+
{
|
|
170
|
+
EditorGUILayout.LabelField(string.Empty, GUILayout.Width(_snapPadding));
|
|
171
|
+
if (disabledTooltip == null)
|
|
172
|
+
{
|
|
173
|
+
GUILayout.Label(disabledLabel);
|
|
174
|
+
}
|
|
175
|
+
else
|
|
176
|
+
{
|
|
177
|
+
GUILayout.Label(new UnityEngine.GUIContent(disabledLabel, disabledTooltip));
|
|
178
|
+
}
|
|
179
|
+
EditorGUILayout.LabelField(string.Empty, GUILayout.Width(_snapPadding));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (createAction != null)
|
|
183
|
+
createAction();
|
|
184
|
+
|
|
185
|
+
EditorGUI.EndDisabledGroup();
|
|
186
|
+
GUILayout.EndHorizontal();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/// <summary>
|
|
190
|
+
/// 创建枚举下拉选框控件
|
|
191
|
+
/// </summary>
|
|
192
|
+
private void CreateEnumPopup(string name, string label, string[] options, int[] values, string tooltip = null)
|
|
193
|
+
{
|
|
194
|
+
if (!_editingEnumData.TryGetValue(name, out var value))
|
|
195
|
+
_editingEnumData[name] = value = 0;
|
|
196
|
+
|
|
197
|
+
GUILayout.BeginHorizontal();
|
|
198
|
+
CreateFieldLabel(label, tooltip);
|
|
199
|
+
_editingEnumData[name] = EditorGUILayout.IntPopup(value, options, values, GUILayout.MaxWidth(_fieldWidth));
|
|
200
|
+
GUILayout.EndHorizontal();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
#endregion
|
|
204
|
+
|
|
205
|
+
#region Data
|
|
206
|
+
|
|
207
|
+
/// <summary>
|
|
208
|
+
/// 从配置文件读取所有属性
|
|
209
|
+
/// </summary>
|
|
210
|
+
/// <param name="miniGameProperty"></param>
|
|
211
|
+
private void ReadSettingsProperties(SerializedProperty miniGameProperty)
|
|
212
|
+
{
|
|
213
|
+
_editingInputData["appId"] = ReadProperty<string>(miniGameProperty, "appId");
|
|
214
|
+
_editingInputData["wasmMemorySize"] = ReadProperty<int>(miniGameProperty, "wasmMemorySize").ToString();
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
_editingInputData["CDN"] = ReadProperty<string>(miniGameProperty, "CDN");
|
|
218
|
+
_editingInputData["preloadFiles"] = ReadProperty<string>(miniGameProperty, "preloadFiles");
|
|
219
|
+
_editingInputData["preloadDataListUrl"] = ReadProperty<string>(miniGameProperty, "preloadDataListUrl");
|
|
220
|
+
|
|
221
|
+
_editingInputData["urlCacheList"] = ReadProperty<string>(miniGameProperty, "urlCacheList");
|
|
222
|
+
_editingInputData["dontCacheFileNames"] = ReadProperty<string>(miniGameProperty, "dontCacheFileNames");
|
|
223
|
+
|
|
224
|
+
_editingBooleanData["needCompress"] = ReadProperty<bool>(miniGameProperty, "needCompress");
|
|
225
|
+
_editingBooleanData["iOSPerformancePlus"] = ReadProperty<bool>(miniGameProperty, "iOSPerformancePlus");
|
|
226
|
+
_editingBooleanData["profiling"] = ReadProperty<bool>(miniGameProperty, "profiling");
|
|
227
|
+
_editingBooleanData["clearStreamingAssets"] = ReadProperty<bool>(miniGameProperty, "clearStreamingAssets");
|
|
228
|
+
|
|
229
|
+
_editingEnumData["orientation"] = ReadProperty<int>(miniGameProperty, "orientation");
|
|
230
|
+
|
|
231
|
+
_editingBooleanData["isOldBuildFormat"] = ReadProperty<bool>(miniGameProperty, "isOldBuildFormat");
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/// <summary>
|
|
237
|
+
/// 保存所有属性到配置文件
|
|
238
|
+
/// </summary>
|
|
239
|
+
/// <param name="miniGameProperty"></param>
|
|
240
|
+
private void SaveSettingsModifiedProperties(SerializedProperty miniGameProperty)
|
|
241
|
+
{
|
|
242
|
+
SaveProperty(miniGameProperty, "appId", _editingInputData["appId"]);
|
|
243
|
+
SaveProperty(miniGameProperty, "wasmMemorySize", int.Parse(_editingInputData["wasmMemorySize"]));
|
|
244
|
+
|
|
245
|
+
SaveProperty(miniGameProperty, "CDN", _editingInputData["CDN"]);
|
|
246
|
+
SaveProperty(miniGameProperty, "preloadFiles", _editingInputData["preloadFiles"]);
|
|
247
|
+
SaveProperty(miniGameProperty, "preloadDataListUrl", _editingInputData["preloadDataListUrl"]);
|
|
248
|
+
|
|
249
|
+
SaveProperty(miniGameProperty, "urlCacheList", _editingInputData["urlCacheList"]);
|
|
250
|
+
SaveProperty(miniGameProperty, "dontCacheFileNames", _editingInputData["dontCacheFileNames"]);
|
|
251
|
+
|
|
252
|
+
SaveProperty(miniGameProperty, "needCompress", _editingBooleanData["needCompress"]);
|
|
253
|
+
SaveProperty(miniGameProperty, "iOSPerformancePlus", _editingBooleanData["iOSPerformancePlus"]);
|
|
254
|
+
SaveProperty(miniGameProperty, "profiling", _editingBooleanData["profiling"]);
|
|
255
|
+
SaveProperty(miniGameProperty, "clearStreamingAssets", _editingBooleanData["clearStreamingAssets"]);
|
|
256
|
+
|
|
257
|
+
SaveProperty(miniGameProperty, "orientation", _editingEnumData["orientation"]);
|
|
258
|
+
|
|
259
|
+
SaveProperty(miniGameProperty, "isOldBuildFormat", _editingBooleanData["isOldBuildFormat"]);
|
|
260
|
+
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/// <summary>
|
|
264
|
+
/// 从配置文件读入属性字段
|
|
265
|
+
/// </summary>
|
|
266
|
+
private static T ReadProperty<T>(SerializedProperty miniGameProperty, string propertyName)
|
|
267
|
+
{
|
|
268
|
+
var property = miniGameProperty.FindPropertyRelative(propertyName);
|
|
269
|
+
if (property == null)
|
|
270
|
+
return default;
|
|
271
|
+
|
|
272
|
+
var rt = typeof(T);
|
|
273
|
+
|
|
274
|
+
if (property.isArray && property.arrayElementType == "string")
|
|
275
|
+
{
|
|
276
|
+
var arr = new string[property.arraySize];
|
|
277
|
+
for (var i = 0; i < property.arraySize; ++i)
|
|
278
|
+
{
|
|
279
|
+
arr[i] = property.GetArrayElementAtIndex(i).stringValue;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return (T)(object)string.Join("\n", arr);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (rt == typeof(bool))
|
|
286
|
+
{
|
|
287
|
+
return (T)(object)property.boolValue;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (rt == typeof(int))
|
|
291
|
+
{
|
|
292
|
+
return (T)(object)property.intValue;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (rt == typeof(float))
|
|
296
|
+
{
|
|
297
|
+
return (T)(object)property.floatValue;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (rt == typeof(string))
|
|
301
|
+
{
|
|
302
|
+
return (T)(object)property.stringValue;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
throw new Exception($"Unsupported property type with ReadProperty<{typeof(T).FullName}>.");
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/// <summary>
|
|
309
|
+
/// 保存属性字段值到配置文件
|
|
310
|
+
/// </summary>
|
|
311
|
+
private static void SaveProperty<T>(SerializedProperty miniGameProperty, string propertyName, T value)
|
|
312
|
+
{
|
|
313
|
+
var property = miniGameProperty.FindPropertyRelative(propertyName);
|
|
314
|
+
var rt = typeof(T);
|
|
315
|
+
|
|
316
|
+
if (property.isArray && property.arrayElementType == "string")
|
|
317
|
+
{
|
|
318
|
+
var raw = (string)(object)value;
|
|
319
|
+
var arr = raw.Split('\n');
|
|
320
|
+
arr = arr.Where(x => x.Length > 0).ToArray(); // 移除其中的空字符串
|
|
321
|
+
property.arraySize = arr.Length;
|
|
322
|
+
for (var i = 0; i < property.arraySize; ++i)
|
|
323
|
+
{
|
|
324
|
+
var elm = property.GetArrayElementAtIndex(i);
|
|
325
|
+
elm.stringValue = arr[i];
|
|
326
|
+
elm.stringValue = elm.stringValue.Trim();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
else if (rt == typeof(bool))
|
|
330
|
+
{
|
|
331
|
+
property.boolValue = (bool)(object)value;
|
|
332
|
+
}
|
|
333
|
+
else if (rt == typeof(int))
|
|
334
|
+
{
|
|
335
|
+
property.intValue = (int)(object)value;
|
|
336
|
+
}
|
|
337
|
+
else if (rt == typeof(float))
|
|
338
|
+
{
|
|
339
|
+
property.floatValue = (float)(object)value;
|
|
340
|
+
}
|
|
341
|
+
else if (rt == typeof(string))
|
|
342
|
+
{
|
|
343
|
+
property.stringValue = (string)(object)value;
|
|
344
|
+
}
|
|
345
|
+
else
|
|
346
|
+
{
|
|
347
|
+
throw new Exception($"Unsupported property type with SaveProperty<{typeof(T).FullName}>.");
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
#endregion
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
#endif
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#if TUANJIE_1_5_OR_NEWER
|
|
2
|
+
using UnityEditor;
|
|
3
|
+
using UnityEditor.Build;
|
|
4
|
+
using UnityEditor.Build.Profile;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace TTSDK.Tool
|
|
8
|
+
{
|
|
9
|
+
[InitializeOnLoad]
|
|
10
|
+
public static class DouYinSubTargetManager
|
|
11
|
+
{
|
|
12
|
+
static DouYinSubTargetManager()
|
|
13
|
+
{
|
|
14
|
+
MiniGameSubplatformManager.RegisterSubplatform(new DouYinSubplatformInterface());
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public class DouYinSubplatformInterface : MiniGameSubplatformInterface
|
|
19
|
+
{
|
|
20
|
+
|
|
21
|
+
public override string GetSubplatformName()
|
|
22
|
+
{
|
|
23
|
+
return "DouYin:抖音小游戏";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public override MiniGameSettings GetSubplatformSettings()
|
|
27
|
+
{
|
|
28
|
+
return new DouYinMiniGameSettings(new DouYinMiniGameSettingsEditor());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public override string GetSubplatformLink()
|
|
32
|
+
{
|
|
33
|
+
return "https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/guide/overview";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public override string GetSubplatformTooltip()
|
|
37
|
+
{
|
|
38
|
+
return "点击查看抖音小游戏文档";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public override BuildMiniGameError Build(BuildProfile buildProfile)
|
|
42
|
+
{
|
|
43
|
+
// 1.Pre-processing
|
|
44
|
+
string buildProfilePath = AssetDatabase.GetAssetPath(buildProfile); // Save the path of the buildProfile for post-processing
|
|
45
|
+
string buildPath = buildProfile.buildPath;
|
|
46
|
+
var douYinMiniGameSettings = buildProfile.miniGameSettings as DouYinMiniGameSettings;
|
|
47
|
+
if (douYinMiniGameSettings is null)
|
|
48
|
+
{
|
|
49
|
+
Debug.LogError("预处理阶段 BuildProfile 不合法");
|
|
50
|
+
return BuildMiniGameError.InvalidInput;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
PlayerSettings playerSettings = AssetDatabase.LoadAssetAtPath<PlayerSettings>("ProjectSettings/ProjectSettings.asset"); // Global PlayerSettings
|
|
54
|
+
if (buildProfile.HasOverrridePlayersettings())
|
|
55
|
+
playerSettings = buildProfile.playerSettings; // Override PlayerSettings
|
|
56
|
+
|
|
57
|
+
if (!IsBuildSettingsValid(douYinMiniGameSettings, playerSettings))
|
|
58
|
+
{
|
|
59
|
+
return BuildMiniGameError.InvalidInput;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 2.BuildPlayer
|
|
63
|
+
SyncBuildSettingsToStark(douYinMiniGameSettings);
|
|
64
|
+
// var res = API.BuildManager.BuildForTuanjie(buildPath, playerSettings);
|
|
65
|
+
// Debug.Log($"=================> build: {res}");
|
|
66
|
+
// if (string.IsNullOrEmpty(res))
|
|
67
|
+
// {
|
|
68
|
+
// return BuildMiniGameError.SubplatformConvertFailed;
|
|
69
|
+
// }
|
|
70
|
+
|
|
71
|
+
// 3.Post-processing
|
|
72
|
+
BuildProfile reloadBuildProfile = AssetDatabase.LoadAssetAtPath<BuildProfile>(buildProfilePath);
|
|
73
|
+
douYinMiniGameSettings = reloadBuildProfile.miniGameSettings as DouYinMiniGameSettings;
|
|
74
|
+
if (douYinMiniGameSettings is null)
|
|
75
|
+
{
|
|
76
|
+
Debug.LogError("后处理阶段 BuildProfile 不合法");
|
|
77
|
+
return BuildMiniGameError.InvalidInput;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Debug.Log("构建成功: " + res);
|
|
81
|
+
return BuildMiniGameError.Succeeded;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public override BuildMiniGameError Build(BuildProfile buildProfile, BuildOptions options)
|
|
85
|
+
{
|
|
86
|
+
SyncBuildOptionsToStark(options);
|
|
87
|
+
return Build(buildProfile);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/// <summary>
|
|
91
|
+
/// 构建参数校验
|
|
92
|
+
/// </summary>
|
|
93
|
+
private static bool IsBuildSettingsValid(DouYinMiniGameSettings settings, PlayerSettings playerSettings)
|
|
94
|
+
{
|
|
95
|
+
if (!settings.needCompress)
|
|
96
|
+
{
|
|
97
|
+
Debug.LogWarning("警告:未启用首包资源压缩,包体可能较大。只能用于开发测试,请勿用于版本上线。");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (settings.profiling)
|
|
101
|
+
{
|
|
102
|
+
Debug.LogWarning("警告:当前已开启「显示性能面板」(Profiling)。只能用于开发测试,请勿用于版本上线。");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (settings.urlCacheList.Length == 0 || (settings.urlCacheList.Length == 1 && string.IsNullOrEmpty(settings.urlCacheList[0])))
|
|
106
|
+
{
|
|
107
|
+
Debug.LogWarning("警告:当前未配置「缓存资源域名」,可能影响游戏启动速度。");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
var scriptingBackend = PlayerSettings.GetScriptingBackend_Internal(playerSettings, NamedBuildTarget.MiniGame);
|
|
111
|
+
if (scriptingBackend != ScriptingImplementation.IL2CPP)
|
|
112
|
+
{
|
|
113
|
+
Debug.LogError($"Scripting Backend {scriptingBackend}(.Net 8) 暂不支持,请选择为 IL2CPP 后重试构建。");
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/// <summary>
|
|
121
|
+
/// 将 BuildProfile 中配置的平台相关参数写回全局配置
|
|
122
|
+
/// </summary>
|
|
123
|
+
private static void SyncBuildSettingsToStark(DouYinMiniGameSettings settings)
|
|
124
|
+
{
|
|
125
|
+
var starkSettings = StarkBuilderSettings.LoadSettings();
|
|
126
|
+
starkSettings.appId = settings.appId;
|
|
127
|
+
starkSettings.wasmMemorySize = settings.wasmMemorySize;
|
|
128
|
+
starkSettings.CDN = settings.CDN;
|
|
129
|
+
starkSettings.preloadFiles = settings.preloadFiles;
|
|
130
|
+
starkSettings.preloadDataListUrl = settings.preloadDataListUrl;
|
|
131
|
+
starkSettings.urlCacheList = settings.urlCacheList;
|
|
132
|
+
starkSettings.dontCacheFileNames = settings.dontCacheFileNames;
|
|
133
|
+
starkSettings.needCompress = settings.needCompress;
|
|
134
|
+
starkSettings.iOSPerformancePlus = settings.iOSPerformancePlus;
|
|
135
|
+
starkSettings.profiling = settings.profiling;
|
|
136
|
+
starkSettings.clearStreamingAssets = settings.clearStreamingAssets;
|
|
137
|
+
starkSettings.orientation = (StarkBuilderSettings.Orientation)settings.orientation;
|
|
138
|
+
starkSettings.isOldBuildFormat = false;
|
|
139
|
+
starkSettings.Save();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/// <summary>
|
|
143
|
+
/// 将 BuildProfile 中配置的 BuildOptions 参数写回全局配置
|
|
144
|
+
/// </summary>
|
|
145
|
+
private static void SyncBuildOptionsToStark(BuildOptions buildOptions)
|
|
146
|
+
{
|
|
147
|
+
var starkSettings = StarkBuilderSettings.LoadSettings();
|
|
148
|
+
starkSettings.buildOptions = buildOptions;
|
|
149
|
+
starkSettings.Save();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
#endif
|