com.typhoon.unitysdk 1.0.19 → 1.0.21
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/ApplyTool.cs +93 -7
- package/Editor/DouyinConfig.cs +132 -0
- package/Editor/DouyinConfig.cs.meta +11 -0
- package/Editor/EditorIcons.cs +8 -0
- package/Editor/ExportModule.cs +45 -4
- package/Editor/GUIDrawer.cs +113 -0
- package/Editor/GUIDrawer.cs.meta +11 -0
- package/Editor/Preferences.cs +3 -0
- package/Editor/PreferencesWindow.cs +84 -88
- package/Editor/PublishProcess.cs +2 -0
- package/Editor/PublishResult.cs +10 -0
- package/Editor/PublishSetting.cs +21 -4
- package/Editor/PublishSettingGUIDrawer.cs +185 -7
- package/Editor/PublishTool.cs +5 -5
- package/Editor/PublishVivoBatSettingInspector.cs +1 -2
- package/Editor/PublishWindow.cs +16 -6
- package/Editor/Texture/black_32x32.png +0 -0
- package/Editor/Texture/black_32x32.png.meta +144 -0
- package/Editor/Texture/icon_arrow_right.png +0 -0
- package/Editor/Texture/icon_arrow_right.png.meta +144 -0
- package/Editor/Texture/icon_variable.png +0 -0
- package/Editor/Texture/icon_variable.png.meta +144 -0
- package/Editor/UniEditor.cs +28 -0
- package/Editor/VariablePreset.cs +160 -0
- package/Editor/VariablePreset.cs.meta +11 -0
- package/Editor/VariablePresetWindow.cs +153 -0
- package/Editor/VariablePresetWindow.cs.meta +11 -0
- package/Editor/WxMiniConfig.cs +285 -0
- package/Editor/WxMiniConfig.cs.meta +11 -0
- package/Runtime/AppConfig.cs +16 -0
- package/Runtime/AppConfigAsset.cs +5 -2
- package/Runtime/TyphoonSdk.cs +31 -0
- package/Runtime/UnityToJs.cs +66 -0
- package/Runtime/UnityToJs.cs.meta +11 -0
- package/Runtime/WxMiniTouchInputSupport.cs +33 -0
- package/Runtime/WxMiniTouchInputSupport.cs.meta +11 -0
- package/Sources~/Package/Douyin.unitypackage +0 -0
- package/Sources~/Package/Douyin.unitypackage.manifest +107 -0
- package/Sources~/Package/WxMini.unitypackage +0 -0
- package/Sources~/Package/WxMini.unitypackage.manifest +395 -0
- package/Sources~/Package//345/270/270/347/224/250/346/211/223/345/214/205/351/205/215/347/275/256.unitypackage +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
using UnityEditor;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace TyphoonUnitySDK
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// 自定义变量窗口
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class VariablePresetWindow : EditorWindow
|
|
10
|
+
{
|
|
11
|
+
private Vector2 _scroll;
|
|
12
|
+
private string _inputTxt;
|
|
13
|
+
private VariablePreset.VariableItem moveUp = null;
|
|
14
|
+
private VariablePreset.VariableItem moveDown = null;
|
|
15
|
+
private VariablePreset.VariableItem delete = null;
|
|
16
|
+
|
|
17
|
+
public static void Open()
|
|
18
|
+
{
|
|
19
|
+
var win = GetWindow<VariablePresetWindow>();
|
|
20
|
+
win.minSize = new Vector2(600, 500);
|
|
21
|
+
win.titleContent = new GUIContent("自定义变量");
|
|
22
|
+
win.Show();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private void OnGUI()
|
|
26
|
+
{
|
|
27
|
+
var rect = new Rect(0, 0, position.width, position.height);
|
|
28
|
+
var rectTitle = rect;
|
|
29
|
+
rectTitle.height = 32;
|
|
30
|
+
rectTitle.width -= 8;
|
|
31
|
+
rectTitle.x += 4;
|
|
32
|
+
rectTitle.y += 4;
|
|
33
|
+
EditorGUI.DrawRect(rectTitle, Skins.PublishWindowTitleBgColor);
|
|
34
|
+
GUI.Label(rectTitle, "自定义变量", Styles.rbold_title);
|
|
35
|
+
var rectSave = rectTitle;
|
|
36
|
+
rectSave.width = 90;
|
|
37
|
+
rectSave.x = rectTitle.xMax - rectSave.width - 4;
|
|
38
|
+
var center = rectSave.center;
|
|
39
|
+
rectSave.height -= 8;
|
|
40
|
+
rectSave.center = center;
|
|
41
|
+
if (GUI.Button(rectSave, new GUIContent("保存配置", EditorIcons.icon_save)))
|
|
42
|
+
{
|
|
43
|
+
VariablePreset.Default.Save();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var toolbarArea = rectTitle;
|
|
47
|
+
toolbarArea.y = rectTitle.yMax;
|
|
48
|
+
toolbarArea.y += 6;
|
|
49
|
+
toolbarArea.height = 22;
|
|
50
|
+
center = toolbarArea.center;
|
|
51
|
+
toolbarArea.width -= 4;
|
|
52
|
+
toolbarArea.center = center;
|
|
53
|
+
GUILayout.BeginArea(toolbarArea);
|
|
54
|
+
GUILayout.BeginHorizontal();
|
|
55
|
+
_inputTxt = GUILayout.TextField(_inputTxt);
|
|
56
|
+
GUI.SetNextControlName("input");
|
|
57
|
+
if (GUILayout.Button("+新建变量", GUILayout.Width(80)))
|
|
58
|
+
{
|
|
59
|
+
if (AddVariable(_inputTxt))
|
|
60
|
+
{
|
|
61
|
+
_inputTxt = string.Empty;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var tipRect = new Rect(0, 0, 180, toolbarArea.height);
|
|
66
|
+
tipRect.y -= 2;
|
|
67
|
+
if (string.IsNullOrEmpty(_inputTxt) && GUI.GetNameOfFocusedControl() != "input")
|
|
68
|
+
{
|
|
69
|
+
GUI.Label(tipRect, "请输入变量名...", Styles.rlabel_italic);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
GUILayout.EndHorizontal();
|
|
73
|
+
GUILayout.EndArea();
|
|
74
|
+
var contentArea = toolbarArea;
|
|
75
|
+
contentArea.y = toolbarArea.yMax + 2;
|
|
76
|
+
contentArea.height = rect.yMax - contentArea.y - 4;
|
|
77
|
+
GUILayout.BeginArea(contentArea);
|
|
78
|
+
var presets = VariablePreset.Default.Presets;
|
|
79
|
+
|
|
80
|
+
foreach (var item in presets)
|
|
81
|
+
{
|
|
82
|
+
GUILayout.BeginHorizontal();
|
|
83
|
+
if (GUILayout.Button(item.VariableName, "Popup", GUILayout.Width(180)))
|
|
84
|
+
{
|
|
85
|
+
var tem = item;
|
|
86
|
+
var menu = new GenericMenu();
|
|
87
|
+
menu.AddItem(new GUIContent("删除"), false, () => delete = tem);
|
|
88
|
+
menu.AddItem(new GUIContent("上移"), false, () => moveUp = tem);
|
|
89
|
+
menu.AddItem(new GUIContent("下移"), false, () => moveDown = tem);
|
|
90
|
+
menu.ShowAsContext();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
item.VariableValue = GUILayout.TextField(item.VariableValue);
|
|
94
|
+
GUILayout.EndHorizontal();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
GUILayout.EndArea();
|
|
98
|
+
if (moveUp != null)
|
|
99
|
+
{
|
|
100
|
+
MoveUp(moveUp);
|
|
101
|
+
moveUp = null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (moveDown != null)
|
|
105
|
+
{
|
|
106
|
+
MoveDown(moveDown);
|
|
107
|
+
moveDown = null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (delete != null)
|
|
111
|
+
{
|
|
112
|
+
DeleteVariable(delete);
|
|
113
|
+
delete = null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Repaint();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private bool AddVariable(string variableName)
|
|
120
|
+
{
|
|
121
|
+
if (string.IsNullOrEmpty(variableName))
|
|
122
|
+
{
|
|
123
|
+
UniEditor.ShowMessageBox($"变量名不可为空", null);
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (VariablePreset.Default.ContainsVariable(variableName))
|
|
128
|
+
{
|
|
129
|
+
UniEditor.ShowMessageBox($"已经存在变量:{variableName}", null);
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
VariablePreset.Default.Presets.Add(new VariablePreset.VariableItem(variableName, ""));
|
|
134
|
+
VariablePreset.Default.Save();
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private void DeleteVariable(VariablePreset.VariableItem item)
|
|
139
|
+
{
|
|
140
|
+
VariablePreset.Default.Delete(item);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private void MoveUp(VariablePreset.VariableItem item)
|
|
144
|
+
{
|
|
145
|
+
VariablePreset.Default.MoveUp(item);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private void MoveDown(VariablePreset.VariableItem item)
|
|
149
|
+
{
|
|
150
|
+
VariablePreset.Default.MoveDown(item);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.IO;
|
|
4
|
+
using UnityEditor;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace TyphoonUnitySDK
|
|
8
|
+
{
|
|
9
|
+
/*微信小游戏配置GUI绘制*/
|
|
10
|
+
public static class WxMiniConfigGUIDrawer
|
|
11
|
+
{
|
|
12
|
+
//微信小游戏进阶设置
|
|
13
|
+
private static bool _wxMiniConfigAdvanceFoldout = false;
|
|
14
|
+
|
|
15
|
+
public static Dictionary<string, Func<WxMiniConfig, bool>> OverrideDrawGUIWxMiniConfig =
|
|
16
|
+
new Dictionary<string, Func<WxMiniConfig, bool>>()
|
|
17
|
+
{
|
|
18
|
+
{ "m_Script", DrawProperty_m_Script },
|
|
19
|
+
{ nameof(WxMiniConfig.AppId), DrawProperty_AppId },
|
|
20
|
+
{ nameof(WxMiniConfig.ProjectName), DrawProperty_ProjectName },
|
|
21
|
+
{ nameof(WxMiniConfig.ScreenOrientation), DrawProperty_ScreenOrientation },
|
|
22
|
+
{ nameof(WxMiniConfig.MemorySize), DrawProperty_MemorySize },
|
|
23
|
+
{ nameof(WxMiniConfig.DST), DrawProperty_DST },
|
|
24
|
+
{ nameof(WxMiniConfig.AssetLoadType), DrawProperty_AssetLoadType },
|
|
25
|
+
{ nameof(WxMiniConfig.LoadingBg), DrawProperty_LoadingBg },
|
|
26
|
+
{ nameof(WxMiniConfig.CDN), DrawProperty_CDN },
|
|
27
|
+
/*进阶选项*/
|
|
28
|
+
{ nameof(WxMiniConfig.UseFriendRelation), DrawProperty_Advance },
|
|
29
|
+
{ nameof(WxMiniConfig.UseCompressedTexture), DrawProperty_Advance },
|
|
30
|
+
{ nameof(WxMiniConfig.UseMiniGameChat), DrawProperty_Advance },
|
|
31
|
+
{ nameof(WxMiniConfig.PreloadWXFont), DrawProperty_Advance },
|
|
32
|
+
{ nameof(WxMiniConfig.DevelopBuild), DrawProperty_Advance },
|
|
33
|
+
{ nameof(WxMiniConfig.AutoProfile), DrawProperty_Advance },
|
|
34
|
+
{ nameof(WxMiniConfig.ScriptOnly), DrawProperty_Advance },
|
|
35
|
+
{ nameof(WxMiniConfig.Il2CppOptimizeSize), DrawProperty_Advance },
|
|
36
|
+
{ nameof(WxMiniConfig.ProfilingFuncs), DrawProperty_Advance },
|
|
37
|
+
{ nameof(WxMiniConfig.Webgl2), DrawProperty_Advance },
|
|
38
|
+
{ nameof(WxMiniConfig.ClearStreamingAssets), DrawProperty_Advance },
|
|
39
|
+
{ nameof(WxMiniConfig.ProfilingMemory), DrawProperty_Advance },
|
|
40
|
+
{ nameof(WxMiniConfig.CleanBuild), DrawProperty_Advance },
|
|
41
|
+
{ nameof(WxMiniConfig.CustomNodePath), DrawProperty_Advance },
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
private static bool DrawProperty_m_Script(WxMiniConfig arg)
|
|
46
|
+
{
|
|
47
|
+
var tmpEnable = GUI.enabled;
|
|
48
|
+
GUI.enabled = true;
|
|
49
|
+
GUILayout.Space(6);
|
|
50
|
+
GUIDrawer.DrawKeynotes("①推荐Unity版本:2019,2020,2021");
|
|
51
|
+
GUIDrawer.DrawKeynotes("②为EventSystem加上WxMiniTouchInputSupport组件,用于支持多点触控");
|
|
52
|
+
GUILayout.Space(6);
|
|
53
|
+
GUI.enabled = tmpEnable;
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private static bool DrawProperty_Advance(WxMiniConfig arg)
|
|
58
|
+
{
|
|
59
|
+
if (_wxMiniConfigAdvanceFoldout)
|
|
60
|
+
{
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private static bool DrawProperty_CDN(WxMiniConfig arg)
|
|
68
|
+
{
|
|
69
|
+
GUILayout.BeginHorizontal();
|
|
70
|
+
arg.CDN = EditorGUILayout.TextField("CDN地址 (后台配白名单)", arg.CDN);
|
|
71
|
+
GUILayout.EndHorizontal();
|
|
72
|
+
GUILayout.TextArea($"支持与自定义变量组合,[变量名]作为占位符\n最终地址:{VariablePreset.Default.ParserToString(arg.CDN)}",
|
|
73
|
+
"helpBox",
|
|
74
|
+
GUILayout.Height(44));
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private static bool DrawProperty_LoadingBg(WxMiniConfig arg)
|
|
79
|
+
{
|
|
80
|
+
GUILayout.BeginHorizontal();
|
|
81
|
+
arg.LoadingBg =
|
|
82
|
+
EditorGUILayout.ObjectField("Loading图(默认使用纯黑)", arg.LoadingBg, typeof(Texture), false) as Texture;
|
|
83
|
+
GUILayout.EndHorizontal();
|
|
84
|
+
GUILayout.Space(5);
|
|
85
|
+
_wxMiniConfigAdvanceFoldout = EditorGUILayout.Foldout(_wxMiniConfigAdvanceFoldout, "进阶选项");
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private static bool DrawProperty_DST(WxMiniConfig arg)
|
|
90
|
+
{
|
|
91
|
+
GUILayout.BeginHorizontal();
|
|
92
|
+
GUILayout.Label("发布目录", GUILayout.Width(146));
|
|
93
|
+
arg.DST = GUILayout.TextField(arg.DST);
|
|
94
|
+
if (GUILayout.Button("打开", GUILayout.Width(50)))
|
|
95
|
+
{
|
|
96
|
+
if (Directory.Exists(arg.DST))
|
|
97
|
+
{
|
|
98
|
+
EditorUtility.RevealInFinder(arg.DST);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (GUILayout.Button("浏览", GUILayout.Width(50)))
|
|
103
|
+
{
|
|
104
|
+
var path = EditorUtility.OpenFolderPanel("请选择", "", "typhoon_wx_game");
|
|
105
|
+
if (!string.IsNullOrEmpty(path))
|
|
106
|
+
{
|
|
107
|
+
arg.DST = UniEditor.FullPathToAssetPath(path);
|
|
108
|
+
GUI.FocusControl("");
|
|
109
|
+
arg.Save();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
GUILayout.EndHorizontal();
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private static bool DrawProperty_MemorySize(WxMiniConfig arg)
|
|
118
|
+
{
|
|
119
|
+
GUILayout.BeginHorizontal();
|
|
120
|
+
GUILayout.Label("分配内存(MB)", GUILayout.Width(146));
|
|
121
|
+
arg.MemorySize = EditorGUILayout.IntSlider(arg.MemorySize, 256, 2048);
|
|
122
|
+
GUILayout.EndHorizontal();
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private static bool DrawProperty_ScreenOrientation(WxMiniConfig arg)
|
|
127
|
+
{
|
|
128
|
+
GUILayout.BeginHorizontal();
|
|
129
|
+
GUILayout.Label("屏幕朝向", GUILayout.Width(146));
|
|
130
|
+
if (GUILayout.Button(arg.ScreenOrientation == WxMiniConfig.Orientation.Portrait ? "竖屏" : "横屏", "PopUp"))
|
|
131
|
+
{
|
|
132
|
+
var menu = new GenericMenu();
|
|
133
|
+
menu.AddItem(new GUIContent("竖屏"), false, () =>
|
|
134
|
+
{
|
|
135
|
+
arg.ScreenOrientation = WxMiniConfig.Orientation.Portrait;
|
|
136
|
+
arg.Save();
|
|
137
|
+
});
|
|
138
|
+
menu.AddItem(new GUIContent("横屏"), false, () =>
|
|
139
|
+
{
|
|
140
|
+
arg.ScreenOrientation = WxMiniConfig.Orientation.Landscape;
|
|
141
|
+
arg.Save();
|
|
142
|
+
});
|
|
143
|
+
menu.ShowAsContext();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
GUILayout.EndHorizontal();
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
private static bool DrawProperty_ProjectName(WxMiniConfig arg)
|
|
151
|
+
{
|
|
152
|
+
arg.ProjectName = EditorGUILayout.TextField("游戏名(找运营要)", arg.ProjectName);
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private static bool DrawProperty_AppId(WxMiniConfig arg)
|
|
157
|
+
{
|
|
158
|
+
GUILayout.Space(5);
|
|
159
|
+
arg.AppId = EditorGUILayout.TextField("AppId(找运营要)", arg.AppId);
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
public static void DrawWxMiniConfig()
|
|
164
|
+
{
|
|
165
|
+
var config = WxMiniConfig.Default;
|
|
166
|
+
GUIDrawer.DrawProperty(config, (property) =>
|
|
167
|
+
{
|
|
168
|
+
if (OverrideDrawGUIWxMiniConfig.TryGetValue(property, out var match))
|
|
169
|
+
{
|
|
170
|
+
return match.Invoke(config);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return false;
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private static bool DrawProperty_AssetLoadType(WxMiniConfig arg)
|
|
178
|
+
{
|
|
179
|
+
GUILayout.BeginHorizontal();
|
|
180
|
+
GUILayout.Label("首包加载模式", GUILayout.Width(146));
|
|
181
|
+
if (GUILayout.Button(arg.AssetLoadType == 0 ? "CDN" : "游戏内", "PopUp"))
|
|
182
|
+
{
|
|
183
|
+
var menu = new GenericMenu();
|
|
184
|
+
menu.AddItem(new GUIContent("CDN"), false, () =>
|
|
185
|
+
{
|
|
186
|
+
arg.AssetLoadType = 0;
|
|
187
|
+
arg.Save();
|
|
188
|
+
});
|
|
189
|
+
menu.AddItem(new GUIContent("游戏内"), false, () =>
|
|
190
|
+
{
|
|
191
|
+
arg.AssetLoadType = 1;
|
|
192
|
+
arg.Save();
|
|
193
|
+
});
|
|
194
|
+
menu.ShowAsContext();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
GUILayout.EndHorizontal();
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/// <summary>
|
|
203
|
+
/// 微信小游戏配置
|
|
204
|
+
/// </summary>
|
|
205
|
+
public class WxMiniConfig : ScriptableObject
|
|
206
|
+
{
|
|
207
|
+
private static string ConfigPath = "Assets/Typhoon_Gen/TyphoonSDK/Editor/WxMiniConfig.asset";
|
|
208
|
+
|
|
209
|
+
private static WxMiniConfig _instance = null;
|
|
210
|
+
|
|
211
|
+
public static WxMiniConfig Default
|
|
212
|
+
{
|
|
213
|
+
get
|
|
214
|
+
{
|
|
215
|
+
if (_instance == null)
|
|
216
|
+
{
|
|
217
|
+
_instance = AssetDatabase.LoadAssetAtPath<WxMiniConfig>(ConfigPath);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (_instance == null)
|
|
221
|
+
{
|
|
222
|
+
_instance = CreateInstance<WxMiniConfig>();
|
|
223
|
+
var folder = Path.GetDirectoryName(ConfigPath);
|
|
224
|
+
if (!Directory.Exists(folder))
|
|
225
|
+
{
|
|
226
|
+
Directory.CreateDirectory(folder);
|
|
227
|
+
AssetDatabase.Refresh();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
AssetDatabase.CreateAsset(_instance, ConfigPath);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return _instance;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
/// <summary>
|
|
239
|
+
/// 朝向
|
|
240
|
+
/// </summary>
|
|
241
|
+
public enum Orientation
|
|
242
|
+
{
|
|
243
|
+
//横屏
|
|
244
|
+
Portrait,
|
|
245
|
+
|
|
246
|
+
//竖屏
|
|
247
|
+
Landscape,
|
|
248
|
+
|
|
249
|
+
LandscapeLeft,
|
|
250
|
+
LandscapeRight,
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
[Header("基础设置")] public string AppId = "";
|
|
254
|
+
public string ProjectName = "";
|
|
255
|
+
public string CDN = "https://xxx.xxx.xxx";
|
|
256
|
+
public Orientation ScreenOrientation = Orientation.Portrait;
|
|
257
|
+
public int MemorySize = 256;
|
|
258
|
+
public string DST = "typhoon_wx_game";
|
|
259
|
+
|
|
260
|
+
[Header("启动Loading配置")] public int AssetLoadType = 0; //首包加载方式,0:CDN,1:游戏内
|
|
261
|
+
public Texture LoadingBg;
|
|
262
|
+
|
|
263
|
+
[Header("SDK 功能选项")] public bool UseFriendRelation = false;
|
|
264
|
+
public bool UseCompressedTexture = false;
|
|
265
|
+
public bool UseMiniGameChat = false;
|
|
266
|
+
public bool PreloadWXFont = false;
|
|
267
|
+
|
|
268
|
+
[Header("调试编译选项")] public bool DevelopBuild = false;
|
|
269
|
+
public bool AutoProfile = false;
|
|
270
|
+
public bool ScriptOnly = false;
|
|
271
|
+
public bool Il2CppOptimizeSize = true;
|
|
272
|
+
public bool ProfilingFuncs = false;
|
|
273
|
+
public bool Webgl2 = false;
|
|
274
|
+
public bool ClearStreamingAssets = true;
|
|
275
|
+
public bool ProfilingMemory = false;
|
|
276
|
+
public bool CleanBuild = false;
|
|
277
|
+
public string CustomNodePath = string.Empty;
|
|
278
|
+
|
|
279
|
+
public void Save()
|
|
280
|
+
{
|
|
281
|
+
EditorUtility.SetDirty(this);
|
|
282
|
+
AssetDatabase.SaveAssets();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
package/Runtime/AppConfig.cs
CHANGED
|
@@ -24,5 +24,21 @@ namespace TyphoonUnitySDK
|
|
|
24
24
|
/// 发布时间
|
|
25
25
|
/// </summary>
|
|
26
26
|
public static string PublishTime => AppConfigAsset.Instance.PublishTime;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
/// [抖音小游戏]视频广告ID
|
|
31
|
+
/// </summary>
|
|
32
|
+
public static string DouyinVideoId = AppConfigAsset.Instance.DouyinVideoId;
|
|
33
|
+
|
|
34
|
+
/// <summary>
|
|
35
|
+
/// [抖音小游戏]插页广告ID
|
|
36
|
+
/// </summary>
|
|
37
|
+
public static string DouyinIntersId => AppConfigAsset.Instance.DouyinIntersId;
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
/// [抖音小游戏]BannerID
|
|
41
|
+
/// </summary>
|
|
42
|
+
public static string DouyinBannerId => AppConfigAsset.Instance.DouyinBannerId;
|
|
27
43
|
}
|
|
28
44
|
}
|
|
@@ -44,7 +44,10 @@ namespace TyphoonUnitySDK
|
|
|
44
44
|
|
|
45
45
|
[Tooltip("版本类型")] public VersionType VersionType = VersionType.Release;
|
|
46
46
|
|
|
47
|
-
[
|
|
48
|
-
|
|
47
|
+
[Tooltip("发布时间")] public string PublishTime = "19700101000000";
|
|
48
|
+
|
|
49
|
+
[Tooltip("[抖音小游戏]视频广告ID")] public string DouyinVideoId;
|
|
50
|
+
[Tooltip("[抖音小游戏]插页广告ID")] public string DouyinIntersId;
|
|
51
|
+
[Tooltip("[抖音小游戏]Banner广告ID")] public string DouyinBannerId;
|
|
49
52
|
}
|
|
50
53
|
}
|
package/Runtime/TyphoonSdk.cs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
using System;
|
|
2
|
+
using System.Collections;
|
|
2
3
|
using System.Collections.Generic;
|
|
3
4
|
using UnityEngine;
|
|
4
5
|
|
|
@@ -9,10 +10,14 @@ namespace TyphoonUnitySDK
|
|
|
9
10
|
/// </summary>
|
|
10
11
|
public partial class TyphoonSdk : MonoSingleton<TyphoonSdk>
|
|
11
12
|
{
|
|
13
|
+
/*绑定SDK实例*/
|
|
12
14
|
public static Dictionary<AppChannel, string> SDKBindings = new Dictionary<AppChannel, string>
|
|
13
15
|
{
|
|
14
16
|
{ AppChannel.Test, "TYPHOON_SDK_TEST" }, //测试渠道
|
|
15
17
|
{ AppChannel.ChinaAndroid, "TYPHOON_SDK_CHINA_ANDROID" }, //国内安卓
|
|
18
|
+
{ AppChannel.WxMini, "TYPHOON_SDK_WX_MINI" }, //微信小游戏
|
|
19
|
+
{ AppChannel.DouyinAndroid, "TYPHOON_SDK_DOUYIN_MINI" }, //抖音小游戏
|
|
20
|
+
{ AppChannel.DouyinIOS, "TYPHOON_SDK_DOUYIN_MINI" }, //抖音小游戏
|
|
16
21
|
};
|
|
17
22
|
|
|
18
23
|
private ISdk _sdk;
|
|
@@ -381,5 +386,31 @@ namespace TyphoonUnitySDK
|
|
|
381
386
|
}
|
|
382
387
|
|
|
383
388
|
#endregion
|
|
389
|
+
|
|
390
|
+
#region 协程
|
|
391
|
+
|
|
392
|
+
/// <summary>
|
|
393
|
+
/// 使用协程延迟处理逻辑
|
|
394
|
+
/// </summary>
|
|
395
|
+
public Coroutine WaitTo(float delay, Action handler)
|
|
396
|
+
{
|
|
397
|
+
return StartCoroutine(IeWaitTo(delay, handler));
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
private IEnumerator IeWaitTo(float delay, Action handler)
|
|
401
|
+
{
|
|
402
|
+
yield return new WaitForSeconds(delay);
|
|
403
|
+
handler?.Invoke();
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/// <summary>
|
|
407
|
+
/// 中断协程
|
|
408
|
+
/// </summary>
|
|
409
|
+
public void KillWaitTo(Coroutine coroutine)
|
|
410
|
+
{
|
|
411
|
+
StopCoroutine(coroutine);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
#endregion
|
|
384
415
|
}
|
|
385
416
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Runtime.InteropServices;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
namespace TyphoonUnitySDK
|
|
8
|
+
{
|
|
9
|
+
#if UNITY_WEBGL
|
|
10
|
+
/// <summary>
|
|
11
|
+
/// unity 调用 js
|
|
12
|
+
/// </summary>
|
|
13
|
+
public class UnityToJs
|
|
14
|
+
{
|
|
15
|
+
[DllImport("__Internal")]
|
|
16
|
+
private static extern void WebMethodCall(string msg);
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
[DllImport("__Internal")]
|
|
20
|
+
private static extern string WebMethodGet(string msg);
|
|
21
|
+
|
|
22
|
+
public static void MethodCall(string msg)
|
|
23
|
+
{
|
|
24
|
+
#if UNITY_EDITOR
|
|
25
|
+
Debug.Log($"## unity call js {msg}");
|
|
26
|
+
#else
|
|
27
|
+
WebMethodCall(msg);
|
|
28
|
+
#endif
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
public static string MethodGet(string msg)
|
|
33
|
+
{
|
|
34
|
+
#if UNITY_EDITOR
|
|
35
|
+
Debug.Log($"## unity get js {msg}");
|
|
36
|
+
return msg;
|
|
37
|
+
#else
|
|
38
|
+
return WebMethodGet(msg);
|
|
39
|
+
#endif
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/*无回调的方式*/
|
|
43
|
+
public static void MethodCall(string method, object data)
|
|
44
|
+
{
|
|
45
|
+
var send = new
|
|
46
|
+
{
|
|
47
|
+
method,
|
|
48
|
+
data,
|
|
49
|
+
};
|
|
50
|
+
MethodCall(send.ToJson());
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/*带回调的方式*/
|
|
54
|
+
public static void MethodCall(SessionItem session)
|
|
55
|
+
{
|
|
56
|
+
var send = new
|
|
57
|
+
{
|
|
58
|
+
session = session.SessionId,
|
|
59
|
+
method = session.MethodName,
|
|
60
|
+
data = session.SendData,
|
|
61
|
+
};
|
|
62
|
+
MethodCall(send.ToJson());
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
#endif
|
|
66
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using UnityEngine.EventSystems;
|
|
3
|
+
|
|
4
|
+
namespace TyphoonUnitySDK
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// 微信小游戏多点触控支持
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class WxMiniTouchInputSupport : MonoBehaviour
|
|
10
|
+
{
|
|
11
|
+
private void Awake()
|
|
12
|
+
{
|
|
13
|
+
if (AppConfig.Channel == AppChannel.WxMini)
|
|
14
|
+
{
|
|
15
|
+
//加载多点触控
|
|
16
|
+
var source = Resources.Load<GameObject>("WX_TOUCH_INPUT_OVERRIDE");
|
|
17
|
+
//获取
|
|
18
|
+
var com = source.GetComponents<BaseInput>();
|
|
19
|
+
foreach (var element in com)
|
|
20
|
+
{
|
|
21
|
+
var type = element.GetType();
|
|
22
|
+
if (type.Name.Contains("WXTouchInputOverride"))
|
|
23
|
+
{
|
|
24
|
+
Debug.Log("补充WXTouchInputOverride组件");
|
|
25
|
+
//补充WXTouchInputOverride组件
|
|
26
|
+
gameObject.AddComponent(type);
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
Binary file
|