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
Add gui.get and gui.set #8638
Add gui.get and gui.set #8638
Conversation
engine/gui/src/gui_script.cpp
Outdated
* local node_position = gui.get(node, "position") | ||
* ``` | ||
*/ | ||
int LuaGet(lua_State* L) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note about rotation:
For go.get/set we support quaternions for e.g rotation. But for gui when using gui.set_rotation and gui.get_rotation we still use euler angles, so we should probably still support that here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good question.
I believe it will be harder to "fix" later on, if we want ppl to merge their code/functions from GUI into GO space.
So, it might be better to return quaternions here?
Let's ask the others in the team as well!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could expose euler_rotation
as a separate property and have rotation
operate on quaternions like we do in other places?
I think we should look over the other properties as well to ensure their values are consistent with their go
counterparts. I.e. the same property on a go
vs a gui
returning Vector3
values vs Vector4
values or similar discrepancies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could expose
euler_rotation
as a separate property and haverotation
operate on quaternions like we do in other places?
If we do so, it's a breaking change then
Currently expected beh. for devs in gui
is euler
(because this is what gui.get_rotation()
and gui.set_rotation()
do). I think for now it's better to keep it this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not suggesting we change the behaviour of gui.get_rotation()
and gui.set_rotation()
. I'm simply suggesting that we make the new gui.get(node, "rotation")
and gui.set(node, "rotation", value)
return and take a quaternion value respectively.
So it would be inconsistent with the existing gui.get_rotation()
and gui.set_rotation()
functions, but not a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it feels strange
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, to me it feels like it will feel strange either way (i.e. it won't behave the same as go.get
)
Do we have any other votes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we do so, we have to introduce euler
in this PR (as well as it is in go.*
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is gui.animate(node, "rotation", ...)
still work in euler values?
Sounds a little bit strange, that leads to additional logic if I want to make a wrappers around all these functions (gui.set, gui.set_rotation and gui.animate)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
I'd like to see some restructuring of the Set method
engine/gui/src/gui_script.cpp
Outdated
* local node_position = gui.get(node, "position") | ||
* ``` | ||
*/ | ||
int LuaGet(lua_State* L) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good question.
I believe it will be harder to "fix" later on, if we want ppl to merge their code/functions from GUI into GO space.
So, it might be better to return quaternions here?
Let's ask the others in the team as well!
Gui scripts can now query/set node properties via
gui.get
andgui.set
:We have also added a new property to the gui namespace
euler
which is linked with therotation
property. When changing one of them, both will change its underlying data. The important change between them is that therotation
property must be set by quaternion values, and theeuler
property must be set by degree values. You can set a single component of the rotation or the euler properties as usual:There are no custom script properties available, you can only get and set the already existing node properties:
Fixes #5090