Is it possible to customize world settings for each map?

Hi guys,

I am currently working on a large cpp-based in-game item generating system, and as I use minimum amount of UObjects in my system, it is not exposed to Blueprints. Though, instead of recompiling each time after I change the parameter or two in code (or stupidly exposing each of these parameters to some Actors), I would like to have a kind of centralized settings object, that I could edit on per-map basis, and the items which I spawn on this map will be taking different values from it. First off, is it possible to utilize in some way the World Settings for that purpose? I did not find any way to extend the settings list in it, outside of just editing the engine source code for it.

If not, what would be the best solution for such settings container? The only way that I can make it work for now, is using custom actor with my settings inside being set as public USTRUCT, placing this actor on the map, in code of each spawned item searching through all the actors on the map, finding that custom settings actor and taking parameters from it. I am pretty sure there are better solutions out there, right? :slight_smile:

You not searched enouth, you extend UWorldSettings and then you set class in project settings in default classes

Ok, but it does not seem to be per-map setting. I can edit it for my project, but how do I set it for each map individually?

Yeah, now I figured that out. I still have to cast the world settings to my own settings class, but it’s still a solution. Thanks.

World Settings state is saved to umap, so it is per map invidually. I using it myself so i know :stuck_out_tongue:

All hail the shadow river

I couldn’t understand this passage; how can a custom world setting be set for each map?

If I want different WorldSettings classes, is that possible?
For example custom World Settings in levels and default WorldSetting from UE4 for Main Menu

Don’t know if it is relevant for you, but for the others new projects.

Yes, you can have indirectly custom WorldSettings.

If you know the concept of instanced UObjects you can extend the UWorldSettings with your game specific one.
On an instanced uproperty you select the UClass you want to instantiate, and get properties to fill that specific one.

Below is a quick code, haven’t tested it. But should work.

UCLASS(EditInlineNew)
class UMyBaseSettingsForIndividualLevelSettings : public UObject
...

UClass()
class AMyCustomWorldSettings : public AWorldSettings
{
...
    template<typename T>
    T* GetLevelSettings()
    {
        return Cast<T>(LevelSpecificSettings);
    }
...
    UPROPERTY(Instanced, ...)
    UMyBaseSettingsForIndividualLevelSettings* LevelSpecificSettings;
...
}