Search Unity

Bug Having a custom Transform inspector prevent recording transform modifications

Discussion in 'Timeline' started by khan-amil, Jul 11, 2022.

  1. khan-amil

    khan-amil

    Joined:
    Mar 29, 2012
    Posts:
    206
    Trying to play a bit with Timeline I ran into this issue while trying to animate a simple cube.
    The menu item "Add key" on the transform inspector is not displayed.
    Disabling our internal transform inspector made the option appear alright.

    I've looked in the editor code and it seems linked to this class, but as it's internal there's no way to use it.

    Any suggestion as to how to get this functionnality with a custom editor for transforms?
     
  2. julienb

    julienb

    Unity Technologies

    Joined:
    Sep 9, 2016
    Posts:
    177
    The menu entries associated to recording ("Add key", "Remove key", etc.) are added to menus for property fields. In your custom inspector, you will need to draw fields using the PropertyField method (in EditorGUI or EditorGUILayout).

    For example, here's a component with a custom inspector that uses the PropertyField method:
    Code (CSharp):
    1. public class TestComponent : MonoBehaviour
    2. {
    3.     public float value;
    4. }
    5.  
    6. [CustomEditor(typeof(TestComponent))]
    7. public class TestEditor : Editor
    8. {
    9.     public override void OnInspectorGUI()
    10.     {
    11.         SerializedProperty property = serializedObject.FindProperty(nameof(TestComponent.value));
    12.         EditorGUILayout.PropertyField(property);
    13.  
    14.         serializedObject.ApplyModifiedProperties();
    15.     }
    16. }
    When recording is enabled in Timeline, I get the recording menu entries if I right-click on a property:
    upload_2022-7-28_10-17-49.png
     
  3. khan-amil

    khan-amil

    Joined:
    Mar 29, 2012
    Posts:
    206
    Oh thanks, ours was using Vector3Field to dra the components but I'm sure I can get the same look/behaviour with propertyfield, just need to find the right names :)