I am using Unity, and wrote down a script below:

The problem is it doesn't recognize the ClearOptions or AddOptions. All the resources I can find are using those, but my editor does not recognize them. How can I use them?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DropdownHandler : MonoBehaviour
    List<string> m_DropOptions = new List<string> { "Option 1", "Option 2" };
    Dropdown m_Dropdown;

    private void Start()
        //Fetch the Dropdown GameObject the script is attached to
        m_Dropdown = GetComponent<Dropdown>();
        //Clear the old options of the Dropdown menu
        //Add the options created in the List above
  • \$\begingroup\$ I had a similar problem once. Does it recognize Monobehaviour etc? If not you need to go to Preferences>External Tools and set the External Script Editor (I had to set VS Community 2019 as this is what I am using). Seems like you may already have done that but I thought Id mention it just in case \$\endgroup\$ – I_Keep_Trying Jun 4 at 12:57

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.