private void DoOffsetManipulator() { if (base.get_targets().Length <= 1) { if (!(base.timelineWindow == null) && base.timelineWindow.state != null && !(base.timelineWindow.state.currentDirector == null)) { AnimationTrack animationTrack = base.get_target() as AnimationTrack; if (animationTrack != null && animationTrack.applyOffsets && this.m_OffsetEditMode != TimelineAnimationUtilities.OffsetEditMode.None) { GameObject sceneGameObject = TimelineUtility.GetSceneGameObject(base.timelineWindow.state.currentDirector, animationTrack); Transform transform = (!(sceneGameObject != null)) ? null : sceneGameObject.get_transform(); TimelineAnimationUtilities.RigidTransform trackOffsets = TimelineAnimationUtilities.GetTrackOffsets(animationTrack, transform); EditorGUI.BeginChangeCheck(); TimelineAnimationUtilities.OffsetEditMode offsetEditMode = this.m_OffsetEditMode; if (offsetEditMode != TimelineAnimationUtilities.OffsetEditMode.Translation) { if (offsetEditMode == TimelineAnimationUtilities.OffsetEditMode.Rotation) { trackOffsets.rotation = Handles.RotationHandle(trackOffsets.rotation, trackOffsets.position); } } else { trackOffsets.position = Handles.PositionHandle(trackOffsets.position, (Tools.get_pivotRotation() != 1) ? trackOffsets.rotation : Quaternion.get_identity()); } if (EditorGUI.EndChangeCheck()) { TimelineAnimationUtilities.UpdateTrackOffset(animationTrack, transform, trackOffsets); this.Evaluate(); base.Repaint(); } } } } }
void DoOffsetManipulator() { if (targets.Length > 1) //do not edit the track offset on a multiple selection { return; } if (timelineWindow == null || timelineWindow.state == null || timelineWindow.state.editSequence.director == null) { return; } AnimationTrack animationTrack = target as AnimationTrack; if (animationTrack != null && (animationTrack.trackOffset == TrackOffset.ApplyTransformOffsets) && m_OffsetEditMode != TimelineAnimationUtilities.OffsetEditMode.None) { var boundObject = TimelineUtility.GetSceneGameObject(timelineWindow.state.editSequence.director, animationTrack); var boundObjectTransform = boundObject != null ? boundObject.transform : null; var offsets = TimelineAnimationUtilities.GetTrackOffsets(animationTrack, boundObjectTransform); EditorGUI.BeginChangeCheck(); switch (m_OffsetEditMode) { case TimelineAnimationUtilities.OffsetEditMode.Translation: offsets.position = Handles.PositionHandle(offsets.position, (Tools.pivotRotation == PivotRotation.Global) ? Quaternion.identity : offsets.rotation); break; case TimelineAnimationUtilities.OffsetEditMode.Rotation: offsets.rotation = Handles.RotationHandle(offsets.rotation, offsets.position); break; } if (EditorGUI.EndChangeCheck()) { UndoExtensions.RegisterTrack(animationTrack, L10n.Tr("Inspector")); TimelineAnimationUtilities.UpdateTrackOffset(animationTrack, boundObjectTransform, offsets); Evaluate(); Repaint(); } } }