Search Unity

Question How to have Editable Track Name (inspector field) ?

Discussion in 'Timeline' started by Immu, Jan 6, 2023.

  1. Immu

    Immu

    Joined:
    Jun 18, 2013
    Posts:
    240
    Hello there,
    I've been creating several custom tracks and they work well for the most part.
    But when in inspector, upon selecting the track, I can't see editable track field name.

    upload_2023-1-6_11-44-38.png
    upload_2023-1-6_11-45-4.png

    Whereas, as you can see, for animation and audio, we do have editable name for the track
    upload_2023-1-6_11-41-55.png

    upload_2023-1-6_11-42-30.png

    This is a huge problem for me, as I use those track names for various auto-assignments/spawns.
    I've been digging in the API but can't find how those editable fields shows up in these inspectors :(

    Thanks for your help!
     

    Attached Files:

  2. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
  3. Immu

    Immu

    Joined:
    Jun 18, 2013
    Posts:
    240
    Indeed, in debug mode, we can't see editable text fields.
    But all my inspectors in the screenshots are in normal mode. Hence why I can compare, with the other two (animation and audio tracks) which does have, in their case, editable text field.

    @DavidGeoffroy any idea ? :/
     
  4. Yuchen_Chang

    Yuchen_Chang

    Joined:
    Apr 24, 2020
    Posts:
    127
    I found out that you have to define the Editor like below by yourself to give the same look as built-in tracks. (The input name field will show up if defined)

    Code (CSharp):
    1. [CustomEditor(typeof(MyCustomTrack))]
    2. class MyCustomTrackInspector : TrackAssetInspector { }
    you will have to use asmref to access TrackAssetInspector, because it is an internal class in Timeline package.

    A weird thing is that TrackAssetInspector should be the default Editor for all Tracks, but it isn't. (editorForChildClasses is true ↓)
    Code (CSharp):
    1.     [CustomEditor(typeof(TrackAsset), editorForChildClasses = true, isFallback = true)]
    2.     [CanEditMultipleObjects]
    3.     class TrackAssetInspector : Editor
    4.     {
    5.         // implementation...