x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Cannot access header file

I am new to UE4. I am learning it by following this site's tutorial. There is a tutorial about timer .
At the first I use UTextRenderComponent declare a variable, but it says the UTextRenderComponent not defined.
So I searched on Internet and I know I must #include "Runtime/Engine/Classes/Components/TextRenderComponent.h" , then it's ok. But when I called UTextRenderComponent member function SetHorizontalAlignment, it didn't give me a code suggestion and show an error.alt text

When I hovered on it. it showed:

 void UTextRenderComponent::SetHorizontalAlignment(EHorizTextAligment Value)
 function "UTextRenderComponent::SetHorizontalAlignment"(declared in line:127, file:"F:\Epic Games\UE_4.20\Engine\Source\Runtime\Engine\Private\Components\TextRenderComponent.h") cannot access.


However, I press Ctrl + left click, I can open that header file.Although it can be complied successfully, it makes me feel bad without code suggestion. Could anyone please help me find out the problem?

Product Version: UE 4.20
Tags:
more ▼

asked Aug 20 '18 at 12:40 PM in C++ Programming

avatar image

starccy
1 2 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

try : #include "Components/TextRenderComponent.h" since this are include folders. basicly components might be internaly a module/dll and thats it basefolder. well its the structure of the ue4 engine.

more ▼

answered Aug 20 '18 at 02:28 PM

avatar image

Kanteh
62 4 4 7

avatar image PlainWaterK Sep 06 '18 at 03:08 AM

I have tried the solution you metioned, but it didn't work.

avatar image Kanteh Sep 06 '18 at 10:11 AM

what i forget to say. u might edit ur Projectname.build.cs file. So it might not work, because u didnt include "UMG" in it.

So what does it do. Its including a module into ur project(badicly similar to a dll in ue4). So u have to set the correct the corrent path(with include) and also to include the dll/module in the build.cs or it wont work.

for my actual project it is like :

Blockquote using UnrealBuildTool;

public class Projectname : ModuleRules { public Projectname (ReadOnlyTargetRules Target) : base(Target) { PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

      PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG" , "RHI" , "GameplayTasks" });
      PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

avatar image starccy Sep 11 '18 at 12:21 PM

I think it because of the member in this class is private, so it cannot be used by VS default Intellisense ?

avatar image Kanteh Sep 06 '18 at 10:20 AM

So for example (what i do when i add new functionallity from ue4 engine).

  • I open up the .h where the function i need is defined.

  • then i take a look at the path. in my case ".....\UnrealEngine\UE_4.19\Engine\Source\Runtime\UMG\Public\Components\WidgetComponent.h" --(alternativly u can google the API/funcion and then scroll down. there u find the needed module and path of the header file "http://api.unrealengine.com/INT/API/Runtime/Engine/Components/UTextRenderComponent/")

  • the important part is "UMG\Public\Components\WidgetComponent.h"

  • the used module by the header is UMG here.

  • so i ensure UMG is added to the projectname.build.cs

  • when its add. "...UMG\Public" is an include folder in ur project(similar to a normal c++ project)

  • so to include the header to my own header/project i use

  • "#include "Components\WidgetComponent.h" "

I hope this helps. Google / search for build.cs etc if u want to get deeper into it. Also it always help

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

So I just created an Empty project where I used the #include "Components/TextRenderComponent.h" and then I declared the comp as you did and everything went as intended. There is an issue with the engine and precompiled header tho, be sure that until it's fixed in 4.20.3 the Intermediate/Build!Platform/UE4Editor/Inc/ProjectName is part of your includes in your solution

more ▼

answered Sep 06 '18 at 07:36 AM

avatar image

TheDreamCatcher
258 2 4 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question