UH oh, now I find out that what Batch code can easily do in a breeze, nest arrays inside of arrays but it looks like to me Unreal Engine runs into nesting troubles trying to do the same, and then corrupts itself. It seems the blueprints have trouble with nesting things.
Struct invalidating when adding array elements inside it
TL;DR Adding elements to an array within a struct within a struct corrupts the outer most struct and every blueprint that had used it.
When the struct is corrupted, this message is given:
So you go and delete all references to these variables in your blueprint. All calls, all functions with output/inputs, all “make structs,” etc., and even deleting all variables and local variables.
After all that, it still tells you there are variables with invalid types, even though none are showing up in your variables section under “My Blueprint” because you have already deleted them.
For some reason, not even “Remove unused variables” works, saying there are no variables to search for.
The only way around this is to either recreating all the corrupt blueprints (copying and pasting doesn’t work, as it is a reference error to the struct) or importing everything to a new project.
Steps to Reproduce:
I have reproduced this problem in a clean project, and the steps are as follows:
- Create a struct with an array in it. We’ll call this
- Create a struct that has a
Struct1inside it. We’ll call this
Struct2in any context. Parameters, variables, make nodes, etc.
- Go back to
Struct1, expand the array, and add in more elements.
After doing all of the above, all references to
Struct2 have corrupted.
EDIT: Also, God forbid you referenced these variables in your level blueprint, as now your whole level is corrupt.
Thank you for submitting a bug report. I have reproduced this issue and logged a report for it here
You can track the report’s status as the issue is reviewed by our development staff. Please be aware that this issue may not be prioritized or fixed soon.
How are you currently dealing with this? I just got this issue and have no idea what to do, I’d probably have to spend hours just re-wiring everything…
Issue has been deleted?
The link is still open, there is an extra period in the URL, I have now removed it and it should link to the correct page
Ah I see, thanks!
Yup, spent hours.
I haven’t ran into this situation since then, as in, I’ve never had to create this system, but what I did do was just try to plan ahead more, and create a backup when I tried to change stuff around.
Hours wasted, indeed.
Sounds like It might be corrupting something.
I’m wondering if I’m missing something big here. This open issue seems to be literally development halting for any project that makes a moderate use of structs in Blueprint, yet UE-41411 and UE-40033 both list target fix estimates of 4.18, which seem like it’s a heck of a long way off (and I don’t even know if that estimate is just short-hand meaning, “we haven’t started looking into it yet”).
Is there some workaround that won’t result in corrupting 50+ source files of mine when I change or add one variable to a struct? Shouldn’t there be more attention put toward fixing this issue in the short term? I upgraded my project from 4.12 and had no idea that it was going to prevent me from achieving certain development goals.
I finally found a workaround to this problem.
- Open project in UE4.
- Go to your project’s content folder in explorer, and recursively make everything read only. (I did this on Content\FirstPersonBP\Blueprints for my project)
- In explorer, locate the child struct and parent struct(s) that you want to change, and uncheck read only.
- Change the child struct as you please, and save it. Then save the parent struct(s).
- Close the UE4 editor (don’t let it save the files it thinks has changed, it won’t be able to anyway).
- Go back to explorer where you recursively made everything read only, and uncheck read only.
- Open your project back up.
- Rejoice, for your old code is still together and functional!
Fundamentally, it seems like changing a child struct destroys the parent struct for long enough that any assets using the parent struct have a bunch of references removed. So, if you make those assets read-only, the UE4 editor can’t stomp all over them.
What a frustrating bug. Hours upon hours wasted…
This bug is some hot garbage it broke nearly my entire project and is definitely not fixed in 4.21 after doing a hot reload.
Just a note if anyone is stuck with the issue where you cant delete the hidden variables which prevent your scripts from running, right click on the asset in the content browser and go to ‘Asset Actions->Reload’ to get the prompt to remove the invalid variables.