why

Add a SimpleAnimation component to your project that can animate 3D objects, but not UI objects.

Analysis of the

AnimatorCullingMode defaults to CullUpdateTransforms, which doesn’t animate the UI and makes it difficult for the configuration person to set this value every time.

To solve

So when the script is mounted, determine if the current object is UI, and if so, automatically change the AnimatorCullingMode value as follows:

    private void Reset()
    {
        if (m_Graph.IsValid())
            m_Graph.Destroy();
        
        m_Initialized = false;

        // For the UI, set cull to always play
        if(GetComponent<RectTransform>() ! =null) { m_CullingMode = AnimatorCullingMode.AlwaysAnimate; }}Copy the code