All the UInterface types explained in Cpp - Unreal Interfaces - UE C++ Tutorial
The Unreal engine provides interfaces as a primary feature of the engine. When considering C++ and blueprint, there's 3 different ways interfaces are used. We have Blueprintable, NotBlueprintable, and Blueprint interfaces. This video goes through the different permutations, the nuances between them, and provides mental model to quickly reason about the differences. TSubclassOf can be constrained using the MustImplement keyword. UClass has the ImplementsInterface function for runtime checks. UObjects have Implements method to check if it implements an interface. Casting to IType only works reliably for code classes implementing interfaces The Implements method is the most reliable way to check for an interface, as it works in all contexts I have tested. Additional notes: While not covered in the video, you can still use TScriptInterface with NotBlueprintable interfaces, in the way that I shown for BlueprintableInterfaces. For clarity, ImplementsInterface is a method of UClass, not TSubclassOf. See UClass::ImplementsInterface Common Errors around Blueprintable and NotBlueprintable. My mental model helps explain these. Interfaces that are not implementable in blueprints cannot have blueprint event members. Blueprint implementable interfaces cannot container blueprintCallable functions that are not BlueprintImplementableEvents. Add NotBlueprintable to the interface if you wish to keep this function. Recorded in 5.3 SLIDE SHOW 0:00 High Level Interface Types 0:26 UType vs IType 0:53 Why use Interfaces 1:26 Blueprintable vs NotBlueprintable 2:29 NotBlueprintable and Blueprintable and Blueprint interface nuances 2:39 Blueprintable Code Inheritance - has valid IType pointers 2:56 Blueprintable Blueprint Inheritance - does not have valid IType pointers 3:18 A useful mental model 3:35 Blueprint defined interfaces 3:39 Interface Inheritance Mental Model Review 4:09 The usefulness of the Mental Model approximation 4:24 Implements vs Cast 5:52 Passing parameters to Blueprintable interface events requires object pointer 6:48 Using TScriptInterface 8:30 Blueprintable NotBlueprintable - I-interface isn't valid for blueprints implementing interface 9:00 Mental Model Explains: BlueprintNativeEvent doesn't allow bp to call super, and default return values 10:30 TSubclassOf constraining to interfaces -- MustImplement 11:15 Checking TSubclassOf at runtime using the ImplementsInterface function 11:54 Blueprint Interface Calls - Direct vs Messages 12:34 Inheritance Polymorphism with subclass interfaces 13:09 Polymorphic interfaces inheritance Diagram LIVE CODING SECTION 15:02 Begin live coding interfaces 15:17 Making a Blueprintable interface in c++ 16:26 Making an actor to overlap interfaces for testing 16:45 Interface runtime checks for Blueprintable interfaces 17:12 Using Execute_ functions to invoke interface events 17:51 Bad code, casting to a IType on a Blueprintable interface 18:15 Clean up code and compile 18:27 Make a BP actor inheriting from a code class (which implements an interface) 19:12 Make a BP actor implementing interface directly 20:00 Make an overlapper actor to call interface functions 20:30 Testing in PIE with breakpoints 20:50 Testing Blueprint-interface-implementer at runtime (with breakpoints) 21:45 Blueprint type fails to Cast, which is explained by mental model of no IType for blueprint implementors 21:55 Testing code-interface-implementer at runtime (with breakpoints) 22:41 Code type cast succeeds, but we will hit checks if we invoke functions wrong way. 23:51 Increase duration of prints and show the blueprint overrides are working when testing in PIE 24:18 Disabling the bad code 24:28 TScriptInterface UPROPERTY 25:04 Making a TScriptInterface at runtime 25:12 TScriptInterface GetObject and GetInterface 26:10 Testing TScriptInterface GetObject and GetInterface in PIE 27:35 Logs showing difference in behavior among code and blueprint implementing a Blueprintable interface. 27:50 Sending a TScriptInterface to Blueprint (from c++ code) 28:05 Receiving TScriptInterface in blueprint 28:47 Testing TScriptInterface with blueprint 29:24 TSubclassOf - UClass method: ImplementsInterface -- runtime checks determine if a class implements interface 31:18 TSubclassOf - MustImplement keyword 32:45 Code Only Interfaces -- ie NotBlueprintable 33:15 BlueprintCallable is valid, there is always an IType 34:21 Making an actor implement the NotBlueprintable interface 34:35 No BlueprintableEvents 35:35 ITypes can have virtual functions 36:02 Implements check still works 36:13 Casting is valid, since there is always an IType 36:49 Making a BP actor subclass to test in PIE. 37:00 Testing in PIE 38:29 Blueprint Defined Interfaces 40:06 Invoking interface functions in blueprint, messages vs direct 41:00 Testing blueprint only interfaces in PIE 41:42 Messages only, no manual type checking 42:26 Closing Summary and thoughts 42:57 Outro Hope it helps :)
Download
0 formatsNo download links available.