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

User defined variables in the editor window #9

Closed
PhaserEditor2D opened this issue May 17, 2017 · 5 comments
Closed

User defined variables in the editor window #9

PhaserEditor2D opened this issue May 17, 2017 · 5 comments
Labels
Enhancement New feature or request

Comments

@PhaserEditor2D
Copy link
Owner

(from http://www.bluesaltgames.com developers email)

User defined variables in the editor window – this one is critical. On unity I can create a variable that’s “public” in the code and it’ll show up on the editor for me to alter. This way I can create a prefab with a “life” variable, and create different monsters from that prefab by altering their individual values. This is one of the massively powerful features in Unity and I strongly recommend you to mimic it.

@PhaserEditor2D
Copy link
Owner Author

That's a feature that unity developers always ask and definitively we have to think on a solution for it. In Phaser there is the "data" property (Phaser.Sprite.data) that has that function of "custom properties". We already support it in the editor, you can edit the "data" and write its JSON value:

http://phasereditor.boniatillo.com/blog/quick-start/080-canvas#DataEditor

Sure, it is not so powerful as the Unity model and I am going to think about how to improve the editor in that field. To extract custom properties from JavaScript code could be difficult since there is many ways to do it, it is not like in C#, but we should find a way.

@tomblind
Copy link

The problem with the current data property is that it only works on Phaser.Sprite objects, not Phaser.Group objects. Having a similar capability on groups would be very helpful.

@PhaserEditor2D
Copy link
Owner Author

the data property is not available in groups in Phaser, however I think in the editor we can add it in near release.

@PhaserEditor2D
Copy link
Owner Author

Thinking on this again.

@PhaserEditor2D PhaserEditor2D transferred this issue from PhaserEditor2D/PhaserEditor Jan 14, 2020
@PhaserEditor2D PhaserEditor2D added the Enhancement New feature or request label Jan 14, 2020
@PhaserEditor2D
Copy link
Owner Author

PhaserEditor2D commented Jun 15, 2020

Hi @tomblind,

Done. Now you can define "public" properties in the prefab, and change the property value in the prefab instance.

Key differences with Unity:

  • The properties are declared visually, and code-generated by the scene compiler.

  • The properties do not affect the rendering of the object in the Scene Editor. We don't run user code inside the Scene Editor.

Here is the documentation: https://help.phasereditor2d.com/v3/scene-editor/prefab-user-properties.html

This is a video about it: https://www.youtube.com/watch?v=3ppowkkgz8Q

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

2 participants