void AddTrackMenu(object param) { KeyValuePair <Type, FEventAttribute> kvp = (KeyValuePair <Type, FEventAttribute>)param; Undo.RecordObjects(new UnityEngine.Object[] { _timeline, this }, "add Track"); FTrack track = (FTrack)typeof(FTimeline).GetMethod("AddTrack").MakeGenericMethod(kvp.Key).Invoke(_timeline, new object[] { SequenceEditor.GetViewRange() }); string evtName = track.gameObject.name; int nameStart = 0; int nameEnd = evtName.Length; if (nameEnd > 2 && evtName[0] == 'F' && char.IsUpper(evtName[1])) { nameStart = 1; } if (evtName.EndsWith("Event")) { nameEnd = evtName.Length - "Event".Length; } evtName = evtName.Substring(nameStart, nameEnd - nameStart); track.gameObject.name = ObjectNames.NicifyVariableName(evtName); if (!_timeline.Sequence.IsStopped) { track.Init(); } SequenceEditor.Refresh(); Undo.RegisterCreatedObjectUndo(track.gameObject, string.Empty); SequenceEditor.SelectExclusive(SequenceEditor.GetEditor <FEventEditor>(track.GetEvent(0))); }