Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


MoveKey(int, Keyframe)

Moves the key at index to /key.time/ and /key.value/.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
public int MoveKey(int index, Keyframe key)

Parameters

index

The index of the key to move.

The keyframe containing the new time and value.

Returns

Type

Description

intThe index of the keyframe after it is moved.

Remarks

This method removes the keyframe at
index
and inserts the updated
key
at the correctly sorted position in AnimationCurve.keys.
Use this method to move a keyframe in two dimensions: time and value.
To use this method as intended, use AnimationCurve.keys to acquire the keyframe, modify the value and/or time, then invoke this method with the updated keyframe. If you use this method with a different keyframe, this method replaces the keyframe with a new one.
AnimationCurve does not support two keys with the same time. If /key.time/ is the same as another keyframe,
key
is reinserted at the time of the keyframe at
index
. This cancels the move operation in the time dimension and keeps the modification in the value dimension.