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

Refactor in Prefab system #106

Open
ncannasse opened this issue Mar 26, 2021 · 2 comments
Open

Refactor in Prefab system #106

ncannasse opened this issue Mar 26, 2021 · 2 comments

Comments

@ncannasse
Copy link
Member

Currently the prefab system is a bit hard to work with because of the factory model:

  • some prefabs does have a member variable referencing their scene object, so they won't work in multiple references
  • it is difficult to deal with the Context API, because you can't store all per-instances variables you might want
  • serialization of fields is done by hand (load/save)
  • modifying prefab data at runtime lead to this data being modified for later instances

I propose we change the following:

  • each prefab have serialization through macros (@:s) + custom save/load if needed
  • when doing make, we clone() the prefab then makeInstance the clone, so we keep the original "factory" prefab untouched but the instantiated one will hold a reference to the scene object (it be its own Context).
  • remove Context (or actually ContextShared become Context)

Ping @trethaller @D0pu for comments

@ncannasse
Copy link
Member Author

After this refactor, another refactor in edit():

  • we want a quick way to edit prefab fields
  • some metadata is required (float ranges)
  • undo should be taken care directly
  • we want to be able customize the UI

Instead of having a lot of metadata in the prefab vars decl that will not work when wanting to do custom things, the idea is instead to be able to declare things very briefly in edit():

For example:

group("Advanced", [
    range(alpha, 0, 1),
    bool(props.visible),
]); 
...

@ncannasse
Copy link
Member Author

ncannasse commented Mar 27, 2021

  • remove Library (use directly Prefab)
  • add loadDeps so references and binary data is loaded before make() -- refactor prefab loading using Library.loadFile that does loadData+loadDeps
  • review prefab cache & reload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant