Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity3D Slider onValueChanged sending only 0 (or other defined value)

I'm trying to attach an onValueChanged event to my GUI Slider, but for some reason it gives me a mandatory option to put a value in (it's the fourth box in the "On Value Change (Single)" section). Then it only sends the forementioned value, not the actual value of the slider.

enter image description here

The code for the event is as follows:

public void ChangeWindDirection(float value)
{
    Debug.Log("New wind direction: " + value);
}

I tried restarting both Unity and Visual Studio 2013 to no avail. Now it even puts the box with a value to every new event I try to create.

like image 538
Filip Vondrášek Avatar asked Sep 20 '15 14:09

Filip Vondrášek


People also ask

What does the Slider UI element represent unity?

The Slider UI element is commonly used where a certain value should be set between a minimum and maximum value pair. One of the most common usages of this is for audio volume, screen brightness, or for doing zoom.

How do you make a sliding UI in unity?

Create the UI Text (user interface) in unitySelect UI and pick the "Text" option. Position it in the right middle holding out + Shift keys change its text field modify its font size set overflow change. Right-click on the canvas and create a new UI slider. Select UI and pick the "Slider" option.


1 Answers

this is the best answer i found:

(posted as a comment by Jesper)

Make sure you selected Dynamic float from the OnValueChanged drop down list in the inspector

click here for the image

like image 64
dev_ter Avatar answered Oct 15 '22 21:10

dev_ter