How to make a SerializedProperty with a list of values?


I am trying to make a custom editor with a slider, that only shows specific values.
e.g.: 5, 7,8,11,321,512.

From it looks like that

public static void Slider(SerializedProperty property, float leftValue, float rightValue, params GUILayoutOption[] options);

is the function to use. But I do not find out how to make the SerializedProperty.

If you want to have a custom Slider, which shows an Array of integer Values (5, 7,8,11,321,512)
you need to do something like this:


Editor Script

using UnityEngine;
using UnityEditor;
public class ValueEditor : Editor
    SerializedProperty intRange;
    float select = 0;   
    public override void OnInspectorGUI()
        intRange = serializedObject.FindProperty("intRange");
        select = CustomIntSlider(intRange,select);
    float CustomIntSlider(SerializedProperty property,float selected){
        EditorGUILayout.LabelField("My Slider",GUILayout.Width(100));
        selected = GUILayout.HorizontalSlider(Mathf.Round(selected),0,property.arraySize-1);
        return selected;


using System.Collections.Generic;
using UnityEngine;
public class Value : MonoBehaviour
    public List<int> intRange = new List<int>(){5,7,8,11,321,512};