Be the first to post for 'Interfaces To Invert Dependencies'!

If you’re reading this, there probably aren’t very many posts yet. But don’t worry, you can be the first! Either create a new post or just reply to this one to say ‘hi’.


Just for semantics, this interface that we are making in this lecture and injecting later, shouldn’t be called GameInstanceInterface? Game instance is the object that inherits interface, and menu calls game instance. Dont you think?

This may seem not that important, but for people that are not that advanced in programming its really important to learn how to make code readable and understanding.

Yeah, I wasn’t very happy with the naming of that interface. The problem with the name GameInstanceInterface is that I don’t have to implement it with the GameInstance. It could be anything that creates the UI.

I’m getting these errors from using the interface,

c:\users\kamur\documents\unreal projects\myproject3\source\myproject3\PuzzlePlatformGameInstance.h(16) : error C2259: ‘UPuzzlePlatformGameInstance’: cannot instantiate abstract class
c:\users\kamur\documents\unreal projects\myproject3\source\myproject3\PuzzlePlatformGameInstance.h(16) : note: due to following members:
c:\users\kamur\documents\unreal projects\myproject3\source\myproject3\PuzzlePlatformGameInstance.h(16) : note: ‘void IMenuInterface::Host(void)’: is abstract
I got no idea how to fix this

Have you implemented all of the pure virtual methods methods you defined in the interface? If you missed any of those overrides in the game instance then it cannot be instantiated.

Basically go through all the methods in your interface and make sure each has an override in the game instance.

1 Like

So the purpose of the UObject definied in the interface file is just so Unreal can “see” the interface? Could someone explain this to me in greater detail?

Yes, basically. So that you could implement the interface with a blueprint. It has something to do with how their reflection system works but I don’t know the exact details myself.

1 Like

Hello Sam, I have the same question which is mentioned above
In the lecture you told that “Unreal can’t know about our Interface unless it inherits from something that is a UObject”
but IMenuInterface doesn’t inherit from UMenuInterface and any other UObject class. on the other hand it seems that thus tow classes have not any connection
out come this why UMenuInterface necessary at all?
how does it work?

Basically, it uses the UObject class to identify the interface in Blueprint (blueprint stuff has to derive from UObject). The IMenuInterface is what you use in C++. It’s all tied together by the UnrealHeaderTool directive UINTERFACE().

Privacy & Terms