Skip to content

Commit f53d970

Browse files
committed
修改AB包编辑器工具
修改AB包编辑器工具,加入打包压缩、加密和版本号比对
1 parent 1d94243 commit f53d970

File tree

14 files changed

+430
-25
lines changed

14 files changed

+430
-25
lines changed

Assets/Game/Prefab/GameMode.prefab.meta

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/GameFramework/Config.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright>
3+
// Copyright (c) 2018 Hu Tao. All rights reserved.
4+
// </copyright>
5+
// <describe> #版本信息# </describe>
6+
// <email> [email protected] </email>
7+
// <time> #2018年6月28日 11点16分# </time>
8+
//-----------------------------------------------------------------------
9+
10+
using System;
11+
using System.Collections.Generic;
12+
13+
[Serializable]
14+
public class AssetBundleVersionInfo
15+
{
16+
public int Version;
17+
public bool IsEncrypt;
18+
public List<ResourcesInfo> Resources;
19+
}
20+
21+
[Serializable]
22+
public class ResourcesInfo
23+
{
24+
public string Name;
25+
public string Hash;
26+
}

Assets/GameFramework/Config/AssetBundleVersionInfo.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright>
3+
// Copyright (c) 2018 Hu Tao. All rights reserved.
4+
// </copyright>
5+
// <describe> #加密器密钥序列化对象# </describe>
6+
// <email> [email protected] </email>
7+
// <time> #2018年6月28日 14点53分# </time>
8+
//-----------------------------------------------------------------------
9+
10+
11+
using UnityEngine;
12+
13+
public class EnciphererKey : ScriptableObject {
14+
15+
public string Key = "";
16+
public byte[] KeyVector;
17+
18+
public void GeneraterKey()
19+
{
20+
string tem = "0123456789abcdefghijklmnopqrstuvwxyz";
21+
for (int i = 0; i < 32; i++)
22+
{
23+
int index = Random.Range(0, tem.Length);
24+
Key += tem[index];
25+
}
26+
KeyVector = new byte[0];
27+
}
28+
}

Assets/GameFramework/Config/EnciphererKey.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/GameFramework/Editor/AssetBundleEditor/AssetBundleEditor.cs

Lines changed: 107 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ private static void OpenAssetBundleWindow()
5151

5252
private string _buildPath = "";
5353
private BuildTarget _buildTarget = BuildTarget.StandaloneWindows;
54+
private ZipMode _zipMode = ZipMode.LZMA;
55+
private EncryptMode _encryptMode = EncryptMode.AES;
56+
private int _assetVersion = 1;
57+
58+
private bool _showSetting = false;
5459

5560
private GUIStyle _box = new GUIStyle("Box");
5661
private GUIStyle _preButton = new GUIStyle("PreButton");
@@ -60,6 +65,7 @@ private static void OpenAssetBundleWindow()
6065
private GUIStyle _miniButtonLeft = new GUIStyle("MiniButtonLeft");
6166
private GUIStyle _miniButtonRight = new GUIStyle("MiniButtonRight");
6267
private GUIStyle _oLMinus = new GUIStyle("OL Minus");
68+
private GUIStyle _flownode0on = new GUIStyle("flow node 0 on");
6369
#endregion
6470

6571
private void Init()
@@ -71,8 +77,11 @@ private void Init()
7177
_assetBundle = new AssetBundleInfo();
7278
AssetBundleTool.ReadAssetBundleConfig(_assetBundle, _validAssets);
7379

74-
_buildPath = EditorPrefs.GetString(Application.productName+"_BuildPath", "");
75-
_buildTarget = (BuildTarget)EditorPrefs.GetInt(Application.productName+"_BuildTarget", 5);
80+
_buildPath = EditorPrefs.GetString(Application.productName + "_BuildPath", "");
81+
_buildTarget = (BuildTarget)EditorPrefs.GetInt(Application.productName + "_BuildTarget", 5);
82+
_zipMode = (ZipMode)EditorPrefs.GetInt(Application.productName + "_ZipMode", 0);
83+
_encryptMode = (EncryptMode)EditorPrefs.GetInt(Application.productName + "_EncryptMode", 1);
84+
_assetVersion = EditorPrefs.GetInt(Application.productName + "_AssetVersion", 1);
7685

7786
Resources.UnloadUnusedAssets();
7887
}
@@ -91,6 +100,7 @@ private void OnGUI()
91100
AssetBundlesGUI();
92101
CurrentAssetBundlesGUI();
93102
AssetsGUI();
103+
SettingGUI();
94104
}
95105
private void TitleGUI()
96106
{
@@ -129,10 +139,7 @@ private void TitleGUI()
129139
}
130140
}
131141
GUI.enabled = true;
132-
133-
_hideInvalidAsset = GUI.Toggle(new Rect(360, 5, 100, 15), _hideInvalidAsset, "Hide Invalid");
134-
_hideBundleAsset = GUI.Toggle(new Rect(460, 5, 100, 15), _hideBundleAsset, "Hide Bundled");
135-
142+
136143
if (GUI.Button(new Rect(250, 25, 60, 15), "Open", _preButton))
137144
{
138145
AssetBundleTool.OpenFolder(_buildPath);
@@ -143,19 +150,26 @@ private void TitleGUI()
143150
if (path.Length != 0)
144151
{
145152
_buildPath = path;
146-
EditorPrefs.SetString(Application.productName+"_BuildPath", _buildPath);
153+
EditorPrefs.SetString(Application.productName + "_BuildPath", _buildPath);
147154
}
148155
}
149156

150157
GUI.Label(new Rect(370, 25, 70, 15), "Build Path:");
151158
_buildPath = GUI.TextField(new Rect(440, 25, 300, 15), _buildPath);
152159

