Answer the question
In order to leave comments, you need to log in
From what can be an error in the selective menu?
In general, in my code there is a selective menu for choosing languages, after choosing a language in (On Value Changet (Int32)) I use the following method
public int Language = 0;
public GameObject DropdownLanguage;
public void SetLanguage(){
Language = DropdownLanguage.GetComponent<Dropdown>().value;
PlayerPrefs.SetInt("Language", Language);
PlayerPrefs.Save();
}
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.UI.Dropdown.AlphaFadeList
(System.Single duration, System.Single start, System.Single end)
(at C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Dropdown.cs:1049)
UnityEngine.UI.Dropdown.Show ()
(at C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Dropdown.cs:866)
UnityEngine.UI.Dropdown.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData)
(at C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Dropdown.cs:685)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData)
(at C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[T]
(UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor)
(at C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:262)
UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2020.2.1f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:385)
Answer the question
In order to leave comments, you need to log in
Something didn't initialize somewhere.
If the tests are automatic - it is quite possible that you need to insert an expectation of SOMETHING (but not in time!) - such as the same Start or Awake
In general, you need to look at the logic and look at the crash site
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question