IntSlider callback function? [Editor Scripting]

I just got into Editor Scripting recently and I’m still getting a hold of all the basics. I wanted to know if the IntSlider (that we use to create a slider of integer values) has any methods or functions that can be used to get more functionality?

Something like the Slider class:
You have -maxValue, -minValue, -value, -onValueChanged (Callback executed when the value of the slider is changed)

These work during the “Play” mode.

I need to access this information while in the editor. Specifically: I need to access the onValueChanged (if it exists) of the IntSlider so I can assign a function for it to execute.

IntSlider Code:

totalRooms = EditorGUILayout.IntSlider(new GUIContent ("Total Rooms"), totalRooms, 0, 10);

Is there a way to achieve this for the inspector? Or something that can be created to solve this? If you can point me in the right direction, I’d be grateful.

78631-1.png
I’m using Unity 5.3.1f

Hi @ImFromTheFuture! I’d suggest the following:

EditorGUI.BeginChangeCheck();
totalRooms = EditorGUILayout.IntSlider(m_TotalRoomsLabel, totalRooms, 0, 10);
if (EditorGUI.EndChangeCheck())
{
    // invoke your changed event handler here
}

How about…

        int origTotalRooms = totalRooms;
        totalRooms = EditorGUILayout.IntSlider(new GUIContent ("Total Rooms"), totalRooms, 0, 10);

        if(origTotalRooms != totalRooms)
            Debug.Log("Oh it changed to " + totalRooms);

Remember this pattern. It is one of the most used tricks of OnGUI. And…it’s too straight forward that you should figure it out yourself.