What's the magic command for opening a UMG blueprint from c++? I have a simple UMG menu defined and re-parented to a c++ class derived from UUserWidget. But I can't figure out how to open it.
Announcement
Collapse
No announcement yet.
Opening a UMG blueprint menu from c++
Collapse
X
-
Yes, YourCppClass is the template argument, you use your C++ base class there. The reference is the class to create, it's expecting a UClass*, so you've got to some how locate the class you want to spawn. I've never used FClassFinder. I always use TSubClassOf<Blah> MyClass; as a Uproperty in my class and expose it in a blueprint so that it's something I hookup in a blueprint asset, instead of something I hard code in a C++ file.
Comment
-
An Alternative
Dear Whammy,
You could also just send a request from C++ to Blueprints, and let Blueprints handle it
I call these CPP Requests, which I first invented while trying to work with Hourence's Solus Item system without having to rewrite the system in C++.
With CPP Requests, the flow is reversed, and you are actually asking Blueprints to do something from C++!
Code:UFUNCTION(BlueprintImplementableEvent, Category="Joy UMG", meta=(FriendlyName = "Joy Mech ~ CPP Request ~ Open Mesh Editor")) virtual void CPPRequest_OpenMeshEditor(AJoySMA* JSMA);
You still get to make this event happen whenever you want, via your code calculations and C++ class structures and work flow, but you still get to use all the convenient UMG nodes in BP!
In my opinion you get best of both worlds,
1. Power to control when the UI gets loaded based on C++ calculations and conditions,
2. Ease of use of UMG BP nodes
Rama
PS: I was just doing this a lot today, so it is a proven workflow for me, that I actually really like
It is one of the core features of my project that is the demo for the book I am writing on UE4 C++Last edited by Rama; 11-21-2014, 10:57 PM.UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin
♥ Rama
Comment
-
I did much the same thing Nick Darnell described above just the other day over here. I created a new UMG menu widget BP, added a reference to that widget type to my player controller BP (which is a subclass of my custom C++ player controller), and then created the widget in my custom C++ player controller.Contact: enlight in #unrealengine IRC channel on Freenode, or @macagonator on Twitter
Comment
Comment