Skip to content

Added Interface Blueprint functionallity#668

Merged
OlssonDev merged 4 commits intoUnrealSharp:mainfrom
lesij-dev:main
Mar 28, 2026
Merged

Added Interface Blueprint functionallity#668
OlssonDev merged 4 commits intoUnrealSharp:mainfrom
lesij-dev:main

Conversation

@lesij-dev
Copy link
Copy Markdown
Contributor

Please check the Generated code if it can be cleaned up.

Interfaces automatically implement a method to check if an UObject implements that interface in blueprints. Can be called by using the static interface method called Implements.
Each interface function can also call the blueprint implementation directly on the UObject by using the generated static Interface.Execute function.
Why this change?
Example:
You implement an Interface in U#.
A Blueprint implements your interface.
If you want to call your method from the Interface in U# the cast will fail.
This change will allow to call those methods directly on the UObject

Please check the Generated code if it can be cleaned up.

Interfaces automatically implement a method to check if an UObject implements that interface in blueprints. Can be called by using the static interface method called Implements.
Each interface function can also call the blueprint implementation directly on the UObject by using the generated static Interface.Execute function.
Why this change?
Example:
You implement an Interface in U#.
A Blueprint implements your interface.
If you want to call your method from the Interface in U# the cast will fail.
This change will allow to call those methods directly on the UObject
@OlssonDev
Copy link
Copy Markdown
Member

This is already a feature in U#. You can do IMyInterface interfaceWrapper = myObject.AsInterface<IMyInterface> and call BP only implemented interfaces

@lesij-dev
Copy link
Copy Markdown
Contributor Author

This doesnt work for BP only interfaces (tried it already). Those can not be casted into Interfaces, since they are not actually implemented in code (atleast afaik). Epic also sais you need to use the Interface::Execute_Function methods
described here

You can try the setup as following:
create interface in u#
implement in bp only -> bp parent is Actor
assign a class reference in an other Object.
Spawn Actor by this reference
cast into the interface (using the AsInterface method)
result should be an empty cast (null)

@lesij-dev
Copy link
Copy Markdown
Contributor Author

here is a test
image

image

@OlssonDev
Copy link
Copy Markdown
Member

I think I want to look into this, I'd rather much add support to the AsInterface to support these cases.

@OlssonDev
Copy link
Copy Markdown
Member

I added support for user created interfaces in AsInterface now. Merging! :D

@OlssonDev OlssonDev merged commit 0f84f6c into UnrealSharp:main Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants