PhaserEditor2D-v3
PhaserEditor2D-v3 copied to clipboard
Add "Reset to default" to properties of components
It would be a helpful addition if there was an option to reset the value of a property from a user component to its default.
Currently you have to enter the default value yourself.
Try this, delete everything in the field and press ENTER. It should return to the default value.
Here: https://phasereditor2d.com/blog/2020/08/phaser-editor-2d-v350-released-new-tutorial
But I think I don't mention it in the documentation of the editor.
![image](https://user-images.githubusercontent.com/12187299/161363611-dccdff62-7601-42c0-8137-d570facf86b2.png)
Yet I think it is valid to add a visual option for resetting the default value.
In case the property is part of a prefab instance, you can reset its value by locking it. However, I should think how to add a general option.
I've already tried deleting everything and then pressing enter, but it stays blank and in the generated JS file it stays too, just with no value.
I've already tried deleting everything and then pressing enter, but it stays blank and in the generated JS file it stays too, just with no value.
What's the type of the property you want to reset?
It is an Expression. I just checked again and it works for the others.
It is an Expression. I just checked again and it works for the others.
Yes because the empty string is a valid value for the Expression type. I should implement a straight forward method for resetting a value. I'm thinking that in case the field is not part of a prefab instance, I can show a reset button in the place of the lock/unlock button.
That would be great! But if the value is empty, the component is generated like this in the code:
const gameObjectComponent = new Component(gameObject);
gameObjectComponent.someValue;
Is this really supposed to be a valid value?
Thinking more about this.
Making a field blank and pressing ENTER restores it to its default value. If the parameter is part of a prefab instance, then you have the "unlock" icon, for restoring the value to its prefab's default.
The problem is in the parameters of string type in the user components. But user components are deprecated, now we have the Script Nodes. The script nodes work just like prefabs.