x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

UMG, overriding of UsingWidget.Tick

Hello!

UserWidget.Tick is not virtual, could I somehow override Tick in my derived class?

Dima.

Product Version: Not Selected
Tags:
more ▼

asked Oct 08 '14 at 03:38 AM in C++ Programming

avatar image

es
116 5 6 9

avatar image AustinK Jan 23 '15 at 06:19 AM

I think it's wierd that the staff hasn't commented on this yet. I'm noticing that in the head file it even says

 /**
      * Ticks this widget.  Override in derived classes, but always call the parent implementation.
      *
      * @param  MyGeometry The space allotted for this widget
      * @param  InDeltaTime  Real time passed since last tick
      */

There is no way to actually override it...

avatar image DarthB Mar 15 '15 at 05:10 PM
avatar image Elringus May 13 '15 at 01:18 PM

But in 4.8 its now throwing a warning C4996: 'UUserWidget::Tick_Implementation': Use NativeTick Please update your code to the new API before upgrading to the next release, otherwise your project will no longer compile. But the NativeTick is still not virtual! I have no idea what they are doing...

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

.h

 virtual void NativeTick(const FGeometry& MyGeometry, float DeltaTime) override;


.cpp

 void UMainMenuWidget::NativeTick(const FGeometry& MyGeometry, float DeltaTime)
 {
     Super::NativeTick(MyGeometry, DeltaTime);
 
         // Your code goes here
 }
more ▼

answered Jul 21 '15 at 05:55 PM

avatar image

Sveitar
1k 8 24 26

avatar image BoteRock Sep 13 '17 at 03:48 PM

It may be better to leave the c++ code above the Super::NativeTick call, because it calls the blueprint Tick, and if it relies on things set by c++ the variables may not be up to date.

avatar image MichaelWion Feb 09 '19 at 10:07 AM

I find it best practice to always call Super::NativeTick (or any overrided virtual method, for that matter). If you need something done in C++ before the blueprint, simply place the code before the call. You could also have bool bReady in your class definition, and then:

 void UMyWidget::NativeTick(const FGeometry& MyGeometry, float DeltaTime) {
     Super::NativeTick(MyGeometry, DeltaTime);
     if(!bReady)
         return;
     // Do whatever
 }
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question