Skip to content

Commit 26312e9

Browse files
committed
【Obb自动改名】
1 parent c55f70e commit 26312e9

6 files changed

+167
-9
lines changed
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
#if UNITY_EDITOR
5+
using UnityEditor;
6+
using UnityEditor.Callbacks;
7+
using System.IO;
8+
using System.Threading;
9+
#endif
10+
11+
/// <summary>
12+
/// Obb 自动重命名
13+
/// </summary>
14+
public static class AndroidBuildPostprocess
15+
{
16+
#if UNITY_EDITOR
17+
[PostProcessBuild(999)]
18+
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
19+
{
20+
if(target != BuildTarget.Android || PlayerSettings.Android.useAPKExpansionFiles == false)
21+
{
22+
return;
23+
}
24+
25+
WaitBuildSuccess(Directory.GetParent(pathToBuiltProject).FullName);
26+
}
27+
28+
static void WaitBuildSuccess(string pathToBuiltProject)
29+
{
30+
if (Directory.Exists(pathToBuiltProject))
31+
{
32+
DirectoryInfo direction = new DirectoryInfo(pathToBuiltProject);
33+
FileInfo[] files = direction.GetFiles("*", SearchOption.TopDirectoryOnly);
34+
for (int i = 0; i < files.Length; i++)
35+
{
36+
if (files[i].Name.EndsWith(".obb"))
37+
{
38+
string sourceName = files[i].FullName;
39+
string obbName = "main." + PlayerSettings.Android.bundleVersionCode +"."+ Application.identifier + ".obb";
40+
string destName = Path.Combine(pathToBuiltProject, obbName);
41+
Directory.Move(sourceName, destName);
42+
Debug.Log("Obb Change Name:" + sourceName +" To " + destName);
43+
}
44+
}
45+
}
46+
}
47+
#endif
48+
}

