How do I set the Classname in Uclass property?

Hi,

I’m lost with how to set the property inside UClass.

From the documentation:

UCLASS(Within=PlayerController)
class UPlayerInput : public UObject

But it is said that we should set the class name, so it should be:

UCLASS(Within= APlayerController)
class UPlayerInput : public UObject

I have the same question for DependsOn.

Thanks,

The ‘A’ and ‘U’ prefixes must be dropped in those cases, i.e. APlayerController becomes just PlayerController. This is really just a leftover convention from UE3 when we still had UnrealScript. In UnrealScript, classes would never have prefixes - the prefixes were automatically added only in the C++ side of things.

It’s just one of the so called ‘Unrealisms’ that have crept in over the years. I’m planning to write a blog post about them as soon as I have time :slight_smile:

Hooo :slight_smile:

That’s hard to find alone for new Engine users.

A blog & Documentation update should be great and really helpful

How do you know the classname? file name or do you truncate the first caracter of the class name set in C++ header?

I’m more than happy to see a blog notes with all the little things like that we should know.

Thanks,

Yeah, I agree, it’s nearly impossible to discover this kind of stuff, but after a while you’ll get used to it.

There is basically a convention between the secret Unreal Engine overlords that all AActor derrived classes start with an ‘A’ and all UObject derrived classes start with an ‘U’. The Engine will strip those prefixes automatically, and it expects you to strip them yourself in certain cases, such as yours.

If you create an Actor class for ‘some cool actor’, then by convention you would have to name your C++ class ASomeCoolActor, and when using it in UCLASS macros you would have to strip the ‘A’ so that it becomes SomeCoolActor, because that’s how the Engine tracks it internally.

Did you change something on this on 4.2.1?
It seems now that we show include the prefix

This has not changed in 4.2.1 or newer versions. Search in the code base for “Within=” and you will see that the prefix is still omitted.