Why do I have to click "copy reference" everytime one of my blueprints has a compile error?

Hi all,

I posted the following already in the forum but got the impression that it belongs here.

I’m having a hard time getting data tables to work in my project. Actually it works sometimes, but not everytime.
I created a struct in C++ to hold the data and the excel (from which I save the csv) using the template from the unreal web page.

My csv looks like this:

 ,NeedName,Comment,Thumbnail
 0,TestNeed1,This is a test text,"""Texture2D'/Game/Textures/icon_GoingHome_32.icon_GoingHome_32'"""
 1,TestNeed2,This is a test text,"""Texture2D'/Game/Textures/icon_food_32.icon_food_32'"""
 2,TestNeed3,This is a test text,"""Texture2d'/Game/Textures/icon_jewelery_32.icon_jewelery_32'"""
 3,TestNeed1,This is a test text,"""Texture2d'/Game/Textures/icon_clothes_32.icon_clothes_32'"""
 4,TestNeed1,This is a test text,"""Texture2D'/Game/Textures/icon_books_32.icon_books_32'"""
 5,TestNeed1,This is a test text,"""Texture2D'/Game/Textures/icon_computer_32.icon_computer_32'"""
 6,TestNeed1,This is a test text,"""Texture2D'/Game/Textures/icon_furniture_32.icon_furniture_32'"""
 7,TestNeed1,This is a test text,"""Texture2D'/Game/Textures/icon_games_32.icon_games_32'"""
 8,TestNeed1,This is a test text,"""Texture2D'/Game/Textures/icon_groceries_32.icon_groceries_32'"""
 9,TestNeed1,This is a test text,"""Texture2D'/Game/Textures/icon_music_32.icon_music_32'"""
 10,TestNeed1,This is a test text,"""Texture2D'/Game/Textures/icon_perfume_32.icon_perfume_32'"""
 11,TestNeed1,This is a test text,"""Texture2D'/Game/Textures/icon_shoes_32.icon_shoes_32'"""
 12,TestNeed1,This is a test text,"""Texture2D'/Game/Textures/icon_tools_32.icon_tools_32'""" 

Now when I import into unreal engine here’s what I get:

The entries crudly circled yellow are the only ones that will work / get displayed in my game.
What could cause that? btw. the csv. is UTF-8 encoded as I am living in a country with funny letters.

Ok, now here’s the REALLY funny part. As soon as i have clicked “Copy Reference” on every referenced image in the content browser, I can reimport the very same data table source (Asset->Reimport List) and the editor will once again recognize the link to the picture and it is displayed in my game.

Please don’t hesitate to move the topic should I be wrong here with my question.

thanks and best regards

Hi ,

I just tried to reproduce this issue, but was unable to do so. Would you be able to provide some additional information?

  • What version of the Engine are you using?
  • Are you using the binary version installed by the Launcher, or did you build the Engine from source code?
  • Does this only happen in your project, or do you see the same results in a new project?
  • Could you provide the code you used to create your struct?
  • When you say that you have to click “Copy Reference” are you referring to having to right-click on the asset in the Content Browser and selecting Copy Reference from there? Do you paste that reference anywhere?

Hi ,
Thanks for your answer. I am currently using 6.1 but it also occurs with every preview build i’ve used (up to and including Preview 5). I am using the binary version.

I did not try to create a new project. What I did was copy my project multiple times always with the same effect. I’ll try to replicate the issue over the weekend. I’ll also add my struct code over the weekend, as I currently don’t have access to it.

Yes that’s the strange part about it, I don’t have to paste the reference anywhere, in fact I can multiselect all my assets, right click and hit “Copy Reference” and it will work again during “Play In Editor”. I don’t even need to reimport the asset list.

By the way, there are more people having this issue, please take a look at the following forum thread, Forum Post. (User teed, 01-25-2015, 11:20 AM)

Thanks for your efforts and have a nice day

Here’s my header file for the struct, the cpp is empty (aside of the includes)

#pragma once
#include "FNeedLookupTable.generated.h"

/**
 * 
 */

USTRUCT(BlueprintType)

struct FNeedLookupTable : public FTableRowBase
{

	GENERATED_USTRUCT_BODY()

public:
	FNeedLookupTable()
		: NeedName(FText::FromString(TEXT("")))
		, Comment(FText::FromString(TEXT("")))
		, Thumbnail()
	{}

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Need)
	FText NeedName; 

	UPROPERTY(EditAnywhere, BlueprintReadWrite, CAtegory = Need)
	FText Comment; 

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Need)
	TAssetPtr<UTexture2D> Thumbnail;

};

umm… hello?

I am very sorry for the delay in getting back to you. I have been rather swamped the past few weeks.

With the additional information you provided I was able to see almost exactly what you described, though I have been experiencing a series of (hopefully) unrelated crashes when trying to reproduce this issue in our latest internal build of the Engine. I am in the process of reverting to a slightly older build to see if I can avoid those crashes and complete the test in our internal build.

Hi ,

That’s great news (apart from the being swamped part). The resource I’m trying to display is a PNG saved photoshop as rgb/16.

I only had crashes when I used asset paths that were not directly copied (Copy Reference) from the content browser in the engine. The asset path needs to be exactly as it is copied from there even though the official documentation states something else (look here).

Thanks for your continuing efforts. My project is for a diploma thesis that should be finished next week but I do have some workarounds so it should be fine ;-).

Cheers

Hi ,

The crashes I was experiencing turned out to be unrelated to this issue. Those crashes were related to how I was making my test project, and once I figured that out I was able to test this issue without any further trouble. It is still occurring in our latest internal build, so I have documented my findings to have this investigated further (UE-11024).

Hi ,

I’ve had a look at your example and I think the issues arise largely from confusion over how TAssetPtr works. It may be worth looking over the documentation for TAssetPtr first just to familiarize yourself with its use.

Essentially the issue is that TAssetPtr will not automatically load its referenced asset, unlike a plain UTexture2D*. If you were to change your Thumbnail property to a UTexture2D*, you’d find everything would work as you expect. The advantage of using a TAssetPtr is that it doesn’t insert an extra asset dependency in the loading; instead you load the asset when you’re ready to use it.

Here’s an example of how you could do this when iterating through the rows of your DataTable:

		if (DataTable != nullptr)
		{
			TArray<FName> RowNames = DataTable->GetRowNames();
			for (const FName& RowName : RowNames)
			{
				FNeedLookupTable* Row = DataTable->FindRow<FNeedLookupTable>(RowName, TEXT("Test"));

				if (Row->Thumbnail.IsPending())
				{
					UObject* Asset = Row->Thumbnail.ToStringReference().TryLoad();
					if (Asset == nullptr)
					{
						UE_LOG(LogTemp, Log, TEXT("Still couldn't load texture"));
					}
				}

				UTexture2D* Texture = Row->Thumbnail.Get();
				if (Texture)
				{
					// Got the texture - do something with it (just print its name for now)
					UE_LOG(LogTemp, Log, TEXT("%s"), *Texture->GetName());
				}
			}
		}

Hope that’s clearer. Give me a shout if you have any further questions.

what is the status of this issue ? (UE-11024)

I have the same problem as in first post, and I dont parse my data table in c++, just BP, so this solution wont work for me.

thanks!

Hi ,

This particular issue was closed with the comment that it is “by design.” The TAssetPtr that was being used in the original post is a lazy weak object pointer, so it won’t provide the asset that it is pointing to unless that asset has already been loaded into memory.

Would you be able to provide more information about how your data table is set up?