UnityCloudBuild上で無理やり圧縮オプションをLZ4に変更する事が出来るか!? ref: https://qiita.com/neon-izm/items/7ba9e52a5970345aee37
public class Preprocess : IPreprocessBuild { | |
// ビルド前処理 | |
public void OnPreprocessBuild (UnityEditor.BuildTarget buildTarget, string path) | |
{ | |
if (buildTarget == BuildTarget.Android) | |
{ | |
Debug.Log("[PREPROCESS] find Android Build"); | |
Console.WriteLine("[PREPROCESS] find Android Build"); | |
//https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/BuildPlayerWindow.cs#L770 | |
MethodInfo setCompressionTypeMethodInfo = | |
typeof(EditorUserBuildSettings).GetMethod("SetCompressionType", | |
BindingFlags.NonPublic | BindingFlags.Static); | |
try | |
{ | |
/* Invokeで実行するとき、staticクラスだったら第一引数はnull | |
* 第二引数は普通にpublicなenum でplatform | |
* 第三引数が内部定義されたenumなので、該当のint数値を直接突っ込んでいます | |
*/ | |
/* 第三引数はこんな感じで定義されています | |
namespace UnityEditor | |
{ | |
internal enum Compression | |
{ | |
None = 0, | |
Lz4 = 2, | |
Lz4HC = 3, | |
} | |
} | |
*/ | |
var invoke = setCompressionTypeMethodInfo.Invoke(null, new object[] {BuildTargetGroup.Android, 2}); | |
} | |
catch (Exception e) | |
{ | |
Debug.Log(e); | |
Console.WriteLine(e); | |
throw; | |
} | |
MethodInfo getCompressionTypeMethodInfo = | |
typeof(EditorUserBuildSettings).GetMethod("GetCompressionType", | |
BindingFlags.NonPublic | BindingFlags.Static); | |
var obj = getCompressionTypeMethodInfo.Invoke(null, new object[] {BuildTargetGroup.Android}); | |
Debug.Log("[REPROCESS] current compression type:" + obj); | |
Console.WriteLine("[PREPROCESS] current compression type:" + obj); | |
} | |
} | |
// 実行順 | |
public int callbackOrder { get { return 0; } } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment