public void SetKeyframeValue(float value, int row, int sample) { Dopesheet.DsKeyframe keyframe = Clip.GetKeyframe(row, sample); if (keyframe == null) { keyframe = Clip.GetSelectedKeyframe(row, sample); } if (keyframe == null) { Dopesheet.DsRow dopesheetRow = Clip.Rows[row]; AddKeyframe(value, row, sample); dopesheetRow = dopesheetRow.Parent; while (dopesheetRow != null) { AddKeyframe(0, dopesheetRow.Index, sample); dopesheetRow = dopesheetRow.Parent; } } else { keyframe.Value = value; if (m_raiseCurveModified) { Clip.RaiseCurveModified(keyframe.Row.Index); } } }
private void OnBoxSelection(Vector2Int min, Vector2Int max) { m_pointer.IsDragInProgress = false; Dopesheet.DsAnimationClip clip = Clip; int rows = clip.VisibleRowsCount; int cols = clip.ColsCount; min.y = Mathf.Clamp(min.y, 0, rows); //min.x = Mathf.Clamp(min.x, 0, cols - 1); max.y = Mathf.Clamp(max.y, 0, rows - 1); //max.x = Mathf.Clamp(max.x, 0, cols - 1); Dopesheet.DsRow minRow = clip.GetRowByVisibleIndex(min.y); if (minRow == null) { return; } min.y = minRow.Index; Dopesheet.DsRow maxRow = clip.GetRowByVisibleIndex(max.y); max.y = maxRow.Index; if (maxRow.Children != null) { max.y += maxRow.Children.Count; } Select(min, max); }
private bool TryGetKeyframeWithinRange(Vector2Int coord, int maxRange, out Vector2Int result) { result = coord; int range = 0; int row = coord.y; int col = coord.x; Dopesheet.DsRow dopesheetRow = Clip.GetRowByVisibleIndex(row); if (dopesheetRow != null) { row = dopesheetRow.Index; while (range <= maxRange) { if (Clip.HasKeyframe(row, col - range)) { result = new Vector2Int(col - range, row); return(true); } if (Clip.HasKeyframe(row, col + range)) { result = new Vector2Int(col + range, row); return(true); } range++; } } return(false); }
public void AddRow(bool isVisible, bool isNew, int parentRowIndex, float initialValue, AnimationCurve curve) { Dopesheet.DsRow row = Clip.AddRow(isVisible, parentRowIndex, initialValue, curve); row.Curve = curve; if (isNew) { Dopesheet.DsKeyframe kf0 = new Dopesheet.DsKeyframe(row, 0, initialValue); Dopesheet.DsKeyframe kf1 = new Dopesheet.DsKeyframe(row, Clip.ColsCount - 1, initialValue); Clip.AddKeyframes(kf0, kf1); row.RefreshCurve(Clip.FrameRate); } if (isVisible) { VisibleRowsCount++; } }
public void RemoveSelectedKeyframes() { BeginRefresh(); List <Dopesheet.DsKeyframe> keyframesList = Clip.SelectedKeyframes.ToList(); HashSet <int> keyframesHs = new HashSet <int>(keyframesList.Select(kf => kf.Row.Index * Clip.ColsCount + kf.Col)); List <Dopesheet.DsKeyframe> notRemovedKeyframesList = new List <Dopesheet.DsKeyframe>(); for (int i = keyframesList.Count - 1; i >= 0; --i) { Dopesheet.DsKeyframe kf = keyframesList[i]; if (kf.Row.Children != null) { for (int j = 0; j < kf.Row.Children.Count; ++j) { Dopesheet.DsRow childRow = kf.Row.Children[j]; Dopesheet.DsKeyframe childKf = Clip.GetKeyframe(childRow.Index, kf.Col); if (childKf != null && !keyframesHs.Contains(childKf.Row.Index * Clip.ColsCount + childKf.Col)) { keyframesList.RemoveAt(i); notRemovedKeyframesList.Add(kf); break; } } } } if (notRemovedKeyframesList.Count > 0) { Dopesheet.DsKeyframe topRowKeyframe = keyframesList.Where(kf => kf.Row.Index == 0).FirstOrDefault(); if (topRowKeyframe != null && !notRemovedKeyframesList.Contains(topRowKeyframe)) { notRemovedKeyframesList.Add(topRowKeyframe); keyframesList.Remove(topRowKeyframe); } Clip.UnselectKeyframes(notRemovedKeyframesList.ToArray()); } Clip.RemoveKeyframes(true, keyframesList.ToArray()); Clip.Refresh(false, true, true); RenderGraphics(); }
private void AddKeyframe(float value, int row, int sample) { if (sample < 0 || row < 0) { return; } Dopesheet.DsRow dopesheetRow = Clip.Rows[row]; Dopesheet.DsKeyframe newKeyframe = new Dopesheet.DsKeyframe(dopesheetRow, sample, value); Clip.ResizeClip(new[] { newKeyframe }); if (!Clip.HasKeyframe(row, sample)) { Clip.AddKeyframes(newKeyframe); } if (m_raiseCurveModified) { Clip.RefreshCurve(row); } m_renderGraphics = true; }
public void RemoveKeyframes(int rowIndex) { Dopesheet.DsRow row = Clip.Rows[rowIndex]; Clip.RemoveKeyframes(true, row.Keyframes.ToArray()); Clip.RemoveKeyframes(true, row.SelectedKeyframes.ToArray()); }