Assets/Editor/AndroidBuildPostprocess.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Editor/ChangePrefab.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
public class ChangePrefab : EditorWindow
1111
{
1212

13-
[MenuItem("Tools/ChangePrefab")]
13+
[MenuItem("Tools/交换Prefab位置工具")]
1414
public static void Open()
1515
{
16-
//GetWindow(typeof(Change_Prefab));
17-
GetWindow<ChangePrefab>("ChangePrefab工具");
16+
GetWindow<ChangePrefab>("交换Prefab位置工具");
1817
}
1918

2019
public GameObject newPrefab;

ProjectSettings/EditorBuildSettings.asset

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
EditorBuildSettings:
55
m_ObjectHideFlags: 0
66
serializedVersion: 2
7-
m_Scenes: []
7+
m_Scenes:
8+
- enabled: 1
9+
path: Assets/Scenes/SampleScene.unity
10+
guid: 829431edede675a409b066468b577df3
811
m_configObjects: {}

ProjectSettings/GraphicsSettings.asset

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ GraphicsSettings:
3636
- {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
3737
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
3838
- {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0}
39+
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
40+
- {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
41+
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
3942
m_PreloadedShaders: []
4043
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
4144
type: 0}
@@ -60,3 +63,4 @@ GraphicsSettings:
6063
m_AlbedoSwatchInfos: []
6164
m_LightsUseLinearIntensity: 0
6265
m_LightsUseColorTemperature: 0
66+
m_LogWhenShaderIsCompiled: 0

ProjectSettings/ProjectSettings.asset

+98-5
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,10 @@ PlayerSettings:
156156
resolutionScalingMode: 0
157157
androidSupportedAspectRatio: 1
158158
androidMaxAspectRatio: 2.1
159-
applicationIdentifier: {}
159+
applicationIdentifier:
160+
Android: com.jeff.hhh
160161
buildNumber: {}
161-
AndroidBundleVersionCode: 1
162+
AndroidBundleVersionCode: 4
162163
AndroidMinSdkVersion: 16
163164
AndroidTargetSdkVersion: 0
164165
AndroidPreferredInstallLocation: 1
@@ -169,7 +170,7 @@ PlayerSettings:
169170
ForceInternetPermission: 0
170171
ForceSDCardPermission: 0
171172
CreateWallpaper: 0
172-
APKExpansionFiles: 0
173+
APKExpansionFiles: 1
173174
keepLoadedShadersAlive: 0
174175
StripUnusedMeshComponents: 1
175176
VertexChannelCompressionMask: 4054
@@ -244,7 +245,7 @@ PlayerSettings:
244245
clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea
245246
templatePackageId: com.unity.template.3d@1.3.0
246247
templateDefaultScene: Assets/Scenes/SampleScene.unity
247-
AndroidTargetArchitectures: 5
248+
AndroidTargetArchitectures: 1
248249
AndroidSplashScreenScale: 0
249250
androidSplashScreen: {fileID: 0}
250251
AndroidKeystoreName:
@@ -262,7 +263,99 @@ PlayerSettings:
262263
androidGamepadSupportLevel: 0
263264
resolutionDialogBanner: {fileID: 0}
264265
m_BuildTargetIcons: []
265-
m_BuildTargetPlatformIcons: []
266+
m_BuildTargetPlatformIcons:
267+
- m_BuildTarget: Android
268+
m_Icons:
269+
- m_Textures: []
270+
m_Width: 432
271+
m_Height: 432
272+
m_Kind: 2
273+
m_SubKind:
274+
- m_Textures: []
275+
m_Width: 324
276+
m_Height: 324
277+
m_Kind: 2
278+
m_SubKind:
279+
- m_Textures: []
280+
m_Width: 216
281+
m_Height: 216
282+
m_Kind: 2
283+
m_SubKind:
284+
- m_Textures: []
285+
m_Width: 162
286+
m_Height: 162
287+
m_Kind: 2
288+
m_SubKind:
289+
- m_Textures: []
290+
m_Width: 108
291+
m_Height: 108
292+
m_Kind: 2
293+
m_SubKind:
294+
- m_Textures: []
295+
m_Width: 81
296+
m_Height: 81
297+
m_Kind: 2
298+
m_SubKind:
299+
- m_Textures: []
300+
m_Width: 192
301+
m_Height: 192
302+
m_Kind: 0
303+
m_SubKind:
304+
- m_Textures: []
305+
m_Width: 144
306+
m_Height: 144
307+
m_Kind: 0
308+
m_SubKind:
309+
- m_Textures: []
310+
m_Width: 96
311+
m_Height: 96
312+
m_Kind: 0
313+
m_SubKind:
314+
- m_Textures: []
315+
m_Width: 72
316+
m_Height: 72
317+
m_Kind: 0
318+
m_SubKind:
319+
- m_Textures: []
320+
m_Width: 48
321+
m_Height: 48
322+
m_Kind: 0
323+
m_SubKind:
324+
- m_Textures: []
325+
m_Width: 36
326+
m_Height: 36
327+
m_Kind: 0
328+
m_SubKind:
329+
- m_Textures: []
330+
m_Width: 192
331+
m_Height: 192
332+
m_Kind: 1
333+
m_SubKind:
334+
- m_Textures: []
335+
m_Width: 144
336+
m_Height: 144
337+
m_Kind: 1
338+
m_SubKind:
339+
- m_Textures: []
340+
m_Width: 96
341+
m_Height: 96
342+
m_Kind: 1
343+
m_SubKind:
344+
- m_Textures: []
345+
m_Width: 72
346+
m_Height: 72
347+
m_Kind: 1
348+
m_SubKind:
349+
- m_Textures: []
350+
m_Width: 48
351+
m_Height: 48
352+
m_Kind: 1
353+
m_SubKind:
354+
- m_Textures: []
355+
m_Width: 36
356+
m_Height: 36
357+
m_Kind: 1
358+
m_SubKind:
266359
m_BuildTargetBatching:
267360
- m_BuildTarget: Standalone
268361
m_StaticBatching: 1

0 commit comments

Comments
 (0)