-
Notifications
You must be signed in to change notification settings - Fork 63
/
BuildEventHandle.cs
107 lines (94 loc) · 5.86 KB
/
BuildEventHandle.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using UnityGameFramework.Editor.ResourceTools;
namespace UGFExtensions.Build.Editor
{
public class BuildEventHandle : IBuildEventHandler
{
public bool ContinueOnFailure
{
get { return false; }
}
public void OnPreprocessAllPlatforms(string productName, string companyName, string gameIdentifier,
string gameFrameworkVersion, string unityVersion, string applicableGameVersion, int internalResourceVersion,
UnityGameFramework.Editor.ResourceTools.Platform platforms, AssetBundleCompressionType assetBundleCompression, string compressionHelperTypeName,
bool additionalCompressionSelected, bool forceRebuildAssetBundleSelected, string buildEventHandlerTypeName,
string outputDirectory, BuildAssetBundleOptions buildAssetBundleOptions, string workingPath,
bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath,
bool outputPackedSelected, string outputPackedPath, string buildReportPath)
{
}
public void OnPreprocessPlatform(UnityGameFramework.Editor.ResourceTools.Platform platform, string workingPath, bool outputPackageSelected,
string outputPackagePath,
bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath)
{
}
public void OnBuildAssetBundlesComplete(UnityGameFramework.Editor.ResourceTools.Platform platform, string workingPath, bool outputPackageSelected,
string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected,
string outputPackedPath, AssetBundleManifest assetBundleManifest)
{
}
public void OnOutputUpdatableVersionListData(UnityGameFramework.Editor.ResourceTools.Platform platform, string versionListPath, int versionListLength,
int versionListHashCode, int versionListZipLength, int versionListZipHashCode)
{
Type resourceBuilderType =
Type.GetType("UnityGameFramework.Editor.ResourceTools.ResourceBuilder,UnityGameFramework.Editor");
var window = EditorWindow.GetWindow(resourceBuilderType);
ResourceBuilderController builderController =
window.GetType().GetField("m_Controller", BindingFlags.Instance | BindingFlags.NonPublic)
?.GetValue(window) as ResourceBuilderController;
if (builderController == null)
{
return;
}
VersionInfoEditorData versionInfoEditorData =
AssetDatabase.LoadAssetAtPath<VersionInfoEditorData>("Assets/Res/Configs/VersionInfoEditorData.asset");
if (versionInfoEditorData == null)
{
versionInfoEditorData = ScriptableObject.CreateInstance<VersionInfoEditorData>();
versionInfoEditorData.VersionInfos = new List<VersionInfoWrapData>
{ new VersionInfoWrapData() { Key = "Normal", Value = new VersionInfoData() } };
AssetDatabase.CreateAsset(versionInfoEditorData, "Assets/Res/Configs/VersionInfoEditorData.asset");
Debug.Log("CreateVersionInfoEditorData Success!");
AssetDatabase.Refresh();
Selection.activeObject = versionInfoEditorData;
}
VersionInfoData versionInfoData = versionInfoEditorData.GetActiveVersionInfoData();
versionInfoData.AutoIncrementInternalGameVersion();
versionInfoData.ForceUpdateGame = false;
versionInfoData.ResourceVersion = builderController.ApplicableGameVersion.Replace('.', '_')+ "_"+builderController.InternalResourceVersion;
versionInfoData.Platform = (Platform)(int)platform;
versionInfoData.LatestGameVersion = builderController.ApplicableGameVersion;
versionInfoData.InternalResourceVersion = builderController.InternalResourceVersion;
versionInfoData.VersionListLength = versionListLength;
versionInfoData.VersionListHashCode = versionListHashCode;
versionInfoData.VersionListCompressedLength = versionListZipLength;
versionInfoData.VersionListCompressedHashCode = versionListZipHashCode;
EditorUtility.SetDirty(versionInfoEditorData);
AssetDatabase.SaveAssets();
if (versionInfoEditorData.IsGenerateToFullPath)
{
versionInfoEditorData.Generate(Path.Combine(builderController.OutputFullPath, platform.ToString(), $"{platform}Version.txt"));
}
}
public void OnPostprocessPlatform(UnityGameFramework.Editor.ResourceTools.Platform platform, string workingPath, bool outputPackageSelected,
string outputPackagePath,
bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath,
bool isSuccess)
{
}
public void OnPostprocessAllPlatforms(string productName, string companyName, string gameIdentifier,
string gameFrameworkVersion, string unityVersion, string applicableGameVersion, int internalResourceVersion,
UnityGameFramework.Editor.ResourceTools.Platform platforms, AssetBundleCompressionType assetBundleCompression, string compressionHelperTypeName,
bool additionalCompressionSelected, bool forceRebuildAssetBundleSelected, string buildEventHandlerTypeName,
string outputDirectory, BuildAssetBundleOptions buildAssetBundleOptions, string workingPath,
bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath,
bool outputPackedSelected, string outputPackedPath, string buildReportPath)
{
}
}
}