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
package/Editor/ApplyTool.cs
CHANGED
|
@@ -23,6 +23,9 @@ namespace TyphoonUnitySDK
|
|
|
23
23
|
public static Dictionary<AppChannel, IApply> Applies = new Dictionary<AppChannel, IApply>()
|
|
24
24
|
{
|
|
25
25
|
{ AppChannel.ChinaAndroid, new ApplyChinaAndroid() },
|
|
26
|
+
{ AppChannel.Test, new ApplyTest() },
|
|
27
|
+
{ AppChannel.WxMini, new ApplyWxMini() },
|
|
28
|
+
{ AppChannel.DouyinAndroid, new ApplyDouyinAndroid() },
|
|
26
29
|
};
|
|
27
30
|
|
|
28
31
|
|
|
@@ -62,6 +65,9 @@ namespace TyphoonUnitySDK
|
|
|
62
65
|
break;
|
|
63
66
|
}
|
|
64
67
|
|
|
68
|
+
//保存所有配置
|
|
69
|
+
setting.Save();
|
|
70
|
+
WxMiniConfig.Default.Save();
|
|
65
71
|
InvokeOnApplyStart(setting);
|
|
66
72
|
if (!Applies.TryGetValue(setting.Channel, out var match))
|
|
67
73
|
{
|
|
@@ -244,6 +250,12 @@ namespace TyphoonUnitySDK
|
|
|
244
250
|
AppConfigAsset.Instance.Version = setting.VersionString;
|
|
245
251
|
AppConfigAsset.Instance.VersionType = setting.VersionType;
|
|
246
252
|
AppConfigAsset.Instance.PublishTime = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
253
|
+
|
|
254
|
+
//写入抖音小游戏参数
|
|
255
|
+
AppConfigAsset.Instance.DouyinVideoId = DouyinConfig.Default.VideoId;
|
|
256
|
+
AppConfigAsset.Instance.DouyinIntersId = DouyinConfig.Default.IntersId;
|
|
257
|
+
AppConfigAsset.Instance.DouyinBannerId = DouyinConfig.Default.BannerId;
|
|
258
|
+
|
|
247
259
|
EditorUtility.SetDirty(AppConfigAsset.Instance);
|
|
248
260
|
AssetDatabase.SaveAssets();
|
|
249
261
|
}
|
|
@@ -292,8 +304,7 @@ namespace TyphoonUnitySDK
|
|
|
292
304
|
}
|
|
293
305
|
}
|
|
294
306
|
|
|
295
|
-
|
|
296
|
-
//引入模块
|
|
307
|
+
/*引入模块*/
|
|
297
308
|
public static void ImportModule(string module)
|
|
298
309
|
{
|
|
299
310
|
var from = $"{UniEditor.PathRoot}/Sources~/{module}/Assets";
|
|
@@ -301,6 +312,7 @@ namespace TyphoonUnitySDK
|
|
|
301
312
|
}
|
|
302
313
|
|
|
303
314
|
|
|
315
|
+
/*导入unity package*/
|
|
304
316
|
public static void ImportUnityPackage(string package)
|
|
305
317
|
{
|
|
306
318
|
AssetDatabase.ImportPackage(package, false);
|
|
@@ -329,11 +341,14 @@ namespace TyphoonUnitySDK
|
|
|
329
341
|
}
|
|
330
342
|
|
|
331
343
|
|
|
332
|
-
|
|
333
|
-
/// 清理文件夹,保留文件
|
|
334
|
-
/// </summary>
|
|
344
|
+
/*清理文件夹,保留文件*/
|
|
335
345
|
public static void ClearFilesInDirectory(string folder, HashSet<string> keep)
|
|
336
346
|
{
|
|
347
|
+
if (keep == null)
|
|
348
|
+
{
|
|
349
|
+
keep = new HashSet<string>();
|
|
350
|
+
}
|
|
351
|
+
|
|
337
352
|
if (Directory.Exists(folder))
|
|
338
353
|
{
|
|
339
354
|
var files = Directory.GetFiles(folder, "*", SearchOption.AllDirectories);
|
|
@@ -350,6 +365,17 @@ namespace TyphoonUnitySDK
|
|
|
350
365
|
}
|
|
351
366
|
}
|
|
352
367
|
|
|
368
|
+
//可能出现的文件夹
|
|
369
|
+
public static string[] MaybeFolder = new[]
|
|
370
|
+
{
|
|
371
|
+
"Assets/Plugins/Android",
|
|
372
|
+
"Assets/Typhoon_Gen/TyphoonSDK/Runtime",
|
|
373
|
+
"Assets/WX-WASM-SDK-V2",
|
|
374
|
+
"Assets/WebGLTemplates",
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
/*应用ChinaAndroid*/
|
|
353
379
|
public class ApplyChinaAndroid : IApply
|
|
354
380
|
{
|
|
355
381
|
public void Apply(PublishSetting setting)
|
|
@@ -360,8 +386,68 @@ namespace TyphoonUnitySDK
|
|
|
360
386
|
Debug.Log($"读取资源清单...{manifest_path}");
|
|
361
387
|
var manifest = ReadManifest(manifest_path);
|
|
362
388
|
Debug.Log($"清理多余文件...");
|
|
363
|
-
|
|
364
|
-
|
|
389
|
+
foreach (var folder in MaybeFolder)
|
|
390
|
+
{
|
|
391
|
+
ClearFilesInDirectory(folder, manifest);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
AssetDatabase.Refresh();
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
/*应用Test*/
|
|
400
|
+
public class ApplyTest : IApply
|
|
401
|
+
{
|
|
402
|
+
public void Apply(PublishSetting setting)
|
|
403
|
+
{
|
|
404
|
+
Debug.Log($"清理多余文件...");
|
|
405
|
+
foreach (var folder in MaybeFolder)
|
|
406
|
+
{
|
|
407
|
+
ClearFilesInDirectory(folder, default);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
AssetDatabase.Refresh();
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
/*应用WxMini*/
|
|
416
|
+
public class ApplyWxMini : IApply
|
|
417
|
+
{
|
|
418
|
+
public void Apply(PublishSetting setting)
|
|
419
|
+
{
|
|
420
|
+
Debug.Log($"导入... {UniEditor.PackagePath_WxMini}");
|
|
421
|
+
ImportUnityPackage(UniEditor.PackagePath_WxMini);
|
|
422
|
+
var manifest_path = $"{UniEditor.PackagePath_WxMini}.manifest";
|
|
423
|
+
Debug.Log($"读取资源清单...{manifest_path}");
|
|
424
|
+
var manifest = ReadManifest(manifest_path);
|
|
425
|
+
Debug.Log($"清理多余文件...");
|
|
426
|
+
foreach (var folder in MaybeFolder)
|
|
427
|
+
{
|
|
428
|
+
ClearFilesInDirectory(folder, manifest);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
AssetDatabase.Refresh();
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/*抖音android*/
|
|
436
|
+
public class ApplyDouyinAndroid : IApply
|
|
437
|
+
{
|
|
438
|
+
public void Apply(PublishSetting setting)
|
|
439
|
+
{
|
|
440
|
+
Debug.Log($"导入... {UniEditor.PackagePath_Douyin}");
|
|
441
|
+
ImportUnityPackage(UniEditor.PackagePath_Douyin);
|
|
442
|
+
var manifest_path = $"{UniEditor.PackagePath_Douyin}.manifest";
|
|
443
|
+
Debug.Log($"读取资源清单...{manifest_path}");
|
|
444
|
+
var manifest = ReadManifest(manifest_path);
|
|
445
|
+
Debug.Log($"清理多余文件...");
|
|
446
|
+
foreach (var folder in MaybeFolder)
|
|
447
|
+
{
|
|
448
|
+
ClearFilesInDirectory(folder, manifest);
|
|
449
|
+
}
|
|
450
|
+
|
|
365
451
|
AssetDatabase.Refresh();
|
|
366
452
|
}
|
|
367
453
|
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.IO;
|
|
4
|
+
using UnityEditor;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
using UnityEngine.Serialization;
|
|
7
|
+
|
|
8
|
+
namespace TyphoonUnitySDK
|
|
9
|
+
{
|
|
10
|
+
/*抖音小游戏配置GUI绘制*/
|
|
11
|
+
public static class DouyinConfigGUIDrawer
|
|
12
|
+
{
|
|
13
|
+
public static Dictionary<string, Func<DouyinConfig, bool>> OverrideDrawGUIFunc =
|
|
14
|
+
new Dictionary<string, Func<DouyinConfig, bool>>()
|
|
15
|
+
{
|
|
16
|
+
{ "m_Script", DrawProperty_m_Script },
|
|
17
|
+
{ nameof(DouyinConfig.AppId), DrawProperty_AppId },
|
|
18
|
+
{ nameof(DouyinConfig.VideoId), DrawProperty_VideoId },
|
|
19
|
+
{ nameof(DouyinConfig.IntersId), DrawProperty_IntersId },
|
|
20
|
+
{ nameof(DouyinConfig.ApkName), DrawProperty_ApkName },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
private static bool DrawProperty_ApkName(DouyinConfig arg)
|
|
25
|
+
{
|
|
26
|
+
arg.ApkName = EditorGUILayout.TextField("apk文件名", arg.ApkName);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
private static bool DrawProperty_IntersId(DouyinConfig arg)
|
|
32
|
+
{
|
|
33
|
+
arg.IntersId = EditorGUILayout.TextField("插页广告ID", arg.IntersId);
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private static bool DrawProperty_VideoId(DouyinConfig arg)
|
|
38
|
+
{
|
|
39
|
+
arg.VideoId = EditorGUILayout.TextField("视频广告ID", arg.VideoId);
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private static bool DrawProperty_AppId(DouyinConfig arg)
|
|
44
|
+
{
|
|
45
|
+
arg.AppId = EditorGUILayout.TextField("AppId", arg.AppId);
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
private static bool DrawProperty_m_Script(DouyinConfig arg)
|
|
51
|
+
{
|
|
52
|
+
var tmpEnable = GUI.enabled;
|
|
53
|
+
GUI.enabled = true;
|
|
54
|
+
GUILayout.Space(6);
|
|
55
|
+
GUIDrawer.DrawKeynotes("①仅支持Unity版本:2019.4.35,2021.3.14(最优,支持ASTC压缩,可减少Webgl运行消耗)");
|
|
56
|
+
GUIDrawer.DrawKeynotes(" 详细以官方文档地址为准,链接如下:");
|
|
57
|
+
var url = "https://bytedance.feishu.cn/docx/doxcnTTjZHp8J6HzdrSbWu1aK5b";
|
|
58
|
+
GUIDrawer.DrawUrlLink($" {url}", () => Application.OpenURL(url));
|
|
59
|
+
GUIDrawer.DrawKeynotes("②需要接入录屏分享功能");
|
|
60
|
+
GUIDrawer.DrawKeynotes("③使用指定广告图标,链接如下:");
|
|
61
|
+
url = "https://developer.open-douyin.com/docs/resource/zh-CN/mini-game/operation1/advertise/norms";
|
|
62
|
+
GUIDrawer.DrawUrlLink($" {url}", () => Application.OpenURL(url));
|
|
63
|
+
GUILayout.Space(6);
|
|
64
|
+
GUI.enabled = tmpEnable;
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
/*绘制GUI*/
|
|
70
|
+
public static void DrawGUI()
|
|
71
|
+
{
|
|
72
|
+
var config = DouyinConfig.Default;
|
|
73
|
+
GUIDrawer.DrawProperty(config, (property) =>
|
|
74
|
+
{
|
|
75
|
+
if (OverrideDrawGUIFunc.TryGetValue(property, out var match))
|
|
76
|
+
{
|
|
77
|
+
return match.Invoke(config);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return false;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/// <summary>
|
|
86
|
+
/// 抖音小游戏配置
|
|
87
|
+
/// </summary>
|
|
88
|
+
public class DouyinConfig : ScriptableObject
|
|
89
|
+
{
|
|
90
|
+
private static string ConfigPath = "Assets/Typhoon_Gen/TyphoonSDK/Editor/DouyinConfig.asset";
|
|
91
|
+
|
|
92
|
+
private static DouyinConfig _instance = null;
|
|
93
|
+
|
|
94
|
+
public static DouyinConfig Default
|
|
95
|
+
{
|
|
96
|
+
get
|
|
97
|
+
{
|
|
98
|
+
if (_instance == null)
|
|
99
|
+
{
|
|
100
|
+
_instance = AssetDatabase.LoadAssetAtPath<DouyinConfig>(ConfigPath);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (_instance == null)
|
|
104
|
+
{
|
|
105
|
+
_instance = CreateInstance<DouyinConfig>();
|
|
106
|
+
var folder = Path.GetDirectoryName(ConfigPath);
|
|
107
|
+
if (!Directory.Exists(folder))
|
|
108
|
+
{
|
|
109
|
+
Directory.CreateDirectory(folder);
|
|
110
|
+
AssetDatabase.Refresh();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
AssetDatabase.CreateAsset(_instance, ConfigPath);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return _instance;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public string AppId;
|
|
121
|
+
public string IntersId;
|
|
122
|
+
public string VideoId;
|
|
123
|
+
public string BannerId;
|
|
124
|
+
public string ApkName;
|
|
125
|
+
|
|
126
|
+
public void Save()
|
|
127
|
+
{
|
|
128
|
+
EditorUtility.SetDirty(this);
|
|
129
|
+
AssetDatabase.SaveAssets();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
package/Editor/EditorIcons.cs
CHANGED
|
@@ -22,6 +22,10 @@ namespace TyphoonUnitySDK
|
|
|
22
22
|
public static Texture icon_android =>
|
|
23
23
|
__icon_android
|
|
24
24
|
?? AssetDatabase.LoadAssetAtPath<Texture>($"{FolderPath}/icon_android.png");
|
|
25
|
+
private static Texture __icon_arrow_right = null;
|
|
26
|
+
public static Texture icon_arrow_right =>
|
|
27
|
+
__icon_arrow_right
|
|
28
|
+
?? AssetDatabase.LoadAssetAtPath<Texture>($"{FolderPath}/icon_arrow_right.png");
|
|
25
29
|
private static Texture __icon_douyin = null;
|
|
26
30
|
public static Texture icon_douyin =>
|
|
27
31
|
__icon_douyin
|
|
@@ -73,6 +77,10 @@ namespace TyphoonUnitySDK
|
|
|
73
77
|
public static Texture icon_success =>
|
|
74
78
|
__icon_success
|
|
75
79
|
?? AssetDatabase.LoadAssetAtPath<Texture>($"{FolderPath}/icon_success.png");
|
|
80
|
+
private static Texture __icon_variable = null;
|
|
81
|
+
public static Texture icon_variable =>
|
|
82
|
+
__icon_variable
|
|
83
|
+
?? AssetDatabase.LoadAssetAtPath<Texture>($"{FolderPath}/icon_variable.png");
|
|
76
84
|
private static Texture __icon_vivo = null;
|
|
77
85
|
public static Texture icon_vivo =>
|
|
78
86
|
__icon_vivo ?? AssetDatabase.LoadAssetAtPath<Texture>($"{FolderPath}/icon_vivo.png");
|
package/Editor/ExportModule.cs
CHANGED
|
@@ -12,9 +12,7 @@ namespace TyphoonUnitySDK
|
|
|
12
12
|
/// </summary>
|
|
13
13
|
public class ExportModule
|
|
14
14
|
{
|
|
15
|
-
|
|
16
|
-
/// 导出ChinaAndroid模块
|
|
17
|
-
/// </summary>
|
|
15
|
+
/*导出ChinaAndroid模块*/
|
|
18
16
|
[MenuItem("TyphoonSDK/开发者/导出-ChinaAndroid.unitypackage")]
|
|
19
17
|
public static void ExportChinaAndroid()
|
|
20
18
|
{
|
|
@@ -40,6 +38,49 @@ namespace TyphoonUnitySDK
|
|
|
40
38
|
ExportUnityPackage(manifest, UniEditor.PackagePath_ChinaAndroid, out var detail);
|
|
41
39
|
}
|
|
42
40
|
|
|
41
|
+
/*导出ChinaAndroid模块*/
|
|
42
|
+
[MenuItem("TyphoonSDK/开发者/导出-WxMini.unitypackage")]
|
|
43
|
+
public static void ExportWxMini()
|
|
44
|
+
{
|
|
45
|
+
var manifest = new List<string>()
|
|
46
|
+
{
|
|
47
|
+
"Assets/WebGLTemplates",
|
|
48
|
+
"Assets/WX-WASM-SDK-V2",
|
|
49
|
+
"Assets/Typhoon_Gen/TyphoonSDK/Runtime/WxMini",
|
|
50
|
+
};
|
|
51
|
+
if (!MakeSureExport(manifest))
|
|
52
|
+
{
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!CheckMissFiles(manifest))
|
|
57
|
+
{
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
ExportUnityPackage(manifest, UniEditor.PackagePath_WxMini, out var detail);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
[MenuItem("TyphoonSDK/开发者/导出-Douyin.unitypackage")]
|
|
65
|
+
public static void ExportDouyin()
|
|
66
|
+
{
|
|
67
|
+
var manifest = new List<string>()
|
|
68
|
+
{
|
|
69
|
+
"Assets/Plugins/ByteGame",
|
|
70
|
+
"Assets/Typhoon_Gen/TyphoonSDK/Runtime/Douyin",
|
|
71
|
+
};
|
|
72
|
+
if (!MakeSureExport(manifest))
|
|
73
|
+
{
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!CheckMissFiles(manifest))
|
|
78
|
+
{
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
ExportUnityPackage(manifest, UniEditor.PackagePath_Douyin, out var detail);
|
|
83
|
+
}
|
|
43
84
|
|
|
44
85
|
/// <summary>
|
|
45
86
|
/// 导出清单文件到模块
|
|
@@ -271,6 +312,7 @@ namespace TyphoonUnitySDK
|
|
|
271
312
|
{
|
|
272
313
|
sb.AppendLine(element);
|
|
273
314
|
}
|
|
315
|
+
|
|
274
316
|
File.WriteAllText(manifestPath, sb.ToString());
|
|
275
317
|
AssetDatabase.Refresh();
|
|
276
318
|
if (File.Exists(savePath))
|
|
@@ -280,7 +322,6 @@ namespace TyphoonUnitySDK
|
|
|
280
322
|
}
|
|
281
323
|
}
|
|
282
324
|
|
|
283
|
-
|
|
284
325
|
public static string ToUnityPath(string path)
|
|
285
326
|
{
|
|
286
327
|
return UniEditor.FullPathToAssetPath(path);
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using UnityEditor;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
using Object = UnityEngine.Object;
|
|
7
|
+
|
|
8
|
+
namespace TyphoonUnitySDK
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
/// GUI绘制器
|
|
12
|
+
/// </summary>
|
|
13
|
+
public static class GUIDrawer
|
|
14
|
+
{
|
|
15
|
+
private static GUIStyle _styleTooltip = null;
|
|
16
|
+
|
|
17
|
+
private static GUIStyle StyleTooltip
|
|
18
|
+
{
|
|
19
|
+
get
|
|
20
|
+
{
|
|
21
|
+
if (_styleTooltip == null)
|
|
22
|
+
{
|
|
23
|
+
_styleTooltip = new GUIStyle(Styles.rlabel_italic);
|
|
24
|
+
_styleTooltip.normal.textColor = new Color(0.47f, 0.8f, 1f, 1f);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return _styleTooltip;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
private static GUIStyle _linkstyle = null;
|
|
33
|
+
|
|
34
|
+
private static GUIStyle LinkStyle
|
|
35
|
+
{
|
|
36
|
+
get
|
|
37
|
+
{
|
|
38
|
+
if (_linkstyle == null)
|
|
39
|
+
{
|
|
40
|
+
_linkstyle = new GUIStyle(Styles.rlabel_italic);
|
|
41
|
+
_linkstyle.normal.textColor = new Color(0.02f, 0.49f, 0.84f, 1f);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return _linkstyle;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
/// <summary>
|
|
50
|
+
/// 绘制GUI属性
|
|
51
|
+
/// </summary>
|
|
52
|
+
public static void DrawProperty(Object target, Func<string, bool> ignoreFunc)
|
|
53
|
+
{
|
|
54
|
+
var obj = new SerializedObject(target);
|
|
55
|
+
EditorGUI.BeginChangeCheck();
|
|
56
|
+
obj.UpdateIfRequiredOrScript();
|
|
57
|
+
SerializedProperty iterator = obj.GetIterator();
|
|
58
|
+
for (var enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false)
|
|
59
|
+
{
|
|
60
|
+
using (new EditorGUI.DisabledScope("m_Script" == iterator.propertyPath))
|
|
61
|
+
{
|
|
62
|
+
var cover = ignoreFunc.Invoke(iterator.propertyPath);
|
|
63
|
+
if (!cover)
|
|
64
|
+
{
|
|
65
|
+
EditorGUILayout.PropertyField(iterator, true);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
obj.ApplyModifiedProperties();
|
|
71
|
+
EditorGUI.EndChangeCheck();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/// <summary>
|
|
75
|
+
/// 绘制Foldout
|
|
76
|
+
/// </summary>
|
|
77
|
+
public static bool DrawFoldout(string content, bool foldout, params GUILayoutOption[] option)
|
|
78
|
+
{
|
|
79
|
+
var click = GUILayout.Button(
|
|
80
|
+
new GUIContent($"{content}", foldout ? EditorIcons.icon_drop_arrow : EditorIcons.icon_arrow_right),
|
|
81
|
+
Styles.rbutton_left, option);
|
|
82
|
+
if (click)
|
|
83
|
+
{
|
|
84
|
+
return !foldout;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return foldout;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
/// <summary>
|
|
92
|
+
/// 绘制关键提示
|
|
93
|
+
/// </summary>
|
|
94
|
+
public static void DrawKeynotes(string content, params GUILayoutOption[] option)
|
|
95
|
+
{
|
|
96
|
+
StyleTooltip.normal.textColor = EditorGUIUtility.isProSkin
|
|
97
|
+
? new Color(0.47f, 0.8f, 1f, 1f)
|
|
98
|
+
: new Color(0.04f, 0.31f, 0.57f, 1f);
|
|
99
|
+
GUILayout.TextArea(content, StyleTooltip, option);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/// <summary>
|
|
103
|
+
/// 绘制关键提示
|
|
104
|
+
/// </summary>
|
|
105
|
+
public static void DrawUrlLink(string content, Action handler, params GUILayoutOption[] option)
|
|
106
|
+
{
|
|
107
|
+
if (GUILayout.Button(new GUIContent(content, "跳转..."), LinkStyle, option))
|
|
108
|
+
{
|
|
109
|
+
handler?.Invoke();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|