代码更改Unity设置中的ICON

醉酒当歌 提交于 2019-12-03 15:44:48

下面的代码是自己研究的可以实现更改unity设置中ICON的功能。


 void SetDefaultIcon(Texture2D tex)
    {
        var getIconFormPlatform = typeof(PlayerSettings).GetMethod("GetIconsForPlatform", BindingFlags.NonPublic | BindingFlags.Static);
        var getIconSizesForPlatform = typeof(PlayerSettings).GetMethod("GetIconSizesForPlatform", BindingFlags.NonPublic | BindingFlags.Static);
        var setIconsForPlatform = typeof(PlayerSettings).GetMethod("SetIconsForPlatform", BindingFlags.NonPublic | BindingFlags.Static);
        var array = (Texture2D[])getIconFormPlatform.Invoke(null, new object[] { string.Empty });
        var iconSizesForPlatform = (int[])getIconSizesForPlatform.Invoke(null, new object[] { string.Empty });
        if (array.Length != iconSizesForPlatform.Length)
        {
            array = new Texture2D[iconSizesForPlatform.Length];
            setIconsForPlatform.Invoke(null, new object[] { string.Empty, array });
        }
        array[0] = tex;
        setIconsForPlatform.Invoke(null, new object[] { string.Empty, array });
        AssetDatabase.SaveAssets();
        defaultIconName = tex != null ? tex.name : string.Empty;

    }


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!