AnyPortrait > Scripting > Animation
Animation
You can play the animation as a script.
If you enter the animation clip name as a parameter, it automatically switches to the root unit corresponding to it.
Multiple animation clips can be layered and played simultaneously.
You can give a fade effect when switching animation.
public apAnimPlayData Play(string animClipName, int layer,
apAnimPlayUnit.BLEND_METHOD blendMethod,
apAnimPlayManager.PLAY_OPTION playOption,
bool isAutoEndIfNotloop)
public apAnimPlayData Play(apAnimPlayData animPlayData, int layer, apAnimPlayUnit.BLEND_METHOD blendMethod, apAnimPlayManager.PLAY_OPTION playOption,
bool isAutoEndIfNotloop)
public apAnimPlayData PlayAt(string animClipName, int frame, int layer,
apAnimPlayUnit.BLEND_METHOD blendMethod,
apAnimPlayManager.PLAY_OPTION playOption,
bool isAutoEndIfNotloop)
public apAnimPlayData PlayAt(apAnimPlayData animPlayData, int frame, int layer, apAnimPlayUnit.BLEND_METHOD blendMethod, apAnimPlayManager.PLAY_OPTION playOption,
bool isAutoEndIfNotloop)
Description
Play the animation clip right away.
Playback starts without waiting time or fade effect.
The PlayAt function allows you to start playback at a specific frame. (Applicable from version 1.1.6)
Parameters
string animClipName : Name of Animation clip
apAnimPlayData animPlayData : Target animation data
int frame : The frame you want to start in the PlayAt function
int layer : Layer on which the animation plays (Default is 0)
apAnimPlayUnit.BLEND_METHOD blendMethod : Layered animation blend method (Default is BLEND_METHOD.Interpolation)
apAnimPlayManager.PLAY_OPTION playOption : How to end other animations that are playing (Default is PLAY_OPTION.StopSameLayer)
bool isAutoEndIfNotloop : Whether to terminate automatically if an animation clip has no Loop option (Default is false)
Return
apAnimPlayData : Data of animation clip being played (if no animation clip is requested, null)
public apAnimPlayData PlayQueued(string animClipName, int layer,
apAnimPlayUnit.BLEND_METHOD blendMethod,
bool isAutoEndIfNotloop)
public apAnimPlayData PlayQueued(apAnimPlayData animPlayData, int layer,
apAnimPlayUnit.BLEND_METHOD blendMethod,
bool isAutoEndIfNotloop)
public apAnimPlayData PlayQueuedAt(string animClipName, int frame, int layer,
apAnimPlayUnit.BLEND_METHOD blendMethod,
bool isAutoEndIfNotloop)
public apAnimPlayData PlayQueuedAt(apAnimPlayData animPlayData, int frame, int layer,
apAnimPlayUnit.BLEND_METHOD blendMethod,
bool isAutoEndIfNotloop)
Description
When the animation clip played on the currently requested layer ends, it plays immediately.
If no animation is playing on the layer, playback will begin immediately.
If the animation clip being played does not end with the Loop option, the function will not be processed and will be ignored.
The PlayQueuedAt function allows you to start playback at a specific frame. (Applicable from version 1.1.6)
Parameters
(Same as Play(), PlayAt() except PLAY_OPTION playOption)
Return
apAnimPlayData : Data of animation clip being played (If the requested animation clip does not exist or is Loop, null)
public apAnimPlayData CrossFade(string animClipName, float fadeTime, int layer,
apAnimPlayUnit.BLEND_METHOD blendMethod,
apAnimPlayManager.PLAY_OPTION playOption,
bool isAutoEndIfNotloop)
public apAnimPlayData CrossFade(apAnimPlayData animPlayData, float fadeTime, int layer,
apAnimPlayUnit.BLEND_METHOD blendMethod,
apAnimPlayManager.PLAY_OPTION playOption,
bool isAutoEndIfNotloop)
public apAnimPlayData CrossFadeAt(string animClipName, int frame, float fadeTime, int layer,
apAnimPlayUnit.BLEND_METHOD blendMethod,
apAnimPlayManager.PLAY_OPTION playOption,
bool isAutoEndIfNotloop)
public apAnimPlayData CrossFadeAt(apAnimPlayData animPlayData, int frame, float fadeTime, int layer,
apAnimPlayUnit.BLEND_METHOD blendMethod,
apAnimPlayManager.PLAY_OPTION playOption,
bool isAutoEndIfNotloop)
Description
Animation clips playback including fade effects.
It is similar to the Play function, but with a fade effect as fadeTime, it starts slowly and naturally.
The CrossFadeAt function allows you to start playback at a specific frame. (Applicable from version 1.1.6)
Parameters
float fadeTime : The time at which the animated smoothly changing fade effect is applied (Default is 0.3f)
(The rest is the same as the Play(), PlayAt())
Return
apAnimPlayData : Data of animation clip being played (if no animation clip is requested, null)
public apAnimPlayData CrossFadeQueued(string animClipName, float fadeTime, int layer,
apAnimPlayUnit.BLEND_METHOD blendMethod,
bool isAutoEndIfNotloop)
public apAnimPlayData CrossFadeQueued(apAnimPlayData animPlayData, float fadeTime, int layer,
apAnimPlayUnit.BLEND_METHOD blendMethod,
bool isAutoEndIfNotloop)
public apAnimPlayData CrossFadeQueuedAt(string animClipName, int frame, float fadeTime, int layer,
apAnimPlayUnit.BLEND_METHOD blendMethod,
bool isAutoEndIfNotloop)
public apAnimPlayData CrossFadeQueuedAt(apAnimPlayData animPlayData, int frame, float fadeTime, int layer,
apAnimPlayUnit.BLEND_METHOD blendMethod,
bool isAutoEndIfNotloop)
Description
As with PlayQueued, when the animation being played ends, it plays continuously.
The fade effect is added by fadeTime based on the end time and playback begins.
The CrossFadeAt function allows you to start playback at a specific frame. (Applicable from version 1.1.6)
Parameters
(Same as CrossFade(), CrossFadeAt() except PLAY_OPTION playOption)
Return
apAnimPlayData : Data of animation clip being played (If the requested animation clip does not exist or is Loop, null)
public void StopLayer(int layer, float fadeTime)
Description
Stop all animations on the requested layer.
Parameters
int layer : Layer to be stopped
float fadeTime : Time at which the animation ends smoothly by fading (Default is 0)
public void StopAll(float fadeTime)
Description
Stop all animations.
Parameters
float fadeTime : Time at which the animation ends smoothly by fading (Default is 0)
public void PauseLayer(int layer)
Description
Pause all animations in the requested layer.
Parameters
int layer : Layer to be paused
public void PauseAll()
Description
Pause all animations.
public void ResumeLayer(int layer)
Description
Plays the paused animations of the requested layer again.
Parameters
int layer : Layer to be resumed
public void ResumeAll()
Description
Plays all paused animations.
public bool IsPlaying(string animClipName)
Description
Queries if the animation clip you requested is playing.
Parameters
string animClipName : Target animation clip name
Return
bool : Returns true if the animation is playing (returns false if it is not playing or is not present)
public apAnimPlayManager PlayManager
Description
The manager that plays the animation.
Controls playback, stop, etc. from inside.
You can refer to the animated clip information that is baked.
public List<apAnimPlayData> PlayDataList : List containing animated clip information
public void RegistAnimationEventListener(MonoBehaviour listenerObject)
Description
Registers a listener to receive animation events.
For more information on how to create and invoke animation events, see the related page.
Parameters
MonoBehaviour listenerObject : The MonoBehaviour object from which the animation event will be invoked
public void SetAnimationSpeed(string animClipName, float speed)
public void SetAnimationSpeed(float speed)
Description
Sets the playback speed of the animation.
The default value is 1.0f, and you can also set a negative number.
Like other functions, it does not work when using mecanim.
If you do not specify animClipName, sets the speed of all animations.
(This function applies from version 1.1.0.)
Parameters
string animClipName : The name of the animation clip for which you want to set the speed. Target all animation clips when not set
float speed : Playback speed ratio. The default is 1.0f
public void ResetAnimationSpeed()
Description
Reverts the playback speed of all animations to their default values.
public List<apAnimPlayData> AnimationPlayDataList
Description
Returns a list of apAnimPlayData with playback information for the animation.
You can see the playable animation data directly.
(This property applies from version 1.1.2.)
Return
List<apAnimPlayData> : A list of playable apAnimPlayData
public apAnimPlayData GetAnimationPlayData(string animClipName)
Description
Queries the apAnimPlayData object with animation playback information by name.
(This function applies from version 1.1.2.)
Parameters
string animClipName : Target animation clip name
Return
apAnimPlayData : A playable apAnimPlayData object. Return null if not
public apAnimPlayData.AnimationPlaybackStatus GetAnimationPlaybackStatus(string animClipName)
Description
Get the playback status of the animation by the name.
The result value of "None, Playing, Paused, Ended" is returned in Enum format.
Provides more granular state values than the IsPlaying () function.
(This function applies from version 1.1.2.)
Parameters
string animClipName : Target animation clip name
Return
apAnimPlayData.AnimationPlaybackStatus : The playback state of the animation
< Blend Method and Play Option >
The values of the Blend Method and Play Option variable, which are included in the playback functions, have the following meanings.
apAnimPlayUnit.BLEND_METHOD blendMethod : Layered animation blend method
BLEND_METHOD.Interpolation : Merges in an overwrite interpolation compared to the animation on the lower layer.
BLEND_METHOD.Additive : Add and merge values to animations in lower layers.
apAnimPlayManager.PLAY_OPTION playOption : How to end another animation that is playing
PLAY_OPTION.StopSameLayer : Stop only the animation of the requested layer.
PLAY_OPTION.StopAllLayers : Stop all animations, including other layers.
< apAnimPlayData >
The class that is returned when the animation play function is called.
apAnimPlayData has animation playback information.
You can control the speed using the function of the returned apAnimPlayData instance.
Ex) portrait.Play("Idle").SetSpeed(2);
public void SetSpeed(float speed)
: Speed is controlled by speed. The default value is 1.0f, which can be negative.
public AnimationPlaybackStatus PlaybackStatus
: Returns the current playing state. The playback status has the following values.
- AnimationPlaybackStatus.None : The data is invalid or is not currently playing.
- AnimationPlaybackStatus.Playing : It is Playing.
- AnimationPlaybackStatus.Paused : It has been played but is currently paused.
- AnimationPlaybackStatus.Ended : When it is not a loop animation, it is played until the last frame.
public string Name
: The name of the animation clip.