I’ve periodically run into this error with TMP_Dropdown when clicking on a dropdown for the first time in playmode:
NullReferenceException: Object reference not set to an instance of an object
TMPro.TMP_Dropdown.AlphaFadeList (System.Single duration, System.Single start, System.Single end) (at Library/PackageCache/com.unity.textmeshpro@3.0.4/Scripts/Runtime/TMP_Dropdown.cs:1072)
TMPro.TMP_Dropdown.Show () (at Library/PackageCache/com.unity.textmeshpro@3.0.4/Scripts/Runtime/TMP_Dropdown.cs:890)
TMPro.TMP_Dropdown.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.textmeshpro@3.0.4/Scripts/Runtime/TMP_Dropdown.cs:707)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2020.2.6f1/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.6f1/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.6f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:385)
The offending line in TMP_Dropdown is:
m_AlphaTweenRunner.StartTween(tween);
It would appear that TMP_Dropdown isn’t checking that m_AlphaTweenRunner is initialized before trying to start the tween.
m_AlphaTweenRunner appears to be initialized in “Awake” so that shouldn’t be possible if the dropdown is active, so I am at a loss as to what is happening.
I’m in 2020.2.6f1 with TextMeshPro 3.0.4, but the problem existed in 2019.2 and TextMeshPro 3.0.3.
private TweenRunner<FloatTween> m_AlphaTweenRunner = new TweenRunner<FloatTween>();
For some reason the Awake() function of TMP_Drowndown isn’t called so TweeRunner isn’t initialized, and TMPro.TMP_Dropdown.OnPointerClick called TweeRunner, that haven’t been initialize inside the Awake()
PS: You had to modify the TMP_Drowndown.cs from [User]\AppData\Local\Unity\cache\packages\packages.unity.com\com.unity.textmeshpro@3.0.4\Scripts\Runtime not the one in your project cache otherwise Unity will overwrite your change
Yes, but this fixed on a problem in a very narrow case (domain reloading which doesn’t really scale well on projects larger than a demo, not without significant work) and instead induced an error for the majority of us that don’t use the play mode options (using the 3.0.6 now), specifically I cannot have a dropdown starting with its game object de-activated and show it on-demand immediately because it now needs to wait for its Start().
As a workaround, I’m calling Start() manually after activating the game object, but I don’t feel good about it. Hope you’ll fix this in next versions