Cast UClass to UUserWidget
i wanna write a C++ function library, it contain a function called CreateAndAddWidget
i cannot cast uclass to uuserwidget, so i cannot call AddToViewport. Could you help me ?Or show me a new way?
asked Jul 11 '17 at 02:08 AM in C++ Programming
Hey ! Your solution is totally wrong. You try to use template, but your function isnt templatized, uclass return is useless, return UUserWidget instead of UClass.. GetClass isnt needed..
Of course you can use template class function, but for this first read how templates works: https://www.tutorialspoint.com/cplusplus/cpp_templates.htm
Anyway i highly recommend to do this in way:
In this case you dont need cast and every widget is based on uuserwidget, so safe to give back uuserwidget :) Cheera
This may help you.
answered Jul 17 '17 at 10:20 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here