During the tranfer of a running application, I get some compilation problems. So I try to start a very short new application with 2019.2.5 version, And the editor gives a lot of underline names, and an error in line 16.:
NullReferenceException: Object reference not set to an instance of an object
DropdownExample.Start () (at Assets/DropdownExample.cs:16)
Here is the small code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
public class DropdownExample : MonoBehaviour
{
public Dropdown dropdown;
public static List names;
// Start is called before the first frame update
void Start()
{
names = new List { “”, “Adelaide”, “Adelaide_d’Aquitaine”, “Adelaide_de_Bourgogne” };
//dropdown.ClearOptions();
dropdown.AddOptions(names);
}
public void Dropdown_IndexChanged(int index)
{
Debug.Log(“index=” + index);
}
}
More, impossible to fix the Dropdown (Script) On Value Change as a dynamic one.
Can you help me?