#Alovon's Untiy Dropdown Problem
1 messages · Page 1 of 1 (latest)
Error on GuessNumSelector line 12: guessesDropdown was not assigned a value
Yeah, it seems that it's unable to parse the input
and it just skips the if-else statement outright
No, it's unable to get the text because there is no dropdown in that variable
It's null
Yeah, and I guess that is tripping it iup
because if it got into the loop properly it should default to 15 tries for the computer
but instead it does the fallback in NumberGuessUI
so NumberGuessUI (Which presides over the program's main scenes) is not getting altered
by GuessNumSelector (The presider of the TextMeshPro Dropdown)
Make sure there is a dropdown referenced in that script's Inspector. As errors stop script execution it's normal that nothing after that line runs
How would I do that here? really new to unity
Show the Inspector of the object that has your Guess Num Selector script attached
That's an event, not your script
That event refers to another object on which the Guess Num Selector script is on - show that one instead
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class GuessNumSelector : MonoBehaviour
{
public TMP_Dropdown guessesDropdown;
public void SetMaxGuesses()
{
if (guessesDropdown.value == 0)
{
NumberGuessUI.MaxGuessesAllowed = 5;
}
else if (guessesDropdown.value == 1)
{
NumberGuessUI.MaxGuessesAllowed = 10;
}
else
{
NumberGuessUI.MaxGuessesAllowed = 15;
}
}
}
?
Well GuessNumSelector is only on one object
that TMP Dropdown
There we go
See how it says "None (TMP_Dropdown)"? You need to drag and drop your dropdown in there
That's where the error comes from
Yeah
Partly, the code gives you a hint that something was wrong in your setup in Unity
Either way, thank you that seemed to make it all work
all 3 options give the proper number of tries to the computer
Nice. I'll let you archive the thread if you don't have more questions