com.typhoon.unitysdk 1.0.48 → 1.0.50

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/CHANGELOG.md CHANGED
@@ -1,7 +1,20 @@
1
1
  # 更新日志
2
+ ## [1.0.50] - 2023-12-10
3
+
4
+ ### 新增
5
+ * 新增历史版本记录
6
+ * 允许切换历史版本
7
+
8
+
9
+ ## [1.0.49] - 2023-12-10
10
+
11
+ ### 其它
12
+ * 更新测试版本3
13
+
14
+
2
15
  ## [1.0.48] - 2023-12-10
3
16
 
4
- ### 其它
17
+ ### 其它
5
18
  * 更新检查测试版本2
6
19
 
7
20
 
@@ -23,7 +23,7 @@ namespace TyphoonUnitySDK
23
23
  }
24
24
  }
25
25
 
26
- public string GetWriteTimeDateString() => WriteTimeStamp > 0 ? WriteTime.Date.ToLongDateString() : "";
26
+ public string GetWriteTimeDateString() => WriteTimeStamp > 0 ? WriteTime.Date.ToShortDateString() : "";
27
27
 
28
28
 
29
29
  public DateTime PublishTime
@@ -36,7 +36,12 @@ namespace TyphoonUnitySDK
36
36
  }
37
37
 
38
38
  public string GetPublishTimeDateString() =>
39
- PublishTimeStamp > 0 ? PublishTime.Date.ToLongDateString() : "";
39
+ PublishTimeStamp > 0 ? PublishTime.Date.ToShortDateString() : "";
40
+
41
+
42
+ public string GetPublishTimeString() =>
43
+ PublishTimeStamp > 0 ? $"{GetPublishTimeDateString()} {PublishTime.ToShortTimeString()}" : "";
44
+
40
45
 
41
46
  public PackageVersionInfo()
42
47
  {
@@ -10,14 +10,53 @@ namespace TyphoonUnitySDK
10
10
  public class HistoryVersionWindow : EditorWindow
11
11
  {
12
12
  private static Color SelectColor =>
13
- EditorGUIUtility.isProSkin ? new Color(0.21f, 0.2f, 0.21f, 1f) : new Color(0.69f, 0.7f, 0.69f, 1f);
13
+ EditorGUIUtility.isProSkin ? new Color(0.03f, 0.39f, 0.7f, 1f) : new Color(0.69f, 0.7f, 0.69f, 1f);
14
14
 
15
15
  private static Color NormalColor =>
16
16
  EditorGUIUtility.isProSkin ? new Color(0.35f, 0.35f, 0.35f, 1f) : new Color(0.87f, 0.87f, 0.87f, 1f);
17
17
 
18
18
 
19
19
  private const float MENU_WIDTH = 268;
20
- private List<PackageVersionInfo> _history = null;
20
+
21
+ private static GUIStyle _styleMenuBtnLabel = null;
22
+
23
+ private static GUIStyle StyleMenuBtnLabel
24
+ {
25
+ get
26
+ {
27
+ if (_styleMenuBtnLabel == null)
28
+ {
29
+ _styleMenuBtnLabel = new GUIStyle("label");
30
+ _styleMenuBtnLabel.padding = new RectOffset(2, 2, 2, 2);
31
+ _styleMenuBtnLabel.margin = new RectOffset(2, 2, 2, 2);
32
+ _styleMenuBtnLabel.border = new RectOffset(2, 2, 2, 2);
33
+ _styleMenuBtnLabel.alignment = TextAnchor.MiddleLeft;
34
+ }
35
+
36
+ return _styleMenuBtnLabel;
37
+ }
38
+ }
39
+
40
+ private static GUIStyle _styleMenuBtn = null;
41
+
42
+ private static GUIStyle StyleMenuBtn
43
+ {
44
+ get
45
+ {
46
+ if (_styleMenuBtn == null)
47
+ {
48
+ _styleMenuBtn = new GUIStyle("button");
49
+ _styleMenuBtn.padding = new RectOffset(2, 2, 2, 2);
50
+ _styleMenuBtn.margin = new RectOffset(2, 2, 2, 2);
51
+ _styleMenuBtn.border = new RectOffset(0, 0, 0, 0);
52
+ _styleMenuBtn.alignment = TextAnchor.MiddleLeft;
53
+ }
54
+
55
+ return _styleMenuBtn;
56
+ }
57
+ }
58
+
59
+ private static List<PackageVersionInfo> _history = null;
21
60
 
22
61
  public List<PackageVersionInfo> History
23
62
  {
@@ -25,7 +64,13 @@ namespace TyphoonUnitySDK
25
64
  {
26
65
  if (_history == null)
27
66
  {
28
- _history = CheckUpdateCacheData.Default.AllVersions ?? new List<PackageVersionInfo>();
67
+ _history = new List<PackageVersionInfo>();
68
+ var all = CheckUpdateCacheData.Default.AllVersions;
69
+ if (all != null)
70
+ {
71
+ _history = new List<PackageVersionInfo>(all);
72
+ }
73
+
29
74
  _history.Sort((a, b) => { return b.PublishTimeStamp.CompareTo(a.PublishTimeStamp); });
30
75
  }
31
76
 
@@ -33,14 +78,34 @@ namespace TyphoonUnitySDK
33
78
  }
34
79
  }
35
80
 
81
+ private PackageVersionInfo _currentVersion = null;
82
+
83
+ private PackageVersionInfo CurrentVersion
84
+ {
85
+ get
86
+ {
87
+ if (_currentVersion == null)
88
+ {
89
+ _currentVersion = UniEditor.LoadCurrentVersionInfo();
90
+ }
91
+
92
+ return _currentVersion;
93
+ }
94
+ }
95
+
96
+
36
97
  private static Vector2 _scroll;
37
98
  private static PackageVersionInfo _select;
99
+ private Vector2 _logScroll;
100
+
101
+ private string _inputSearch;
38
102
 
39
103
  public static void Open()
40
104
  {
105
+ _history = null;
41
106
  var win = GetWindow<HistoryVersionWindow>();
42
- win.titleContent = new GUIContent("历史版本");
43
- win.minSize = new Vector2(600, 400);
107
+ win.titleContent = new GUIContent("所有版本");
108
+ win.minSize = new Vector2(720, 480);
44
109
  win.Show();
45
110
  }
46
111
 
@@ -56,6 +121,19 @@ namespace TyphoonUnitySDK
56
121
  var rectLeft = rect;
57
122
  rectLeft.width = MENU_WIDTH;
58
123
  DrawLeftMenu(rectLeft);
124
+ var rectLine = rectLeft;
125
+ rectLine.x = rectLeft.xMax;
126
+ rectLine.width = 1;
127
+ var center = rectLine.center;
128
+ var draw = rectLine;
129
+ draw.height -= 8;
130
+ draw.center = center;
131
+ EditorGUI.DrawRect(draw, Color.black);
132
+
133
+ var rectRight = rectLine;
134
+ rectRight.x = rectLine.xMax;
135
+ rectRight.width = rect.xMax - rectRight.x;
136
+ DrawRightGUI(rectRight);
59
137
  }
60
138
  }
