AnimatorCullingMode
перечисление
Описание
Режим отбора для Animator.
Чтобы указать, как Animator управляет анимациями объектов, которые могут быть не видны, задайте значение из этого перечисления в Animator.cullingMode.
using UnityEngine; // This example demonstrates how to change the culling mode of an Animator component based on the distance between the // object and the main camera. This can be useful to optimize performance by disabling animations when objects are far // away from the camera. [RequireComponent(typeof(Animator))] public class AnimatorCullingModeExample : MonoBehaviour { // The distance at which the Animator culling mode is set to CullCompletely. public float distanceToEnableCulling = 100.0f; Animator m_Animator; void Start() { m_Animator = GetComponent<Animator>(); m_Animator.cullingMode = AnimatorCullingMode.AlwaysAnimate; if (Camera.main == null) { Debug.LogError("There is no main camera in the scene."); } } void Update() { if (Camera.main == null) { return; } // Check the distance between the object and the camera. if (Vector3.Distance(transform.position, Camera.main.transform.position) < distanceToEnableCulling) { m_Animator.cullingMode = AnimatorCullingMode.AlwaysAnimate; } else { m_Animator.cullingMode = AnimatorCullingMode.CullCompletely; } } }
Дополнительные ресурсы: ,Animator.cullingMode,.
Свойства
| Свойство | Описание |
|---|---|
| AlwaysAnimate | Всегда анимировать весь персонаж. Объект анимирован даже когда он вне экрана. |
| CullUpdateTransforms | Ретаргетинг, IK и запись преобразований отключены, когда рендереры не видны. |
| CullCompletely | Animation полностью отключен, когда рендереры не видны. |