I followed this tutorial on Youtube and actually it works for me too. but I still get this error message immediately after starting the editor.
At the moment this message has no influence on my desired function, but I would rather have the error message completely gone in case there could be trouble later when compiling etc.
Why does the error appear to me?
Because I followed the tutorial pretty closely and I drag and droped the Dropdown instance from my hierarchy into the “public Dropdown DropDownVar;”:
here is my code that makes this error:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SettingsMenu : MonoBehaviour
{
// ==================== Resolution Dropdown ====================
public Dropdown DropDownVar;
private void Start()
{
DropDownVar.onValueChanged.AddListener(delegate
{
DropDownSettingsValueWechselPassiert(DropDownVar);
});
}
//Beim wechsel eines Wertes im Dropdown, wird das hier ausgefuehrt:
public void DropDownSettingsValueWechselPassiert(Dropdown transmitter)
{
switch(transmitter.value)
{
case 0:
// Switch to 640 x 480 full-screen at 60 hz
Screen.SetResolution(Display.main.systemWidth, Display.main.systemHeight, true, 60);
break;
case 1:
// Switch to 640 x 480 in full-screen
Screen.SetResolution(480, 640, true);
break;
case 2:
Screen.SetResolution(720, 1280, true);
break;
case 3:
Screen.SetResolution(1080, 1920, true);
break;
case 4:
Screen.SetResolution(1440, 2560, true);
break;
case 5:
Screen.SetResolution(2160, 3840, true);
break;
case 6:
Screen.SetResolution(2160, 4096, true);
break;
}
}
}