Want to set adaptive icon for Android from script.
I am using Unity example: https://docs.unity3d.com/ScriptReference/PlayerSettings.SetPlatformIcons.html so, what am I doing:

     void Start()
        Texture2D[][] jaggedArray =
             new Texture2D[] { (Texture2D)AssetDatabase.LoadAssetAtPath(pathToTexture, typeof(Texture2D))},
             new Texture2D[] { (Texture2D)AssetDatabase.LoadAssetAtPath(pathToTexture, typeof(Texture2D))}


void SetIcons(Texture2D[][] textures)
    var platform = BuildTargetGroup.Android;
    var kind = UnityEditor.Android.AndroidPlatformIconKind.Adaptive;

    var icons = PlayerSettings.GetPlatformIcons(platform, kind);

    //Assign textures to each available icon slot.
    for (var i = 0; i < icons.Length; i++)
    PlayerSettings.SetPlatformIcons(platform, kind, icons);

What am I doing wrong, coz I am getting InvalidOperationException?

  • \$\begingroup\$ Where is the exception being thrown? What's the full text of the error message? \$\endgroup\$ – DMGregory Dec 14 '18 at 13:03
  • \$\begingroup\$ Also, it's a bit unusual to call this in Start, since that's a MonoBehaviour message that's fired at runtime. SetPlatformIcons is in the UnityEditor namespace, so I'd expect this to be done via an editor script when you're editing your project. It might not be valid to call at runtime. \$\endgroup\$ – DMGregory Dec 14 '18 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.