Jump to content

Recommended Posts

So I observed some rather frustrating behavior when it comes to configs and prefabs.

 

I found myself assigning waypoint prefabs a lot, so I naturally created a config class for waypoints so I can reuse the same things across different systems. 

I also created a config which contains group prefabs for a specific faction. That way I can once again reuse certain things. 

Finally, I have created an encounter config where I can give a type, min/max groups to spawn, timers and such.

 

So think of it as the following structure

EncounterConfig

{

    GroupsConfig

    WaypointsConfig

};

 

This all works within the editor. I can both assign an existing config file, or manually assign values. 

The issue is, if I spawn a prefab with this EncounterConfig the sub-configs do NOT load at runtime. They're null. Doesn't matter if it's a file or manual assignment. 

 

As a workaround I tried having ResourceNames for the configs instead, so I could load them similarly to prefabs but I cannot for the life of me figure out how to load a config via ResourceName. 

 

Anyone got some pointers? 

Share this post


Link to post
Share on other sites

I ended up figuring it out. But note my observations are from a few versions ago. Didn't quite test it on latest update since things are working for me now.

 

I discovered there is some weirdness with attribute system. Lets say you have an exposed attribute like the following example. Notice how there is a default value (empty array). In the editor things will look hunky-dory. You can add stuff to it.... it works (so it seems). BUT.... my observation is this default value is what ultimately gets assigned at runtime. Once I removed the default assignment.... it works.

 

[Attribute(UIWidgets.Auto, category: "Encounters")];
private ref array<ref TW_AmbientEncounterEntry> encounterConfigs = {};

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×