61
139
 
@@ -65,23 +143,154 @@ namespace TyphoonUnitySDK
65
143
  var center = rect.center;
66
144
  rectView.width -= 8;
67
145
  rectView.height -= 8;
146
+ rectView.center = center;
68
147
  GUILayout.BeginArea(rectView);
148
+ _inputSearch = GUILayout.TextField(_inputSearch);
149
+ var low = string.IsNullOrWhiteSpace(_inputSearch) ? null : _inputSearch.ToLower();
69
150
  _scroll = GUILayout.BeginScrollView(_scroll);
70
151
 
71
152
  foreach (var info in History)
72
153
  {
154
+ var publishTimeString = info.GetPublishTimeDateString();
155
+ var versionString = info.Version;
156
+ if (low != null)
157
+ {
158
+ if (!publishTimeString.ToLower().Contains(low) && !versionString.Contains(low))
159
+ {
160
+ continue;
161
+ }
162
+ }
163
+
73
164
  var isSelect = _select == info;
74
- DrawMenuButton(isSelect, info.Version, info.GetPublishTimeDateString());
165
+ StyleMenuBtnLabel.fontStyle = isSelect ? FontStyle.Bold : FontStyle.Normal;
166
+ if (GUILayout.Button("", StyleMenuBtn, GUILayout.Height(40)))
167
+ {
168
+ _select = info;
169
+ _logScroll = Vector2.zero;
170
+ }
171
+
172
+ var last = GUILayoutUtility.GetLastRect();
173
+ if (isSelect)
174
+ {
175
+ EditorGUI.DrawRect(last, SelectColor * 0.7f);
176
+ }
177
+
178
+ var rectInfo = last;
179
+ center = rectInfo.center;
180
+ rectInfo.width -= 4;
181
+ rectInfo.height -= 4;
182
+ rectInfo.center = center;
183
+ var rectVersion = rectInfo;
184
+ rectVersion.height = 16;
185
+
186
+ GUI.Label(rectVersion, $"v{info.Version}", StyleMenuBtnLabel);
187
+ var rectPublishTime = rectVersion;
188
+ rectPublishTime.y += rectPublishTime.height;
189
+ GUI.Label(rectPublishTime, $"发布时间: {info.GetPublishTimeString()}", StyleMenuBtnLabel);
190
+
191
+ var used = CurrentVersion.Version == info.Version;
192
+ if (used)
193
+ {
194
+ var rectFlag = rectInfo;
195
+ rectFlag.width = 120;
196
+ rectFlag.height = 16;
197
+ rectFlag.center = rectInfo.center;
198
+ rectFlag.x = rectInfo.xMax - rectFlag.width;
199
+ rectFlag.x -= 8;
200
+ GUIDrawer.DrawKeynotesAlignmentRight(rectFlag, "使用中");
201
+ }
75
202
  }
