Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(LOWEST PRIO) Serialize GameObject with intermediate classes #15

Open
applejag opened this issue Apr 25, 2020 · 0 comments
Open

(LOWEST PRIO) Serialize GameObject with intermediate classes #15

applejag opened this issue Apr 25, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@applejag
Copy link
Owner

Description

Create type for serializing GameObject, to begin with. This idea spans all UnityEngine.Object types. But some fake GameObject type that can be freely serialized and deserialized without creating objects that Unity starts tracking and adding into the scene.

Would allow deserializing of types. Accompanied by some helper methods such as FakeGameObject.ApplyTo(GameObject target) and FakeGameObject.Instantiate().

Would also be good with some deserializing abstract class that the user can define to be able to control wether to instantiate some objects or wether to apply it to an existing object (maybe based on some type or ID field for that object in particular). Perhaps by using the visitor pattern.

A cleaner solution would be to abuse JObject or something, and only having to implement the deserializing logic. Gets complicated when you have to factor in user-defined MonoBehaviours and such

A veeery low prio item but it's still possible to pull off.

Motivation

This is where the idea falls flat.

The cool factor is one aspect.

If it spans most UnityEngine.Object types then it could be used as an alternative scene saving, but without UnityEditor dependency. Maybe as a very simplified (but overpowered) save functionality?

Using it for saving would be bad practice though as it would save far too much info not needed, and perhaps even make it worse when it comes to supporting updates. Users are better off implementing their own save functionality by using custom structs/classes to store information, loaded into prefabs.

Could be good if you want to create a world builder though 🤔 but we already have Unity for that anyways.

So it only lands on cool factor. :/ Would be fun to develop though!

Suggested solution

Some class, such as this one:

class FakeObjectVisitor {
    void VisitObject(FakeObject value) {}
    void VisitGameObject(FakeGameObject value) {}
    void VisitComponent(FakeComponent value) {}
}

That walks the different types and tries to apply the values onto an existing object or instantiate a new one. Working sort of from the deepest to the root (but having to deal with GameObject may not exist that Component is trying to be created onto).

@applejag applejag added the enhancement New feature or request label Apr 25, 2020
@applejag applejag changed the title Suggestion: Serialize GameObject with intermediate classes Suggestion: (LOWEST PRIO) Serialize GameObject with intermediate classes Apr 25, 2020
@applejag applejag changed the title Suggestion: (LOWEST PRIO) Serialize GameObject with intermediate classes (LOWEST PRIO) Serialize GameObject with intermediate classes Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant