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"

[Closed] Documentation on includes, project generation, source folders

Hi,

I am trying to organise my project files. I would like to use subfolders for my code, and I need to include non-generated classes (like Slate) as well. I have been trying for hours, tried to copy the Classes/public/private structure without result (also, it is just awful to use), I have tried to put everything at the root... I have tried everything for the past four hours and I am going mad, though I am experienced with making build systems...

Why is my xxxClasses.h empty ?

How can I add code without using the "add code to project" that exposes only basic classes ?

How can I use subfolders the way I want ?

Why does "Include X.h" does not work in project.h when the file is just alongside ?

Is there any kind of logic in this mess ?

Thanks

Product Version: Not Selected
Tags:
more ▼

asked Apr 04 '14 at 08:00 PM in C++ Programming

avatar image

StrangerGwenn
604 55 64 133

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

The question has been closed Apr 28 '15 at 07:44 AM by StrangerGwenn for the following reason:

The question is answered, right answer was accepted


2 answers: sort voted first

Hello Gwenn,

Sorry you're having such a hard time getting started with UE4. Based on your questions I will assume that you did not yet have a chance to take a look at our Online Documentation, particularly the special Section for Programmers, so let me try to push you in the right direction to get up and running as quickly as possible.

A quick overview on how Unreal projects are organized can be found on the Directory Structure page, and the basic knowledge required for project compilation is documented on the Compiling Game Projects page. UE4 is a cross-platform engine that supports development on Windows, MacOS and soon Linux, so our means of managing project files need to be cross-platform as well. Our solution to managing things like header include directories, library dependencies and build settings are the .Build.cs and .Target.cs files that exist in each project.

The Managing Game Code page describes the different ways of adding code to your project. The Add Code To Project feature in the Editor is primarily meant for creating new game classes, because those require special markup that is usually not known to new users. For everything else you normally use Visual Studio as you would in any other game engine that is built in C++. The Add Code To Project feature currently does not allow you to specify a sub-directory, but we are working on that as I'm writing this, and it will probably be in the 4.2 release.

While sub-directories and files in the Public folders are enumerated automatically, file paths in the Private directory must be explicitly listed in the PrivateIncludePaths array of the project's .Build.cs file. In the past we have considered enumerating private sub-directories automatically as well, but after weighing the advantages and disadvantages have decided against it for the time being. We may change this in the future, provided we are finding compelling reasons.

The Classes directory is actually in the process of being deprecated. If you are adding new UObject based classes through Visual Studio you are now allowed to place them in either the Public or the Private directory, and it will just work. When you are adding UObject based classes manually in Visual Studio, remember that some extra markup will be required. You can find all about that on the Edit Class Header documentation page.

I hope that these quick pointers will allow you to get started with UE4, and we're looking forward to all the awesome things you will be creating. If you need further assistance, please let us know! If it is related to this question, you can post a comment right here, otherwise start a new thread on AnswerHub. Thanks!

more ▼

answered Apr 04 '14 at 08:36 PM

avatar image StrangerGwenn Apr 04 '14 at 09:31 PM

Thanks you for your answer. I have actually been working with Unreal before the public release, none of this is new.

I have not worked with Slate before, and it seems that the process is entirely different : you can't use "Add code to project", you can't put the header in Classes because there is no generated include, and putting the Private subdirectories in PrivateIncludePaths does not fix the missing includes.

Take this simple problem : in my HUD class, I can't include my "MyUIWidget.h" file which is in a Private/Player directory. No matter what I enter in the .Build.cs file, it won't find it. And I can't put the file itself elsewhere. Where am I supposed to put headers for classes that were not generated ?

avatar image StrangerGwenn Apr 04 '14 at 10:26 PM

Maybe I was a bit quick to reply, I found a working setup. All Slate code is in Private/GUI folder, and I include these files using the entire name (ProjectName/Private/GUI/file.h) from the master ProjectName.h file.

Though I am relieved to see it work, I would like to know how I can get rid of the Classes/Private structure.

avatar image gmpreussner STAFF Apr 06 '14 at 05:42 PM

Personally, I put all my headers into a pre-compiled header file called MyModulePrivatePCH.h. This header is then included as the first header of all my .cpp files. Take a look at some of the existing modules for guidance, for example DeviceManager, SessionFrontend or SettingsEditor.

Some programmers prefer to list every include file separately instead of a PCH in each of their .cpp files. There are arguments to be made for either approach. I prefer the simplicity of pre-compiled header files, because then I don't have to update dozens of .cpp files if I move or rename a header.

Note that even with a PCH file you still need to list all sub-directories in Private in the PrivateIncludePaths setting of project's Build.cs file. You can find examples in the aforementioned example modules as well.

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

To add directories with header files open Build.cs file of your project and add following lines:

 PrivateIncludePaths.AddRange(new string[] { 
                         "Folder",
                         "Folder/Subfolder"
             });

and so on. You might want to use PublicIncludePaths instead/together, depends on your goals.

To enable Slate in your project add next line to the same file

 PrivateDependencyModuleNames.AddRange(new string[] { "Slate" });

https://docs.unrealengine.com/latest/INT/Programming/UnrealBuildSystem/index.html https://answers.unrealengine.com/questions/20310/explanation-of-source-code-folder-structure.html

more ▼

answered Apr 04 '14 at 08:28 PM

avatar image

BiggestSmile
1.6k 54 38 105

avatar image StrangerGwenn Apr 04 '14 at 09:24 PM

Thanks, but .h in Classes are required to include their "generatred" version, which do not exist in the case of Slate widgets or other non-Unreal sources, unless I am mistaken. So I tried to put the headers in Private, but the above will not work in Private.

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

Follow this question

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

Answers to this question