There is a problem of adding images for Dropdown items. When specifying images for Options in the Inspector, there is no effect. Trying to add Options in the code:

public class FillDroPDown : MonoBehavior { public Dropdown dd; void Start () { dd.options.Clear(); dd.AddOptions(new List<Dropdown.OptionData> { new Dropdown.OptionData { text="1", image=Resources.Load("LeftToRight.png", typeof(Sprite)) as Sprite } }); } void Update () { } } 

Text data is displayed successfully, but images are not. Please help with solving this problem. Unity version 5.3.4f1.

    1 answer 1

    It is necessary that the resources (in this case, the sprite) were in the Resources folder. I myself suffered with this because anywhere it did not find for very long. If you have it in the child category of the Resources folder (for example, Resources / Sprites), you must write

     image=Resources.Load("Sprites/LeftToRight.png", typeof(Sprite)) as Sprite 

    In general, I advise you to manually create a dropdown, change everything you need and continue to generate it from the prefab. Instead of writing a script for this. Or at a minimum, adjust the look of the dropdown itself from the prefab, and the text is already set by the script.