#Probably due to Unity Serialization

1 messages ยท Page 1 of 1 (latest)

random geyser
#

That is my guess too, would be great if you can shed some more light on it.

sleek mesa
#

Is the struct/class marked as serializable?

random geyser
#

There are no more usages than mentioned. Declared the BufferedInputAction on a vanilla demo script and invoked it in update thats all.

random geyser
#

deliberately

dusk spindle
#

any context? lol

random geyser
#

sure what you need ?

dusk spindle
#

I.. don't need anything.. do you? :p

random geyser
#

I have posted the initial problem outside of this thread, check that out incase you havent, So I have no idea what more context you need. Thus the question ๐Ÿ™‚

random geyser
dusk spindle
#

I meant more like, I can't see the original context

random geyser
#

[Original Message]

I have this basic InputBufferAction struct which utilizes FrameSliceCounter which is also a struct. They work perfectly when I make them serializable or when I make them class (non-serializable) but break when they are struct and non-serializable.

For eg. in image the frameSliceCounter should count 15->14 then in next frame 14-13 and so on, with class and serializedStruct the state(frame Idx) is preserved while with non-serialized struct they dont. Any insights ?

random geyser
dusk spindle
#

@random geyser typically you'd want your structs to be immutable, but pretty sure you already know that.
As for the issue, it might be how you call HasFrameSliceExpired().
Like if you do:

void Update() {
  var action = buffer[0];
  action.HasFrameExpired(); // test
}

the struct would be duplicated, not affecting the one in index 0.. but likely you know that as well (?)

#

it could be a Unity Serialization issue if you're working in editor, but in runtime it shouldn't matter

random geyser
dusk spindle
#

could you also post the code you use to call action.HasFrameSliceExpired just in case?

random geyser
#

Im at work rn, but will send it once im home

#

but im sure Im accessing it directly via array instead of creating a ref holder.