153-
BuildTarget buildTarget = (BuildTarget)EditorGUI.EnumPopup(new Rect((int)position.width - 205, 5, 150, 15), _buildTarget, _preDropDown);
154-
if (buildTarget != _buildTarget)
160+
if (GUI.Button(new Rect(250, 45, 100, 15), "Expand All", _preButton))
155161
{
156-
_buildTarget = buildTarget;
157-
EditorPrefs.SetInt(Application.productName+"_BuildTarget", (int)_buildTarget);
162+
AssetBundleTool.ExpandFolder(_asset, true);
158163
}
164+
if (GUI.Button(new Rect(350, 45, 100, 15), "Shrink All", _preButton))
165+
{
166+
AssetBundleTool.ExpandFolder(_asset, false);
167+
}
168+
169+
_hideInvalidAsset = GUI.Toggle(new Rect(460, 45, 100, 15), _hideInvalidAsset, "Hide Invalid");
170+
_hideBundleAsset = GUI.Toggle(new Rect(560, 45, 100, 15), _hideBundleAsset, "Hide Bundled");
171+
172+
_showSetting = GUI.Toggle(new Rect((int)position.width - 135, 5, 80, 15), _showSetting, "Setting", _preButton);
159173

160174
if (GUI.Button(new Rect((int)position.width - 55, 5, 50, 15), "Build", _preButton))
161175
{
@@ -279,8 +293,8 @@ private void CurrentAssetBundlesGUI()
279293
}
280294
private void AssetsGUI()
281295
{
282-
_assetViewRect = new Rect(250, 45, (int)position.width - 255, (int)position.height - 50);
283-
_assetScrollRect = new Rect(250, 45, (int)position.width - 255, _assetViewHeight);
296+
_assetViewRect = new Rect(250, 65, (int)position.width - 255, (int)position.height - 70);
297+
_assetScrollRect = new Rect(250, 65, (int)position.width - 255, _assetViewHeight);
284298
_assetScroll = GUI.BeginScrollView(_assetViewRect, _assetScroll, _assetScrollRect);
285299
GUI.BeginGroup(_assetScrollRect, _box);
286300

@@ -351,7 +365,52 @@ private void AssetGUI(AssetInfo asset, int indentation)
351365
AssetGUI(asset.ChildAssetInfo[i], indentation + 1);
352366
}
353367
}
354-
}
368+
}
369+
private void SettingGUI()
370+
{
371+
if (_showSetting)
372+
{
373+
GUI.BeginGroup(new Rect((int)position.width / 2 - 125, (int)position.height / 2 - 65, 250, 130), "", _flownode0on);
374+
375+
GUI.Label(new Rect(5, 5, 80, 20), "Build Target: ");
376+
BuildTarget buildTarget = (BuildTarget)EditorGUI.EnumPopup(new Rect(90, 5, 155, 20), _buildTarget, _preDropDown);
377+
if (buildTarget != _buildTarget)
378+
{
379+
_buildTarget = buildTarget;
380+
EditorPrefs.SetInt(Application.productName + "_BuildTarget", (int)_buildTarget);
381+
}
382+
383+
GUI.Label(new Rect(5, 30, 80, 20), "Zip Mode: ");
384+
ZipMode zipMode = (ZipMode)EditorGUI.EnumPopup(new Rect(90, 30, 155, 20), _zipMode, _preDropDown);
385+
if (zipMode != _zipMode)
386+
{
387+
_zipMode = zipMode;
388+
EditorPrefs.SetInt(Application.productName + "_ZipMode", (int)_zipMode);
389+
}
390+
391+
GUI.Label(new Rect(5, 55, 80, 20), "Encrypt: ");
392+
EncryptMode encryptMode = (EncryptMode)EditorGUI.EnumPopup(new Rect(90, 55, 155, 20), _encryptMode, _preDropDown);
393+
if (encryptMode != _encryptMode)
394+
{
395+
_encryptMode = encryptMode;
396+
EditorPrefs.SetInt(Application.productName + "_EncryptMode", (int)_encryptMode);
397+
}
398+
399+
GUI.Label(new Rect(5, 80, 150, 20), "Asset Version: " + _assetVersion);
400+
if (GUI.Button(new Rect(150, 80, 95, 20), "Reset", _preButton))
401+
{
402+
_assetVersion = 1;
403+
EditorPrefs.SetInt(Application.productName + "_AssetVersion", _assetVersion);
404+
}
405+
406+
if (GUI.Button(new Rect(100, 105, 50, 20), "Sure", _preButton))
407+
{
408+
_showSetting = false;
409+
}
410+
411+
GUI.EndGroup();
412+
}
413+
}
355414
}
356415

357416
/// <summary>
@@ -372,4 +431,38 @@ public enum FileType
372431
/// </summary>
373432
InValidFile
374433
}
434+
435+
/// <summary>
436+
/// 压缩模式
437+
/// </summary>
438+
public enum ZipMode
439+
{
440+
/// <summary>
441+
/// 不压缩
442+
/// </summary>
443+
Uncompressed = 1,
444+
/// <summary>
445+
/// LZMA压缩
446+
/// </summary>
447+
LZMA = 0,
448+
/// <summary>
449+
/// LZ4压缩
450+
/// </summary>
451+
LZ4 = 256
452+
}
453+
454+
/// <summary>
455+
/// 加密模式
456+
/// </summary>
457+
public enum EncryptMode
458+
{
459+
/// <summary>
460+
/// 不加密
461+
/// </summary>
462+
None,
463+
/// <summary>
464+
/// AES加密
465+
/// </summary>
466+
AES
467+
}
375468
}

0 commit comments

Comments
 (0)