keywords: [UE4]Get Widget Animation in C++

keywords:C++操作控制UMG动画、Widget Animation

示例代码:

void UMyMenuWidget::AssignAnimations()
{
    UProperty* prop = GetClass()->PropertyLink;

    // Run through all properties of this class to find any widget animations
    while( prop != nullptr  )
    {
        // Only interested in object properties
        if( prop->GetClass() == UObjectProperty::StaticClass() )
        {
            UObjectProperty* objectProp = Cast<UObjectProperty>(prop);

            // Only want the properties that are widget animations
            if( objectProp->PropertyClass == UWidgetAnimation::StaticClass() )
            {
                UObject* object = objectProp->GetObjectPropertyValue_InContainer( this );

                UWidgetAnimation* widgetAnim = Cast<UWidgetAnimation>(object);

                if( widgetAnim != nullptr )
                {
                    // DO SOMETHING TO STORE OFF THE ANIM PTR HERE!
                    // E.g. add to a TArray of some struct that holds info for each anim
                }
            }
        }

        prop = prop->PropertyLinkNext;
    }
}

参考自:Get Widget Animation in C++
https://answers.unrealengine.com/questions/427948/get-widget-animation-in-c.html


飞蛾扑火时,一定是极快乐幸福的。----三毛《撒哈拉的故事》