zoukankan      html  css  js  c++  java
  • Unity设置AppIcon方法

    制作unity自动打包工具时,不同的渠道需要不同的AppIcon,在网上找了方法,记录下

    Unity4.6测试可用,Unity2017.2.0测试不可用

    代码:

        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 }); }
         textureArray[0] = texture; setIconsForPlatform.Invoke(
    null, new object[] { string.Empty, textureArray }); AssetDatabase.SaveAssets(); }

     自己摸索了下,折腾出2017下修改APPIcon方法

        private void _setDefaultIcon(string iconName)
        {
            Texture2D texture = AssetDatabase.LoadAssetAtPath(string.Format("Assets/Images/Icon/{0}.png", iconName),
                typeof(Texture2D)) as Texture2D;
    
            int[] iconSize = PlayerSettings.GetIconSizesForTargetGroup(BuildTargetGroup.Android);
            Texture2D[] textureArray = new Texture2D[iconSize.Length];
            for (int i = 0; i < textureArray.Length; i++)
            {
                textureArray[i] = texture;
            }
            textureArray[0] = texture;
            PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Android, textureArray);
            AssetDatabase.SaveAssets();
        }
  • 相关阅读:
    ksframework的xlua版本
    unity摄像机脚本
    代码重构:用工厂+策略模式优化过多的if else代码块
    在Unity中创建攻击Slot系统
    Unity运用GPU代替CPU处理和计算简单测试
    程序员工具集
    Unity开发-你必须知道的优化建议
    unity向量计算
    ClassFoo-IT知识花园
    BZOJ 3446: [Usaco2014 Feb]Cow Decathlon( 状压dp )
  • 原文地址:https://www.cnblogs.com/Yellow0-0River/p/9208278.html
Copyright © 2011-2022 走看看