Unity设置AppIcon方法
Posted JohnRey
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Unity设置AppIcon方法相关的知识,希望对你有一定的参考价值。
制作unity自动打包工具时,不同的渠道需要不同的AppIcon,在网上找了方法,记录下
代码:
public void SetDefaultIcon() {
Texture2D texture = AssetDatabase.LoadAssetAtPath(string.Format("Assets/AppIcon/{0}.png", "appicon"), typeof(Texture2D)) as Texture2D; MethodInfo getIconFormPlatform = typeof(PlayerSettings).GetMethod("GetIconsForPlatform", BindingFlags.NonPublic | BindingFlags.Static); MethodInfo getIconSizesForPlatform = typeof(PlayerSettings).GetMethod("GetIconSizesForPlatform", BindingFlags.NonPublic | BindingFlags.Static); MethodInfo setIconsForPlatform = typeof(PlayerSettings).GetMethod("SetIconsForPlatform", BindingFlags.NonPublic | BindingFlags.Static); Texture2D[] textureArray = (Texture2D[])getIconFormPlatform.Invoke(null, new object[] { string.Empty }); var iconSizesForPlatform = (int[])getIconSizesForPlatform.Invoke(null, new object[] { string.Empty }); if (textureArray.Length != iconSizesForPlatform.Length) { textureArray = new Texture2D[iconSizesForPlatform.Length]; setIconsForPlatform.Invoke(null, new object[] { string.Empty, textureArray }); } setIconsForPlatform.Invoke(null, new object[] { string.Empty, textureArray }); AssetDatabase.SaveAssets(); }
以上是关于Unity设置AppIcon方法的主要内容,如果未能解决你的问题,请参考以下文章