dropdown not showing dynamic int option

Please help
I have created a method that takes in an int and runs another method. I attached the script to a game object and attached that Game object to the OnValueChanged section of the drop down object in the inspector. However, in the inspector, I am not given the ability to make my method be used as a dynamic int. I’ve looked and i cant find anyone who’s had a similar issue to mine, and because I am new to unity i am unsure as to how to fix this.

public class CameraMenu : MonoBehaviour
{
public void CameraPosition(int option)
    {
        if (option == 0)
        {
            fixedcamera();
        }
        else if (option == 1)
        {
            floatingcamera();
        }
        else if (option == 2)
        {
            beziercamera();
        }
    }
}

my script basically looks like this, when i select any of the options from the dropdown it always runs option zero so from what i can tell it only passes 0.

I forgot to mention it but from what i can tell all the methods that this method is calling do work, it just always runs a 0 case. when i switch which method is assign to option zero around, that case works but only that method. is there a way to make it so each dropdown option sends an int without using dynamic int as an alternative?

So I just had the same problem. I believe it might be related to the new update, at least that’s what it seems for me. Did you recently upgrade to 2019.2.6f1. I upgraded today and this became a problem. I just downgraded back to 2019.2.4f1 and it solved the problem - the dynamic int works again.

I am in 2019.2.5f1 and ill try to revert it.

I’m wondering if its a bug cause reverting it didnt really change anything. tomorrow ill try going to an even later build and see if it works there

Hey, yea I think its definitely a bug. Reverting to 2019.2.4f1 solved the issue for me only in the sense that I figured the bug was in 2.5f1 or 2.6f1 and I backtracked for the moment to avoid it. Sorry that it didn’t work for you. Hopefully a fix will come soon.

Sorry to revive this thread, but I wanted to answer it for anyone else who may come along. Dynamic ints are not a thing. It has to be a float, you can use

public void SliderFunction (float dynamicFloat)
{
    Mathf.RoundToInt(dynamicFloat);
}

To convert it to an integer. It seems GSanLob was able to get ints working, I’m going to assume this was a float and he didn’t realize it because as far as I know dynamic ints are not a thing, I think it has something to do with sliders returning floats, even when the ‘whole numbers’ option is ticked. I had the same issue, changed my int to a float and everything worked, so I’m assuming this is the answer. If anyone has more info I’d love to hear!

Also, in the words of the documentation:
" The slider has a single event called On Value Changed that responds as the user drags the handle. The current numeric value of the slider is passed to the function as a float parameter. "

1 Like

Now you can use a method with an int signature but it’s called with the index of your drop down