user2424967
user2424967

Reputation: 51

Unity Slider doesn't apply changes automatically

I've created custom Editor with Slider:

[CustomEditor(typeof(CylindricalCamera))]
public class CylindricalCameraEditor : Editor
{
    public override void OnInspectorGUI()
    {
        CylindricalCamera camera = (CylindricalCamera)target;
        camera._nearClipPlane = EditorGUILayout.Slider(camera._nearClipPlane, 0, 10);

In CylindricalCamera I am drawing a custom gizmo:

public class CylindricalCamera : MonoBehaviour
{
..
    void OnDrawGizmos()
    {
...

I want a gizmo in CylindricalCamera to be repainted every time I drag the slider. But in fact I have not only to drag the slider, but also to select and press Enter on the textbox near the Slider:

Custom slider

How could I force Slider to apply changes automatically, without pressing Enter?

I am using Unity 5.3.5 f1

Upvotes: 0

Views: 689

Answers (1)

user2424967
user2424967

Reputation: 51

Solved:

OnInspectorGUI()
{
...
if (GUI.changed) EditorUtility.SetDirty(target);
}

Upvotes: 2

Related Questions