76
203
 
204
+ GUILayout.Space(30);
77
205
  GUILayout.EndScrollView();
78
206
  GUILayout.EndArea();
79
207
  }
80
208
 
81
209
 
210
+ private void DrawRightGUI(Rect rect)
211
+ {
212
+ var view = rect;
213
+ view.height -= 48;
214
+ var center = view.center;
215
+ var draw = view;
216
+ draw.width -= 8;
217
+ draw.height -= 8;
218
+ draw.center = center;
219
+ GUILayout.BeginArea(draw);
220
+ if (_select == null)
221
+ {
222
+ GUILayout.Label("请从左侧选择配置", Styles.rbold_label);
223
+ }
224
+ else
225
+ {
226
+ var title = $"当前选择: v{_select.Version}";
227
+ if (_select.IsMajor)
228
+ {
229
+ title += $" [重大修复版本]";
230
+ }
231
+
232
+ GUILayout.Label(title, Styles.rbold_title, GUILayout.Height(24));
233
+ GUILayout.Label($"发布时间: {_select.GetPublishTimeString()}", Styles.rlabel_italic);
234
+ GUILayout.Space(5);
235
+ GUILayout.Label("版本更新日志:", Styles.rbold_label);
236
+ if (string.IsNullOrWhiteSpace(_select.VersionChangeLog))
237
+ {
238
+ GUILayout.Label("无");
239
+ }
240
+ else
241
+ {
242
+ _logScroll = GUILayout.BeginScrollView(_logScroll, false, false, GUIStyle.none, GUIStyle.none);
243
+ GUILayout.Label(_select.VersionChangeLog);
244
+ GUILayout.EndScrollView();
245
+ }
246
+ }
247
+
248
+ GUILayout.EndArea();
249
+
250
+ if (_select != null)
251
+ {
252
+ //绘制底部信息栏
253
+ var rectBottom = view;
254
+ rectBottom.y = view.yMax;
255
+ rectBottom.height = rect.yMax - rectBottom.y;
256
+ rectBottom.width -= 4;
257
+ var line = rectBottom;
258
+ line.height = 1;
259
+ line.y = rectBottom.y - line.height;
260
+ var colorLine = EditorGUIUtility.isProSkin
261
+ ? new Color(0.14f, 0.14f, 0.14f, 1f)
262
+ : new Color(0.6f, 0.6f, 0.6f, 1f);
263
+ var colorBg = EditorGUIUtility.isProSkin
264
+ ? new Color(0.24f, 0.24f, 0.24f, 1f)
265
+ : new Color(0.8f, 0.8f, 0.8f, 1f);
266
+ EditorGUI.DrawRect(rectBottom, colorBg);
267
+ EditorGUI.DrawRect(line, colorLine);
268
+
269
+ var btnInstallRect = rectBottom;
270
+ btnInstallRect.width = 120;
271
+ btnInstallRect.x = rectBottom.xMax - btnInstallRect.width;
272
+ center = btnInstallRect.center;
273
+ draw = btnInstallRect;
274
+ draw.width -= 8;
275
+ draw.height -= 8;
276
+ draw.center = center;
277
+ var temEnable = GUI.enabled;
278
+ var used = CurrentVersion.Version == _select.Version;
279
+ GUI.enabled = !used;
280
+ var txt = used ? "使用中" : $"安装";
281
+ if (GUI.Button(draw, txt, Styles.rbutton_bold))
282
+ {
283
+ UniEditor.UpdateInstallVersion(_select);
284
+ }
285
+
286
+ GUI.enabled = temEnable;
287
+ }
288
+ }
289
+
290
+
82
291
  private void DrawMenuButton(bool select, string version, string date)
