Force users to set variable from Details Panel.
Do not allow BlueprintReadWrite, if it must be set in graph then only a custom Kismet K2Node can do that filtering.
Announcement
Collapse
No announcement yet.
Referencing Blueprint Interfaces as UPROPERTY
Collapse
X
-
cygon repliedThank you very much!
That totally fixes the pain on the Blueprint side for me
Erm, correction, it seems to do nothing.
Code:/// Dialog to which input is currently being sent (can be null if no dialog is active) public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient, Category="UI") TScriptInterface<IButtonControllableDialog> ActiveDialog; /// Dialog to which input is currently being sent (can be null if no dialog is active) public: UPROPERTY( EditAnywhere, BlueprintReadWrite, Transient, Category="UI", meta = (AllowedClasses = "ButtonControllableDialog") ) UObject *SameWithBCD; /// Dialog to which input is currently being sent (can be null if no dialog is active) public: UPROPERTY( EditAnywhere, BlueprintReadWrite, Transient, Category="UI", meta = (AllowedClasses = "Gooblefoob") ) UObject *SameWithGooblefoob; /// Dialog to which input is currently being sent (can be null if no dialog is active) public: UPROPERTY( EditAnywhere, BlueprintReadWrite, Transient, Category="UI", meta = (AllowedClasses = "IButtonControllableDialog") ) UObject *SameWithIBCD; /// Dialog to which input is currently being sent (can be null if no dialog is active) public: UPROPERTY( EditAnywhere, BlueprintReadWrite, Transient, Category="UI", meta = (AllowedClasses = "UButtonControllableDialog") ) UObject *SameWithUBCD;
According to the docs it should at least affect the asset picker, but that doesn't seem to happen either.
https://wiki.unrealengine.com/UPROPERTY#AllowedClasses
So unless I'm missing something, I'm still at square one.Last edited by cygon; 10-26-2019, 02:51 PM.
Leave a comment:
-
BrUnO XaVIeR repliedUPROPERTY ( EditAnywhere, meta = (AllowedClasses="ButtonControllableDialog") )
UObject *ActiveDialog;
Leave a comment:
-
cygon repliedB) I do not want to cast anything and know there is no need to. All blueprint interface calls are by name (and I can see exactly how someone at Epic attempted to design a system for actual method calls in UE C++, failed and clobbered stuff together to arrive at the current state of things)
I want some semblance of type safety. I'm given two choices in my PlayerController:
Choice 1:
Code:/// Dialog to which input is currently being sent (can be null if no dialog is active) public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient, Category="UI") TScriptInterface<IButtonControllableDialog> ActiveDialog;
Choice 2:
Code:/// Dialog to which input is currently being sent (can be null if no dialog is active) public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient, Category="UI") UObject *ActiveDialog;
Last edited by cygon; 10-26-2019, 06:25 AM.
Leave a comment:
-
cygon repliedPlease read my original post.
A) I have a C++ class (let's say, a custom PlayerController) that has a UPROPERTY:
Now I thought my C++ player controller could be given a property like this:
Code:/// Dialog to which input is currently being sent (can be null if no dialog is active) public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient, Category="UI") TScriptInterface<IButtonControllableDialog> ActiveDialog;
Leave a comment:
-
BrUnO XaVIeR repliedInterface implemented to Blueprints using the Editor is an UInterface sub object attached to the Blueprint.
Casting will never work like that, this is why you get null.
Also there's no reason to cast anything to call interface methods from Blueprint and Interfaces cannot have properties so I have no idea why you even want to cast them.
Leave a comment:
-
cygon repliedSo this is really the state of things?
Either expose properties as (UObject *) and lose any indication as to which interface type is supposed to be assigned to them,
or expose properties as (UMyBlueprintInterface *) and lose the ability to ever implement the interface using Blueprints?
Leave a comment:
-
cygon started a topic Referencing Blueprint Interfaces as UPROPERTYReferencing Blueprint Interfaces as UPROPERTY
I have created a Blueprint interface in C++, like this:
Code:/// Implemented by dialogs and menus that can be controlled with keyboard and gamepad class NUCLEX_API IButtonControllableDialog { GENERATED_BODY() /// Accepts the currently selected dialog option public: UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, Category="UI") void Accept(); /// Cancels the currently selected dialog public: UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, Category="UI") void Cancel(); // ... };
Now I thought my C++ player controller could be given a property like this:
Code:/// Dialog to which input is currently being sent (can be null if no dialog is active) public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient, Category="UI") TScriptInterface<IButtonControllableDialog> ActiveDialog;
Code:this->ActiveDialog->GetClass()->ImplementsInterface(UButtonControllableDialog::StaticClass())
But if I assign the ActiveDialog property in Blueprint, even though it compiles fine, it instead assigns NULL.
It works if I change the property type to UObject *, but that would totally remove any type information. Blueprinters could assign literally anything :-/
Funnily, if I create a class with an IButtonControllableDialog property in Blueprint and nativize it, the same TScriptInterface<IButtonControllableDialog> property is generated.
How can I create a property of type IButtonControllableDialog that works for both C++ and Blueprint classes?Tags: None
Leave a comment: