Hello everyone! In last hour ive got a problem.
I create a struct in GameInstance class, then use it to define variable (GoodGameRef) as an example below .
//GameInstance.h
USTRUCT(BlueprintType)
struct FGoodGame {
. . .
};
UCLASS()
class ...
{
. . .
FGoodGame GoodGameRef;
. . .
};
Then i want to use the same struct to define other variable from other class.
//Saver.h
#include "GameInstance.h"
UCLASS()
class ... {
FGoodGame GoodGameRefButInOtherClass; // And on that moment i started to recieve compile errors, so, ive tryed different ways to setup it, but i dont get it.
};
How can i setup variable in class with struct from other one?
Thanks.
What compile error do you get?.. without them we can only guess what is wrong.
I’m sorry, here a error for example above.
Unrecognized type ‘FGoodGame’ - type must be a UCLASS, USTRUCT or UENUM
This is actually UHT error not compiler, it does not see the struct like it does not process it (but considerint it works in GameInstance.h it should be fine or name is does not match. UHT regonize types in header file even without includes as it tracks all of them. From examples you give it looks fine but it seems you modify names so im not sure if it is 100% is correct. You could also try rebuilding. Also do you really named your file GameInstance.h? If yes there might be conflict with the engine
If you desperate and if you don’t need anything from reflection system and you could remove UPROPERTY() which will remove variable from UHT scan, you could try it to see how compiler gonna react to it
Also those are not references (as it is not pointer * or reference &) those are data structures that contain variables, they stored same way as int32 or float.
I didn’t get how error was fixed, because when I return to PC problem was solved by itself.
Unreal & VS compile all fine with UPROPERTY set in. Maybe that rebuild or something helped(but why it didn’t help earlier idk). Great thanks you for answer anyway!
And thanks for additional explaining:
Also those are not references (as it is not pointer * or reference &) those are data structures that contain variables, they stored same way as int32 or float.