I can not figure out how to change the array once i select a option in a dropdown.
StartCoroutine(LoadBackgroundMusic( fileArray[0]));
im trying to change that fileArray. i am getting all of the names (strings) in it, but i can not figure out how to change the int form 0 to, 1,2,3, etc
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEngine.UI;
using System;
using System.Linq;
public class DropDownScriptForMusic : MonoBehaviour {
List<string> NewNames = new List<string>();
public ButtonSelectedScript button;
public Dropdown dropdown;
public Text selectedName;
public void DropDown_IndexChange(int index)
{
selectedName.text = NewNames[index];
}
public void MusicList()
{
NewNames.AddRange(button.names);
dropdown.AddOptions(NewNames);
}
}
^ my dropdown codes
Comment
Answer by Straafe · Sep 24, 2019 at 03:57 PM
You're having trouble updating the dropdown options? After editing the DropdownOptions, you need to run RefreshShownValue(), so just add
dropdown.RefreshShownValue();
At the end of your MusicList() function.
the dropdown menu updates fine, the problem im trying to figure out is how to change the int in the array that the dropdown menu is calling
You want to change the currently selected entry in the dropdown? Or both change the current selection and all the options? Or something else? I am still a little confused on what your problem is.
Your answer
![](https://koobas.hobune.stream/wayback/20220612212548im_/https://answers.unity.com/themes/thub/images/avi.jpg)