Компонент Animation используется для воспроизведения анимации.
Вы можете назначать анимационные клипы на компонент Animation и управлять воспроизведением из вашего скрипта.
Смешивание анимаций, Добавление анимации, Миксинг анимаций, Слои и полный контроль над всеми аспектами воспроизведения анимации.
Для обзора скриптинга анимации в Unity пожалуйста прочтите это введение.
AnimationState может использоваться для изменения слоя анимации, изменения скорости воспроизведения, а также для прямого контроля над смешиванием и перемешиванием.
Анимация также поддерживает счетчики, так что вы можете сделать повторяющийся цикл всех AnimationStates как этот:
var anim: Animation;
function Start() { anim = GetComponent.<Animation>(); // Make all animations in this character play at half speed for (var state : AnimationState in anim) { state.speed = 0.5; } }
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { public Animation anim; void Start() { anim = GetComponent<Animation>(); foreach (AnimationState state in anim) { state.speed = 0.5F; } } }
See Also: Обзор скриптинга анимации в Unity here.
| animatePhysics | Когда включено, анимации будут выполняться в физическом цикле. Это полезно только в сочетании с кинематическими физическими телами. |
| clip | Анимация по-умолчанию. |
| cullingType | Контролирует отсечение данного компонента Animation. |
| isPlaying | Проигрываем ли мы какие-либо анимации? |
| localBounds | AABB of this Animation animation component in local space. |
| playAutomatically | Если анимационный клип по умолчанию (Animation.clip) автоматически начинает проигрываться при старте. |
| this[string] | Возвращает состояние анимации с именем name. |
| wrapMode | How should time beyond the playback range of the clip be treated? |
| AddClip | Добавляет clip в анимацию с именем newName. |
| Blend | Смешивает анимацию с именем animation в сторону targetWeight в течение следующих time секунд. |
| CrossFade | Fades the animation with name animation in over a period of time seconds and fades other animations out. |
| CrossFadeQueued | Плавный переход анимации происходит после того, как предыдущие анимации закончат проигрываться. |
| GetClipCount | Получить количество анимационных клипов назначенных этой анимации. |
| IsPlaying | Проигрывается ли анимация с именем name. |
| Play | Проигрывает анимацию без какого-либо смешивания.\n |
| PlayQueued | Воспроизведет анимацию после того, как завершится воспроизведение предыдущих анимаций. |
| RemoveClip | Удаляет анимационный клип из списка анимаций. |
| Rewind | Проигрывает анимацию с именем name. |
| Sample | Samples animations at the current state. |
| Stop | Останавливает все проигрываемые анимации, которые были запущены с этой анимацией. |
| enabled | Enabled Behaviours are Updated, disabled Behaviours are not. |
| isActiveAndEnabled | Has the Behaviour had enabled called. |
| gameObject | The game object this component is attached to. A component is always attached to a game object. |
| tag | Тег данного игрового объекта. |
| transform | The Transform attached to this GameObject (null if there is none attached). |
| hideFlags | Should the object be hidden, saved with the scene or modifiable by the user? |
| name | The name of the object. |
| BroadcastMessage | Вызывает метод названный methodName на каждом MonoBehaviour этого game object-а или любого из его потомков. |
| CompareTag | Помечен ли этот игровой объект тэгом tag? |
| GetComponent | Возвращает компонент типа type, если он прикреплен к игровому объекту и null, если не прикреплен. |
| GetComponentInChildren | Returns the component of Type type in the GameObject or any of its children using depth first search. |
| GetComponentInParent | Returns the component of Type type in the GameObject or any of its parents. |
| GetComponents | Returns all components of Type type in the GameObject. |
| GetComponentsInChildren | Returns all components of Type type in the GameObject or any of its children. |
| GetComponentsInParent | Returns all components of Type type in the GameObject or any of its parents. |
| SendMessage | Вызывает метод с именем methodName в каждом MonoBehaviour на этом объекте. |
| SendMessageUpwards | Вызывает на каждом MonoBehaviour в данном игровом объекте и на каждом предке скрипта метод с именем methodName. |
| GetInstanceID | Returns the instance id of the object. |
| ToString | Returns the name of the game object. |
| Destroy | Removes a gameobject, component or asset. |
| DestroyImmediate | Destroys the object obj immediately. You are strongly recommended to use Destroy instead. |
| DontDestroyOnLoad | Makes the object target not be destroyed automatically when loading a new scene. |
| FindObjectOfType | Returns the first active loaded object of Type type. |
| FindObjectsOfType | Returns a list of all active loaded objects of Type type. |
| Instantiate | Returns a copy of the object original. |
| bool | Does the object exist? |
| operator != | Compares if two objects refer to a different object. |
| operator == | Compares two object references to see if they refer to the same object. |