Announcement

Collapse
No announcement yet.

Please add UPROPERTY(meta = (BindWidget)) support for UWidgetAnimation!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [FEATURE REQUEST] Please add UPROPERTY(meta = (BindWidget)) support for UWidgetAnimation!

    Still think it's a bit weird that we haven't got this.

    We can access UWidget children in C++ by declaring a pointer to the related type with UPROPERTY(meta = (BindWidget)) (which also forces the blueprintee to create said child). It would be *really* beneficial if we could do this with animations too, because otherwise we can't play animations from C++ directly. Currently, the workaround is to make a pointer with BlueprintReadWrite and then set the pointer in the widget.

    Sometimes, this pointer isn't set early enough too - because the earliest event we have is PreConstruct() (in some cases I need my animations set before this, and created an OnInitialized() event.

    Answerhub: https://answers.unrealengine.com/que...rt-for-uw.html

    #2
    I do agree. Another workaround for retrieving the UWidgetAnimation pointer is by iterating through all properties of the UUserWidget in C++ (e.g. using this in NativeConstruct), however NativeContruct() is called often (e.g. when adding this widget to a panel using AddChild) and the method is cumbersome.

    Some kind of UPROPERTY(meta = (BindWidgetAnimation)) would be helpful!
    Last edited by Roi Danton; 01-21-2018, 11:23 AM.
    Client side prediction with GameplayAbilitySystem | GameplayAbilitySystem at stackoverflow

    Comment


      #3
      Yeah I used to do things like that before I knew BindWidget existed, I'm going to look into adding this myself.

      Comment


        #4
        This is obviously far from ideal but this is what I use to get animations:

        Code:
        void UViewWidget::GetAnimations(TMap<FString, UWidgetAnimation*>& OutResults)
        {
            OutResults.Empty();
        
            UProperty* Property = GetClass()->PropertyLink;
            while (Property != nullptr)
            {
                if (Property->GetClass() == UObjectProperty::StaticClass())
                {
                    UObjectProperty* ObjectProperty = Cast<UObjectProperty>(Property);
        
                    if (ObjectProperty->PropertyClass == UWidgetAnimation::StaticClass())
                    {
                        UObject* Object = ObjectProperty->GetObjectPropertyValue_InContainer(this);
                        UWidgetAnimation* WidgetAnimation = Cast<UWidgetAnimation>(Object);
        
                        if (WidgetAnimation != nullptr)
                        {
                            FString Name = WidgetAnimation->GetMovieScene()->GetFName().ToString();
                            OutResults.Add(Name, WidgetAnimation);
                        }
                    }
                }
        
                Property = Property->PropertyLinkNext;
            }
        }
        George Rolfe.
        Technical Coordinator at Orbit Solutions Pty Ltd.

        Comment


          #5
          TheJamsh I've implemented this feature in my engine source. I'll make a pull request as soon as I can.

          The meta specifiers are BindAnimation and BindAnimationOptional.

          Cheers!

          Edit: https://github.com/EpicGames/UnrealEngine/pull/4930

          Cheers!
          Last edited by Sveitar; 08-04-2018, 02:04 AM.

          Comment

          Working...
          X