Little problem with USTRUCT

Hello there, i’m really new to C++. Recently I tried to make a new structure with c++ to show the Content directory as a dropdown menu. I have successfully made a new structure, but for some reason it’s nested. What should I fix in the code to make my structure looks ‘normal’?

USTRUCT(BlueprintType)
struct FDPath
{
	GENERATED_BODY()

	/**
	 * The path to the directory.
	 */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=ContentPath, meta=(ContentDir))
		FDirectoryPath DirectoryContentPath;
};

Nested? Do you mean the open/close icon on ContentPath? That is because the UPROPERTY has a category set.

It’s shown at the screenshot. There’s a ‘Content Path’ group in front of my structure, and I want to remove it and leave just my struct :slight_smile:

Just delete Category=ContentPath from UPROPERTY.

1 Like

no luck :frowning:

USTRUCT(BlueprintType)
struct FDPath
{
	GENERATED_BODY()

	/**
	 * The path to the directory.
	 */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(ContentDir))
		FDirectoryPath DirectoryContentPath;
};
LogCompile: Error: An explicit Category specifier is required for any property exposed to the editor or Blueprints in an Engine module.

Hah, never seen that one before. But probably because I am not using an engine module.
Try using a game module for example?

#include "GameCore.h"
#include "Modules/ModuleManager.h"


IMPLEMENT_PRIMARY_GAME_MODULE( FGameCoreGameModule, GameCore, "GameCore" );


void FGameCoreGameModule::StartupModule() {

}

void FGameCoreGameModule::ShutdownModule() {
}
#pragma once


class FGameCoreGameModule : public IModuleInterface {
public:
    virtual void StartupModule() override;
    virtual void ShutdownModule() override;
    virtual bool IsGameModule() const override { 
        return true; 
    }
};

Or perhaps it was the target.cs file that must be modified here, I don’t remember. Since Your image shows you are working with an editor utility widget you could either go for game or editor as well:

using UnrealBuildTool;
using System.Collections.Generic;

public class GameCoreEditorTarget : TargetRules
{
	public GameCoreEditorTarget(TargetInfo Target) : base(Target)
	{
		Type = TargetType.Editor;
		DefaultBuildSettings = BuildSettingsVersion.V2;
		ExtraModuleNames.Add("GameCoreEditor");
	}
}

  • But really, what is so bad about having your category show as an open/close arrow??
1 Like

I’ll give it a shot, thanks for the reply. I want to get rid of category to make the widget looks default, w/o any arrows :smiley: