#Alovon's Untiy Dropdown Problem

1 messages · Page 1 of 1 (latest)

hexed gulch
burnt lily
#

Error on GuessNumSelector line 12: guessesDropdown was not assigned a value

hexed gulch
#

Yeah, it seems that it's unable to parse the input

#

and it just skips the if-else statement outright

burnt lily
#

No, it's unable to get the text because there is no dropdown in that variable

#

It's null

hexed gulch
#

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)

burnt lily
#

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

hexed gulch
#

How would I do that here? really new to unity

burnt lily
#

Show the Inspector of the object that has your Guess Num Selector script attached

hexed gulch
burnt lily
#

I don't see the script here

#

I just see the dropdown

hexed gulch
#

it's at the bottom

burnt lily
#

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

hexed gulch
#
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

burnt lily
#

No, it's not there

#

The TMP dropdown references it

hexed gulch
#

you mean this

#

oop

burnt lily
#

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

hexed gulch
#

?

burnt lily
#

Yeah

hexed gulch
#

Now we in buisness

#

So it wasn't in the code at all XD

burnt lily
#

Partly, the code gives you a hint that something was wrong in your setup in Unity

hexed gulch
#

Either way, thank you that seemed to make it all work

#

all 3 options give the proper number of tries to the computer

burnt lily
#

Nice. I'll let you archive the thread if you don't have more questions

hexed gulch
#

How do you archive theads actually Xd

#

First time properly using a one