Hello,
I’ve been trying to customize a TrackAsset’s name on creation.
As far as I can tell, there is no way to actually do that?
I checked Timeline’s source code to try and verify my assumption, and…
TimelineContextMenu calls “TimelineHelpers.CreateTrack((Type)trackItemType, …” with a null name argument.
TimelineHelpers.CreateTrack calls “var track = asset.CreateTrack(type, parent, name);”, and…
TimelineAsset.CreateTrack calls the following
var baseName = name;
if (string.IsNullOrEmpty(baseName))
{
baseName = type.Name;
#if UNITY_EDITOR
baseName = UnityEditor.ObjectNames.NicifyVariableName(baseName);
#endif
}
var trackName = baseName;
if (parent != null)
trackName = TimelineCreateUtilities.GenerateUniqueActorName(parent.subTracksObjects, baseName);
else
trackName = TimelineCreateUtilities.GenerateUniqueActorName(trackObjects, baseName);
It’s a shame that at no point neither of [DisplayName], [CreateAssetMenu] are used to determine the name, or any callbacks are made to let users author the name via script.
None of the scriptableobject calls seem to be useful for this, either. Awake/OnEnable/OnValidate don’t get called until later, and will reoccur more than once per the asset’s lifetime after creation.
Is there any way to rename the track via script without having to declare a contextmenu option manually?