Populate exposed interface on spawn is not working (compile error in blueprint)

What

Trying to create a “Widget Blueprint” and populating a “Expose on Spawn” interface results in a blueprint compile error.

Reproduce

  1. Create new project from Launcher (ThirdPerson Blueprint)
  2. Add new “Blueprint Interface” MyInterface
  3. Add new “Blueprint Widget”
  4. Create a variable in this widget of type MyInterface, tick as “Editable” and “Expose on spawn” (see image)
  5. In the ThirdPersonCharacter Blueprint on event BeginPlay add the following blueprint graph (see image)
  6. Click compile

Setting the interface on spawn generates the compile error, but setting it via the public setter is fine and working (see image)

Hello splitDEV,

I have a couple of questions for you that will help narrow down what issue it is that you are experiencing.

Quick questions:

  1. Could you elaborate on what it is exactly that you are trying to accomplish?
  2. If you are trying to apply the interface to a blueprint have you tried doing so via the Class Settings?

Of course.

  1. Basically I have pickups in my level which implement MyInterface. If the player picks them up I want to spawn a corresponding Widget (InventorySlot) in my hud. MyInterface has methods to retrieve the pickup name, inventory image and so on, so the spawned widget needs a reference to the item
  2. No, I’m not trying to apply the interface to a blueprint :slight_smile:

As you can see in the image, passing the interface in the “On spawn” pin generates the compile error, but setting the interface directly doesn’t. Both ways should behave the same way (as it does for other engine classes like Vector, Actors etc. - those behave in both ways the same and can be passed via the “on spawn” pin and direct set)

Hope this helps.

Instead of passing in a variable of the interface, in you apply the interface to the widget blueprint you will then be able to use that interface within that widget. I believe that this will accomplish the goals that you are trying to meet. I have link the documentation on interfaces. I hope that this information helps.

Link: https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/UsingInterfaces/index.html

I know how interfaces work, thanks :slight_smile:
I want to pass a reference to a class inheriting from MyInterface to another class on spawn. It is working if I set the interface via direct “setter”.
It is working for other classes and structs in blueprints (

).

Hello splitDEV,

I was able to reproduce this issue on our end. I have written up a report (UE-24222) and I have submitted it to the developers for further consideration. I will provide updates with any pertinent information as it becomes available. Thank you for your time and information.

Make it a great day