# TSubClassOf with Interfaces isn't working

**URL:** <https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991>\
**Category:** UI\
**Tags:** interface, tsubclassof, unreal-engine, defaults, Blueprint, CPP, question\
**Created:** [January 22, 2016, 10:20pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991 "2016-01-22T22:20:50Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![erebel55](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@erebel55](https://forums.unrealengine.com/u/erebel55)\
**Post date:** [January 22, 2016, 10:20pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/1 "2016-01-22T22:20:50Z")

</div>

I have the following c++ interface

```
UINTERFACE(Blueprintable)
class UActionInterface : public UInterface
{
	GENERATED_UINTERFACE_BODY()
};

class IActionInterface
{
	GENERATED_IINTERFACE_BODY()
};

```

I am then implementing this interface via my c++ weapon class

```
UCLASS(ABSTRACT, Blueprintable)
class FPSGAME_API AFPSWeapon : public AActor, public IActionInterface

```

I then create a Blueprint from this FPSWeapon and add the ActionInterface under the Interfaces section.

 ![75580-shotgun.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/b/0/1b0f9406c53658a8a6b7cb5eaf245c69ab34b006.png)

My Character c++ class has the following property

```
// Default Inventory List
UPROPERTY(EditDefaultsOnly, Category = Inventory)
TArray<TSubclassOf<IActionInterface>> DefaultInventoryClasses;

```

But now in the editor I get nothing for this dropdown instead of the shotgun bp like I would expect.

 ![75591-nothing.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/a/9/8a9bd45af46a383beee62a72f68e879737c475a0.png)

Does anyone know why my Shotgun BP doesn’t show up here?

Thanks!

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [January 22, 2016, 10:43pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/2 "2016-01-22T22:43:23Z")

</div>

Interfaces are not identify as UClass\* so TSubclassOf (which work the same as UClass\* just limiting the UClass selection i editor) won’t work either.

Use this insted

```
TScriptInterface<IActionInterface>

```

---

<div class="post-metadata">

**Author:** ![erebel55](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@erebel55](https://forums.unrealengine.com/u/erebel55)\
**Post date:** [January 22, 2016, 10:46pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/3 "2016-01-22T22:46:06Z")

</div>

So I can’t limit the TSubclassOf dropdown to only my interface?

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [January 22, 2016, 10:48pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/4 "2016-01-22T22:48:54Z")

</div>

use UActionInterface insted of UInterface, but keep in mind those are like class identificators, not object pointers and i don’t know if you can do anything with those in blueprints.

---

<div class="post-metadata">

**Author:** ![erebel55](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@erebel55](https://forums.unrealengine.com/u/erebel55)\
**Post date:** [January 22, 2016, 10:52pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/5 "2016-01-22T22:52:13Z")

</div>

Yeah even with TArray\< TSubclassOf\< UActionInterface \> \> DefaultInventoryClasses; I still get nothing in the dropdown box.

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [January 22, 2016, 10:52pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/6 "2016-01-22T22:52:28Z")

</div>

Ok i think i get it now you want list of objects that implements interface, i dont think there is anyway to do so. If you can find node in engine that is example of that i can find how it was made for you

---

<div class="post-metadata">

**Author:** ![erebel55](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@erebel55](https://forums.unrealengine.com/u/erebel55)\
**Post date:** [January 22, 2016, 10:53pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/7 "2016-01-22T22:53:48Z")

</div>

Yeah, I am expecting to see my Shotgun BP in the dropdown box since it implements the interface. Is that not reasonable?

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [January 22, 2016, 10:59pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/8 "2016-01-22T22:59:17Z")

</div>

HA! Found it ^^ I digged a little in UHT code and find TScriptInterface

> **[TScriptInterface](https://docs.unrealengine.com/5.1/en-US/API/Runtime/CoreUObject/UObject/TScriptInterface/)**
>
> Templated version of \[FScriptInterface\](API\\Runtime\\CoreUObject\\UObject\\FScriptInterface), which provides accessors and operators for referencing the interface portion of a \[UObject\](API\\Runtime\\CoreUObject\\UObject\\UObject) that implements a native...

Try using I class if this wont work try using U class of interface

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [January 22, 2016, 11:02pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/9 "2016-01-22T23:02:57Z")

</div>

USe I class i found example in engine source code, i modified anwser, tell me if it works

---

<div class="post-metadata">

**Author:** ![erebel55](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@erebel55](https://forums.unrealengine.com/u/erebel55)\
**Post date:** [January 22, 2016, 11:08pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/10 "2016-01-22T23:08:44Z")

</div>

When I use that I don’t get a dropdown at all.

![75593-nodropdown.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/1/5/515c1862dae8b0123fbb52e31486ffe79d7ce133.png)

---

<div class="post-metadata">

**Author:** ![erebel55](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@erebel55](https://forums.unrealengine.com/u/erebel55)\
**Post date:** [January 22, 2016, 11:09pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/11 "2016-01-22T23:09:55Z")

</div>

I was able to get the following working. But now I’m interested in TScriptInterface.

```
UPROPERTY(EditDefaultsOnly, meta = (MustImplement = "ActionInterface"))
TArray<TSubclassOf<UObject>> DefaultInventoryClasses;
```

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [January 22, 2016, 11:12pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/12 "2016-01-22T23:12:18Z")

</div>

Ah ok 🙂 Well then as you anwser to your quastion yourself i will turn it in to anwser and mark as resulved. I guess that template i told you is not supported by blueprints

---

<div class="post-metadata">

**Author:** ![erebel55](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@erebel55](https://forums.unrealengine.com/u/erebel55)\
**Post date:** [January 22, 2016, 11:18pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/13 "2016-01-22T23:18:23Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![idbrii](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@idbrii](https://forums.unrealengine.com/u/idbrii)\
**Post date:** [September 8, 2016, 8:19pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/14 "2016-09-08T20:19:38Z")

</div>

What is that a TArray of?

Should it be UObjects:

```
TArray<UObject*> DefaultInventoryClasses;
```

---

<div class="post-metadata">

**Author:** ![erebel55](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@erebel55](https://forums.unrealengine.com/u/erebel55)\
**Post date:** [September 8, 2016, 8:30pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/15 "2016-09-08T20:30:18Z")

</div>

Sorry not sure how that got chopped off before. I’ve edited my answer with how I have it.

---

<div class="post-metadata">

**Author:** ![idbrii](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@idbrii](https://forums.unrealengine.com/u/idbrii)\
**Post date:** [September 8, 2016, 11:28pm UTC](https://forums.unrealengine.com/t/tsubclassof-with-interfaces-isnt-working/344991/16 "2016-09-08T23:28:31Z")

</div>

Both of these worked for me:

```
UPROPERTY(EditDefaultsOnly, config, NoClear, Category="SomeCategory", meta=( MustImplement=SomeInterface ))
TSubclassOf<UObject> SomeVariable;

UPROPERTY(EditDefaultsOnly, config, NoClear, Category="SomeCategory", meta=( MustImplement=SomeInterface ))
UClass* SomeVariable;

```

I did this in a UDeveloperSettings so I had more restrictions about what kinds of variables were allowed (hence config and NoClear).
