Skip to content

Commit b6cd452

Browse files
committed
重写打包工具
1 parent 63bab14 commit b6cd452

File tree

7 files changed

+808
-1
lines changed

7 files changed

+808
-1
lines changed

.idea/.idea.UnityGameFramework/.idea/workspace.xml

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

.vscode/launch.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
5+
{
6+
"name": "Unity Editor",
7+
"type": "unity",
8+
"request": "launch"
9+
},
10+
{
11+
"name": "Windows Player",
12+
"type": "unity",
13+
"request": "launch"
14+
},
15+
{
16+
"name": "OSX Player",
17+
"type": "unity",
18+
"request": "launch"
19+
},
20+
{
21+
"name": "Linux Player",
22+
"type": "unity",
23+
"request": "launch"
24+
},
25+
{
26+
"name": "iOS Player",
27+
"type": "unity",
28+
"request": "launch"
29+
},
30+
{
31+
"name": "Android Player",
32+
"type": "unity",
33+
"request": "launch"
34+
35+
}
36+
]
37+
}

.vscode/settings.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"files.exclude":
3+
{
4+
"**/.DS_Store":true,
5+
"**/.git":true,
6+
"**/.gitignore":true,
7+
"**/.gitmodules":true,
8+
"**/*.booproj":true,
9+
"**/*.pidb":true,
10+
"**/*.suo":true,
11+
"**/*.user":true,
12+
"**/*.userprefs":true,
13+
"**/*.unityproj":true,
14+
"**/*.dll":true,
15+
"**/*.exe":true,
16+
"**/*.pdf":true,
17+
"**/*.mid":true,
18+
"**/*.midi":true,
19+
"**/*.wav":true,
20+
"**/*.gif":true,
21+
"**/*.ico":true,
22+
"**/*.jpg":true,
23+
"**/*.jpeg":true,
24+
"**/*.png":true,
25+
"**/*.psd":true,
26+
"**/*.tga":true,
27+
"**/*.tif":true,
28+
"**/*.tiff":true,
29+
"**/*.3ds":true,
30+
"**/*.3DS":true,
31+
"**/*.fbx":true,
32+
"**/*.FBX":true,
33+
"**/*.lxo":true,
34+
"**/*.LXO":true,
35+
"**/*.ma":true,
36+
"**/*.MA":true,
37+
"**/*.obj":true,
38+
"**/*.OBJ":true,
39+
"**/*.asset":true,
40+
"**/*.cubemap":true,
41+
"**/*.flare":true,
42+
"**/*.mat":true,
43+
"**/*.meta":true,
44+
"**/*.prefab":true,
45+
"**/*.unity":true,
46+
"build/":true,
47+
"Build/":true,
48+
"Library/":true,
49+
"library/":true,
50+
"obj/":true,
51+
"Obj/":true,
52+
"ProjectSettings/":true,
53+
"temp/":true,
54+
"Temp/":true
55+
}
56+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEditor;
5+
using System.IO;
6+
using System;
7+
8+
public class AssetBundleBuildEditor :EditorWindow {
9+
10+
private static string _configPath="ProjectSettings/AssetBundleEditorConifg.json";
11+
private static AssetBundleConifgInfo _config;
12+
private static List<string> _buildTargets;
13+
private static string _outPutPath="";
14+
15+
private Vector2 _scrollViewPos;
16+
17+
[MenuItem("Tools/AssetBundles Options")]
18+
public static void AssetBundilesOptions()
19+
{
20+
LoadConfig();
21+
22+
GetWindowWithRect<AssetBundleBuildEditor>(new Rect(Screen.width/2,Screen.height/2,400,30));
23+
}
24+
25+
[MenuItem("Tools/Build AssetBundles")]
26+
public static void BuildAssetBundles()
27+
{
28+
LoadConfig();
29+
30+
BuildPipeline.BuildAssetBundles(_config.BuildPath,BuildAssetBundleOptions.None,EditorUserBuildSettings.activeBuildTarget);
31+
}
32+
33+
[MenuItem("Tools/Build AssetBundles All Targets")]
34+
public static void BuildAssetBundlesAllTargets()
35+
{
36+
LoadConfig();
37+
38+
//List<BuildTarget> targets=new List<BuildTarget>();
39+
for(int i=0;i<_config.BuildTargets.Count;i++)
40+
{
41+
BuildTarget target= (BuildTarget)_config.BuildTargets[i];
42+
string buildPath=Path.Combine(_config.BuildPath,target.ToString());
43+
BuildPipeline.BuildAssetBundles(buildPath,BuildAssetBundleOptions.None,target);
44+
}
45+
46+
}
47+
48+
/// <summary>
49+
/// OnGUI is called for rendering and handling GUI events.
50+
/// This function can be called multiple times per frame (one call per event).
51+
/// </summary>
52+
void OnGUI()
53+
{
54+
if (_config==null)
55+
{
56+
return;
57+
}
58+
59+
GUILayout.BeginVertical("HelpBox");
60+
61+
GUILayout.BeginHorizontal("Box");
62+
GUILayout.Label("Version");
63+
GUILayout.Label(_config.Version.ToString());
64+
if(GUILayout.Button("RESET",GUILayout.Width(60)))
65+
{
66+
67+
}
68+
GUILayout.EndHorizontal();
69+
70+
GUILayout.BeginHorizontal("Box");
71+
GUILayout.Label("BuildPath");
72+
GUILayout.Label(_config.BuildPath);
73+
74+
if(GUILayout.Button("BROWSE",GUILayout.Width(60)))
75+
{
76+
77+
}
78+
GUILayout.EndHorizontal();
79+
80+
_scrollViewPos=GUILayout.BeginScrollView(_scrollViewPos,"Box");
81+
string[] targets= Enum.GetNames(typeof(BuildTarget));
82+
for(int i=0;i<targets.Length;i++)
83+
{
84+
GUILayout.Toggle(false,targets[i]);
85+
}
86+
GUILayout.EndScrollView();
87+
88+
GUILayout.BeginHorizontal();
89+
GUILayout.FlexibleSpace();
90+
if(GUILayout.Button("OK",GUILayout.Width(60)))
91+
{
92+
93+
}
94+
GUILayout.EndHorizontal();
95+
96+
GUILayout.EndVertical();
97+
}
98+
99+
//加载配置信息
100+
private static void LoadConfig()
101+
{
102+
103+
if (!File.Exists(_configPath))
104+
{
105+
File.WriteAllText(_configPath,JsonUtility.ToJson(new AssetBundleConifgInfo()));
106+
}
107+
108+
_config=JsonUtility.FromJson<AssetBundleConifgInfo>(File.ReadAllText(_configPath));
109+
// _config.Targets=new List<BuildTarget>();
110+
// for(int i=0;i<_config.BuildTargets.Count;i++)
111+
// {
112+
// _config.Targets.Add((BuildTarget)_config.BuildTargets[i]);
113+
// }
114+
}
115+
116+
117+
118+
119+
//ab包的配置文件信息
120+
[System.Serializable]
121+
public class AssetBundleConifgInfo
122+
{
123+
public int Version=-1;
124+
public string BuildPath="";
125+
public List<int> BuildTargets=new List<int>();
126+
127+
}
128+
129+
}

Assets/GameFramework/Editor/AssetBundleEditor/AssetBundleBuildEditor.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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ private void Init()
100100

101101
private void Update()
102102
{
103+
103104
if (EditorApplication.isCompiling)
104105
{
105106
Close();
106107
}
108+
107109
}
108110

109111
private void OnGUI()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"BuildPath":"C:/Users/codingworks/Desktop/test","ZipMode":256,"BuildTargets":[5,9],"EncryptMode":1,"AssetVersion":17}
1+
{"Version":-1,"BuildPath":"xxxxxxxxxxxxxx","BuildTargets":[5,9]}

0 commit comments

Comments
 (0)