Download

Custom Data Asset Can't See Custom UObject (Answered)

I have a custom data asset and I want it to hold a TMap of instances of ItemEvent( inherits UObject) that are blueprints. When I go to assign it none of my instances show up. Not sure what I am doing wrong. My code and some pics are below.

Item Event UObject


// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "DynamicsInventoryItemEvent.generated.h"

/**
*
*/
UCLASS(Blueprintable, BlueprintType, abstract, EditInlineNew, CollapseCategories, AutoExpandCategories = ("Default"))
class DYNAMICSINVENTORY_API UDynamicsInventoryItemEvent : public UObject
{
GENERATED_BODY()
public:
UDynamicsInventoryItemEvent();

//Called when the event is triggered.
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Dialogue Events")
void OnUse(AActor* OwnerActor, int InventoryIndex, int InventoryItemIndex);
};


// Fill out your copyright notice in the Description page of Project Settings.


#include "DynamicsInventoryItemEvent.h"

UDynamicsInventoryItemEvent::UDynamicsInventoryItemEvent()
{

}

void UDynamicsInventoryItemEvent::OnUse_Implementation(AActor* OwnerActor, int InventoryIndex, int InventoryItemIndex)
{
return;
}



Custom Data Asset


// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "DynamicsInventoryItemEvent.h"
#include "CoreMinimal.h"
#include "Engine/DataAsset.h"
#include "DynamicsInventoryDataAsset.generated.h"

/**
*
*/
UCLASS()
class DYNAMICSINVENTORY_API UDynamicsInventoryDataAsset : public UDataAsset
{
GENERATED_BODY()

public:
UPROPERTY(EditAnywhere, BlueprintReadOnly)
TMap<FName, TSoftObjectPtr<UDynamicsInventoryItemEvent>> ItemEvents;
//I have also tried this TMap<FName, UDynamicsInventoryItemEvent*> ItemEvents;
};


](filedata/fetch?id=1828330&d=1604284833)
](filedata/fetch?id=1828331&d=1604284833)
](filedata/fetch?id=1828332&d=1604284832)

This works but there is one problem. I can set any asset. I only want ones that inherit
UDynamicsInventoryItemEvent


UPROPERTY(EditAnywhere, BlueprintReadOnly)
TMap<FName, UObject*> ItemEvents;

Hello,

Try this:



UPROPERTY(EditAnywhere, BlueprintReadOnly)
TMap<FName, TSubclassOf<UDynamicsInventoryItemEvent>> ItemEvents;

Although I am confused, are you trying to reference assets or actual instantiated objects?

This worked. Thank you so much.