Download

Adding code manually that requires to be generated

I’m trying to use the ShooterGame as a reference for creating game menus and as I am going through the reference code I am seeing #includes for generated files. Is there a way to tell the project to create these generated files or do I have to use the editor to find the parent class and add it to the project?

Create the header file and the c++ file, then go to the object directory, rightclick the uproject (in file browser) and click “generate visual studio files”.

As Cube2222 said, all you really have to do is add the header/code file in the source directory and regenerate your project files.

You will need a couple of requirements though:

  1. The header file must have its last include be the generated header file. It defines the GENERATED_UCLASS_BODY macro which actually handles defining a number of internal methods and accessors based on the UProperties and such that you include in your class.
  2. Your class declaration must have a the GENERATED_UCLASS_BODY()
  3. Your code file must begin with the pre compiled header, and probably the PCIP constructor depending on whats going on in your class.
  4. Actors must begin with an A and Unreal Objects begin with A U. The F appears to be optional, but I’m not entirely certain about that.
  5. If you are creating a non UObject based class, as happens with slate or misc. internals programming, you don’t have to do any of the above.

This is a sample cheat manager which covers the above (save the fifth)


#include "SamplePlayerController.h"
#include "SampleCheatManager.generated.h"


UCLASS(Within=SamplePlayerController)
class USampleCheatManager : public UCheatManager
{
    GENERATED_UCLASS_BODY()
public:
};


#include "Sample.h"#include "SampleCheatManager.h"


USampleCheatManager::USampleCheatManager(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
}

One caveat to keep in mind - You cannot properly extend Character, and there may be other classes that are dependent on a blueprint of some sort to define its parameters.

Hope this fills in any other blanks.
Good luck!

Sorry for the delay as I’ve been busy all week and just got some free time to continue my project.

I ran the command to generate project files but still was not able to get a generated file. I created an empty .h/.cpp file and nothing. I set up the requirements mentioned above and nothing. I did a direct copy of the reference code and again nothing. Is there something I need to register with my project to get the file generation to work? I made sure that my search paths are correct and I do see that VS is able to locate the file, but the generation just seems to do nothing for me.

Edit: If it makes a difference I have many sub directories in my Source folder to keep the structure of the code clean. Is this a big no-no?

Sounds fine to me. ReqPro and I are using folders on our projects for the same reason and it is working fine. Maybe something odd is going on with your setup. If you want some hands on help join us on IRC and I’ll dive into google hangout to show you our set up and or look over yours.

Best wishes

I just played around a bit with my setup and I think I found an issue with it. I will continue to pinpoint the issue, but thank you for wanting to assist me. I will join the iRC channel if I notice that I am no where near on course.

Roger.

Don’t waste too much time chasing this down. mIRC is a decent windows client, otherwise you should probably be using irssi or something. Google will present you with dozens of options.

Best thing you can do is come get some help if you run aground. I promise it doesnt cost a dime.

Not yet at least =)

I figured out my issues. The first issue is that in my project’s build.cs I never specified the private include directories. Which would explain why every time I generated the project files it would throw errors stating that the files could not be found. The second issue I had is that I had a class called ‘FMenuItemStyle’ and an object of that class called ‘MenuItemStyle’. For some reason this caused the compiler to throw an error saying that ‘MenuItemStyle’ cannot be redefined.

The prefixes are not always self evident. The pairing of [PREFIX]ClassName is pretty confusing when first starting out. U is UnrealObject, A is Actor, and F is some magical type for things that are neither actors nor are they unreal objects - although some people seem to think that F means float, IDK how accurate that is in light of the slate classes and structs that don’t contain floats using F.

Good catch on the private include paths, I think that was going to be the first thing I showed off too. Just make sure when you are using your #include that you provide the relative pathing from the base private/public folders and you should be able to provide paths anywhere under the sun.

Good luck, if you run into other issues please don’t hesitate to reach out.
We are all here for brain picking!

=D