Unity 6.3
0 онлайн 58 гостей 3 в системе
Вход

Animator.StringToHash

Declaration

public static int StringToHash(string name);

Параметры

Параметр Описание
имя Строка для преобразования в id.

Возвращаемое значение

инт Хеш входной строки.

Описание

Создает параметр id из строки.

Этот метод использует CRC32 для создания id из строки. Используйте созданный id для оптимизации назначения и получения параметров. Созданный id действителен до тех пор, пока вводная строка не изменится. Это означает, что созданный id сохраняется между сессиями и может быть использован для сетевых связей.

using UnityEngine;

// Press the space key in Play Mode to switch to the Bounce state.

[RequireComponent(typeof(Animator))]
public class AnimatorPlayExample : MonoBehaviour
{
    // The Animator component on the GameObject this script is attached to.
    Animator m_Animator;

    // Cache the hash of the bounce state.
    int m_BounceStateHash;

    void Start()
    {
        m_Animator = GetComponent<Animator>();
        m_BounceStateHash = Animator.StringToHash("Base Layer.Bounce");
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            // Play Bounce but start at a quarter of the way through
            m_Animator.Play(m_BounceStateHash, 0, 0.25f);
        }
    }
}