[ExecuteInEditMode] setting fields to Null;

I have a RopeSpawn class that spawns rope based on parameters. The class is using [ExecuteInEditMode] to
run in the Editor in order to spawn rope for use of level design, and then Simulate it in PlayMode. Once I create the rope in Editor mode, if I don’t change ANY value after spawning, once I hit PLAY the segmentGroup[ ] that contains all the rope segments sets all references to Null.

I know that the Update() function is only called during variable changes, so I tried putting update in the
Awake() function but it still gives same result. I have to manually change a parameter from the inspector and then hit PLAY to get the correct references.

Why is the editor acting this way? All my fields are serialized and should update when the Editor is in playmode.

Hard to say without seeing your code honestly. Something in your code is likely setting it to null.

void Update()
{
// Destroys all segments on reset
if (reset)
{
foreach (GameObject tmp in segmentGroup)
{
DestroyImmediate(tmp);
}
segmentGroup.Clear();
reset = false;
}
// Spawn segments
if (spawn)
{
// Destroy previous segments
foreach (GameObject t in segmentGroup)
{
DestroyImmediate(t);
}
segmentGroup.Clear();
Spawn();
spawn = false;
}
scale = 0f;
scale = 1f;
}

Spawn() just adds elements to the segmentGroup and thats it. It doesn’t clear the list or delete any entries.

I think because I am creating prefab objects for segments, once the editor changes into playmode they aren’t serialized so they are set to Null. Once I change a value in the editor it reloads that prefab.
Any way around this?

I think it’s more likely to do with the DestroyImmediate() calls, but we’re only seeing a small snippet of your code here.

After completely removing the Destroy/DestroyImmediate functions, it still creates Null values in the List. The only way
to solve the issue is to manually change ANY variable by any amount in the inspector and then hitting PLAY.