Timeline Animatable Property In Custom Inspector?

Hi All,

I have two scripts, one which displays the user properties in a custom inspector editor and another manages the properties - however these values are not displayed to the user. I’ve drawn up a simple version of my current setup below. I’m trying to the properties not shown to the user animatable on the timeline via the sliders which are shown to the user. However I can’t seem to get them to keyframe. Any ideas or tips to why it isn’t working? - In the example below- I want to animate selectedCategory on the timeline when the user changes the slider position.

Custom Inspector Editor:

[CustomEditor(typeof(LightingObjectControl))]
public class GDTF_LightingControlInspectorEditor : Editor
{
private LightingObjectControl lightingObjectControlTarget;
lightingObjectControlTarget.categoriesHolder.selectedCategory = (int) GUILayout.HorizontalSlider(lightingObjectControlTarget.categoriesHolder.selectedCategory, 0, 100);
}

Script To Manage Values:

[Serializable]
public class LightingObjectControl : MonoBehaviour
{
    // Editor Window Variables
    public CategoryHolder categoriesHolder;
    [Button("GenerateCategory")] //Button is part of ODIN.
    public void genCat(){
    CategoryHolder categoriesHolder = new CategoryHolder();
    categoriesHolder = 0;
    }
    [Serializable]
    public struct CategoryHolder
    {
        public Category[] Categories;
        public int selectedCategory;
    }
}

To allow keyframing it’s required to use GUILayout methods that take a SerializedProperty, or wrap them in a BeginProperty/EndProperty block - see the example here.

Is there any more information or help docs about getting custom fields to auto record onto a timeline? I’ve implemented what @seant_unity suggested, however by changing the slider it doesn’t add a keyframe.

//Get the SerialisedObject that contains the value - lightingObjectControlTarget.Fixture.dmxChart.dmxChannels[dmxChanNumber].value
SerializedObject objSer = lightingObjectControlTarget.getFixtureSO();
                SerializedProperty tempprop = objSer.FindProperty("dmxChart").FindPropertyRelative("dmxChannels").GetArrayElementAtIndex(dmxChanNumber).FindPropertyRelative("value");
                /
                EditorGUI.BeginProperty(EditorGUILayout.GetControlRect(), GUIContent.none, tempprop);
                EditorGUI.BeginChangeCheck();
               
                int newVal =
                        (int) GUILayout.HorizontalSlider(
                            tempprop.intValue, 0,
                            lightingObjectControlTarget.Fixture.dmxChart.dmxChannels[dmxChanNumber].maxValue);
                if (EditorGUI.EndChangeCheck())
                {
                    tempprop.intValue = newVal;
                }

                objSer.ApplyModifiedProperties();
               
                EditorGUI.EndProperty();