External Access of Custom Struct Arrays Causes Null References on Engine Load

Hey everyone,
So I encountered this about a dozen times before I worked out what was causing it: Whenever we were loading the Editor/Game references for even basic classes would be set to null. It turns out that this was happening to classes that were referenced in custom struct arrays that were being accessed from a blueprint without a helper function. Yeah. That ol’ chestnut. Initially we were able to get around this by setting bDeferDependencyLoads to false in BaseEngine.ini but then we continued to have problems and this seems to have solved it.

For an example: We had a team info that stored classes for units and their respective costs. If the game mode directly accessed it’s array of team infos and ran checks on the array units referenced in that spawn cost check would have their mesh and anim blueprint references set to null on engine load. When the team info blueprint has the logic in it for selecting the unit, given a cost, and we call that from the game mode the characters don’t have any issues.

Anyway, I’ve seen a few people having this issue, or similar, so I thought I’d post the work around.