Hey so I’ve been having problems with accessing the data tables stored in my data asset blueprint to load them into memory, when I try and call LoadSoftRef I get the below error from what I can tell this is being caused by calling the .Num() method on DataTables_Array array (This happens no matter what method I call from array).
Any help would be appreciated with this problem?
Error message
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000070
UE4Editor_UnrealCOC_1620!UDataTable_DataAsset::LoadSoftRef() [E:\UE4 games\UnrealCOC\Source\UnrealCOC\DataTable_DataAsset.cpp:9]
UE4Editor_UnrealCOC_1620!UTestAppearance_Class::PlayerAppearanceCon() [E:\UE4 games\UnrealCOC\Source\UnrealCOC\TestAppearance_Class.cpp:15]
UE4Editor_UnrealCOC_1620!UTestAppearance_Class::execPlayerAppearanceCon() [E:\UE4 games\UnrealCOC\Intermediate\Build\Win64\UE4Editor\Inc\UnrealCOC\TestAppearance_Class.gen.cpp:31]
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_UMG
UE4Editor_UMG
UE4Editor_UMG
UE4Editor_UMG
UE4Editor_UMG
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_Engine
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor_UnrealEd
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
kernel32
ntdll
Code
DataTable_DataAsset.h
15 UCLASS(Blueprintable)
16 class UNREALCOC_API UDataTable_DataAsset : public UDataAsset
17 {
18 GENERATED_BODY()
19
20 public:
21 //StreamHandle
22 TSharedPtr<FStreamableHandle> Handle;
23
24 TArray<FSoftObjectPath> Paths;
25
26 FStreamableDelegate Delegate = FStreamableDelegate::CreateUObject(this, &UDataTable_DataAsset::Del);
27
28 UPROPERTY(EditAnywhere, Category = "DataTables")
29 TArray<TSoftObjectPtr<UDataTable>> DataTables_Array;
30
31 UFUNCTION(BlueprintCallable, Category = "Data Async Load Helper")
32 void LoadSoftRef(UUnrealGameInstance* UGI);
33
34 UFUNCTION(BlueprintCallable, Category = "Data Async Unload Helper")
35 void UnloadSoftRef();
36
37 UFUNCTION(BlueprintCallable, Category = "Delegate")
38 void Del();
39 };
DataTable_DataAsset.cpp
7 void UDataTable_DataAsset::LoadSoftRef(UUnrealGameInstance* UGI) {
8
9 for (int32 Index = 0; Index < DataTables_Array.Num();Index++) {
10 Paths.AddUnique(DataTables_Array[Index].ToSoftObjectPath());
11 }
12
13 Handle = UGI->AssetLoader.RequestAsyncLoad(Paths, Delegate);
14 }
15
16
17 void UDataTable_DataAsset::UnloadSoftRef() {
18 Handle.Get()->ReleaseHandle();
19
20 }
21
22
23 void UDataTable_DataAsset::Del() {
24 while (!Handle.Get()->HasLoadCompleted()) {
25
26 }
27 }
UnrealGameInstance.h
UCLASS()
class UNREALCOC_API UUnrealGameInstance : public UGameInstance
{
GENERATED_BODY()
public:
UUnrealAssetManager& UAM = UUnrealAssetManager::GetObj();
FTempSettings_Struct TempSettings;
FPermSettings_Struct PermSettings;
FDT_Ref_Struct DT_Ref2;
FStreamableManager AssetLoader;
UDataTable_DataAsset* TDataAsset = LoadObject<UDataTable_DataAsset>(NULL, TEXT("/Game/DataAsset/AssetDT.AssetDT"), NULL, LOAD_None, NULL);
void SetDT_Ref();
UUnrealGameInstance();
};
TestAppearance.cpp
7 FString UTestAppearance_Class::PlayerAppearanceCon(ACharacter* CPlayer, UGameInstance* GI) {
8 APlayerCharacter_Class* Data_Player = Cast<APlayerCharacter_Class>(CPlayer);
9 UUnrealGameInstance* Data_GI = Cast<UUnrealGameInstance>(GI);
10 FString AppearanceDescription = "";
11
12 Data_GI->TDataAsset ->LoadSoftRef(Data_GI);
13
14
15
16
17 return AppearanceDescription;
18 }