83
292
  {
84
- GUILayout.Button("", Styles.rbutton, GUILayout.Height(32));
293
+ GUILayout.Button("", GUILayout.Height(32));
85
294
  var rect = GUILayoutUtility.GetLastRect();
86
295
  if (select)
87
296
  {
@@ -336,11 +336,11 @@ namespace TyphoonUnitySDK
336
336
  draw.width -= 4;
337
337
  draw.height -= 4;
338
338
  draw.center = center;
339
- if (GUI.Button(draw, "历史版本", Styles.rbutton))
339
+ if (GUI.Button(draw, "所有版本", Styles.rbutton))
340
340
  {
341
341
  if (CheckUpdateCacheData.Default.AllVersions.Count < 0)
342
342
  {
343
- EditorUtility.DisplayDialog("提示", "历史版本读取失败", "是");
343
+ EditorUtility.DisplayDialog("提示", "版本读取失败", "是");
344
344
  }
345
345
  else
346
346
  {
@@ -1115,5 +1115,59 @@ namespace TyphoonUnitySDK
1115
1115
  }
1116
1116
  }
1117
1117
  }
1118
+
1119
+ /// <summary>
1120
+ /// 更新安装版本
1121
+ /// </summary>
1122
+ public static void UpdateInstallVersion(PackageVersionInfo versionInfo)
1123
+ {
1124
+ //判断是否为upm包的模式
1125
+ var root = Path.GetFullPath(PathRoot);
1126
+ var projPath = Path.GetFullPath(Application.dataPath);
1127
+ var current = LoadCurrentVersionInfo();
1128
+ if (current.Version == versionInfo.Version)
1129
+ {
1130
+ EditorUtility.DisplayDialog("提示", "当前已经是目标版本了", "是");
1131
+ return;
1132
+ }
1133
+
1134
+ if (root.Contains(projPath))
1135
+ {
1136
+ EditorUtility.DisplayDialog("提示", "安装失败,只支持unity package manager 模式,本地包请手动进行更新", "是");
1137
+ return;
1138
+ }
1139
+
1140
+ var click = EditorUtility.DisplayDialog("提示",
1141
+ $"更新版本到 v{versionInfo.Version} ?\n发布时间:{versionInfo.GetPublishTimeString()}",
1142
+ "是");
1143
+ if (click)
1144
+ {
1145
+ //修改package.json
1146
+ try
1147
+ {
1148
+ var package = $"Packages/manifest.json";
1149
+ var json = File.ReadAllText(package);
1150
+ var map = json.ToXObject<Dictionary<string, object>>();
1151
+ var dependencies = map["dependencies"].ToString();
1152
+ var depMap = dependencies.ToXObject<Dictionary<string, string>>();
1153
+ foreach (var pair in depMap)
1154
+ {
1155
+ Debug.Log($"{pair.Key},{pair.Value}");
1156
+ }
1157
+
1158
+ //修改版本号
1159
+ depMap["com.typhoon.unitysdk"] = $"{versionInfo.Version}";
1160
+ map["dependencies"] = depMap.ToXJson();
1161
+ var final = map.ToXJson();
1162
+ File.WriteAllText(final, package);
1163
+ Debug.LogError($"更改成功,刷新工程...");
1164
+ AssetDatabase.Refresh();
1165
+ }
1166
+ catch (Exception e)
1167
+ {
1168
+ Debug.LogError($"安装失败:{e}");
1169
+ }
1170
+ }
1171
+ }
1118
1172
  }
1119
1173
  }
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"com.typhoon.unitysdk","displayName":"typhoon unity sdk","version":"1.0.48","description":"","unity":"2018.1","type":"tool","hideInEditor":false,"author":{"name":"Jan Zhang","email":"","url":""},"changelogUrl":"","documentationUrl":"","keywords":["typhoon"],"license":"","licensesUrl":"","customDependencies":[{"PackageName":"com.unity.nuget.newtonsoft-json","Value":"2.0.0"}],"version_log":"## [1.0.48] - 2023-12-10\r\n\r\n### 其它\n* 更新检查测试版本2\r\n\r\n","major_flag":false,"write_time_stamp":1702183396000,"others":{"items":[]},"dependencies":{"com.unity.nuget.newtonsoft-json":"2.0.0"}}
1
+ {"name":"com.typhoon.unitysdk","displayName":"typhoon unity sdk","version":"1.0.50","description":"","unity":"2018.1","type":"tool","hideInEditor":false,"author":{"name":"Jan Zhang","email":"","url":""},"changelogUrl":"","documentationUrl":"","keywords":["typhoon"],"license":"","licensesUrl":"","customDependencies":[{"PackageName":"com.unity.nuget.newtonsoft-json","Value":"2.0.0"}],"version_log":"## [1.0.50] - 2023-12-10\r\n\r\n### 新增\n* 新增历史版本记录\r\n* 允许切换历史版本\r\n\r\n","major_flag":false,"write_time_stamp":1702189549000,"others":{"items":[]},"dependencies":{"com.unity.nuget.newtonsoft-json":"2.0.0"}}