Feature Request: Serializable Coroutine for Game Save #2741
Replies: 11 comments 2 replies
-
Coroutines are very much so a Unity-specific thing. It's up to Unity to provide serialization support for them, nothing in the language is prohibiting that. If you need coroutine-like functions to survive saves, I don't recommend using Unity coroutines at all. Personally, I think you should explicitly define the state that should survive saves and reload. Don't try to capture everything, just what actually matters. At the very least, it makes it much easier to version. (As you've suggested, serializing the automatically generated enumerable classes would be very fragile when the code changes.) |
Beta Was this translation helpful? Give feedback.
-
I encounter the need for coroutine before I know Unity and before I know coroutine.
I don't use Unity (see: class XnaLikeGame).
I find writing code on update() is getting harder when the game is getting more complex. |
Beta Was this translation helpful? Give feedback.
-
@isral In C# (and arguably many newer language like js and ts) we tends to use |
Beta Was this translation helpful? Give feedback.
-
Async/await is one of implementation of coroutine, I write about await twice in my proposal, in co_call, and stackoverlow link near the end. |
Beta Was this translation helpful? Give feedback.
-
@isral That's correct, so we don't ever directly use coroutine anymore. Because it was too old. It could be abstracted into I don't said you don't know about it. But I told you to accept that coroutine is not being used on the coding level anymore. It's too old. It is only a legacy of the old style framework. We better write it as |
Beta Was this translation helpful? Give feedback.
-
Can't you do this already with a custom |
Beta Was this translation helpful? Give feedback.
-
I read https://blogs.msdn.microsoft.com/lucian/2016/04/20/async-workflow-2/
But not:
|
Beta Was this translation helpful? Give feedback.
-
I'm closing this as I don't believe this has anything to do with the language. Feel free to correct me if I'm wrong and I'll move this to a discussion. |
Beta Was this translation helpful? Give feedback.
-
I'm currently creating my own language to implement this, but maybe it's too much for me. |
Beta Was this translation helpful? Give feedback.
-
What I meant is, this seems more like a compiler/runtime issue than a language one. Do you have any suggestions as to how the language spec might change to make this possible? |
Beta Was this translation helpful? Give feedback.
-
@YairHalberstadt
C# compiler create several private fields to make local (and temporary) variables preserved across yield. In this proposal, there is a new variant of enumerable object that is user controlled. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I want serializable stackless coroutine for save and load game coroutine.
serialized to
Coroutine is used for game scripting to be more intuitive rather then using a method that called every game update with switch (state) { ... }
Implementation:
I think my proposal is full of flaws, so any fix are welcome.
Beta Was this translation helpful? Give feedback.
All reactions