-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Bind Node
methods for getting its SceneState
#104656
base: master
Are you sure you want to change the base?
Conversation
Because we shouldn't expose things on a whim if they are not really needed. |
I have already voiced concerns of exposing things willy-nilly in the past. For the purposes described in the proposal, I think these fit the bill. Granted, it's not much here, but by accepting these PRs for the sake of it, that additional baggage grows. At least, that's how I've felt, looking at this happening for a while. Regarding the PR itself, I can somewhat foresee a confusion between PackedScene and SceneState. For example, users wondering why they can't just |
I think the critical question here is: I.e. does this make you able to fetch this data for cases when you can't do so via other means, like loading the scene file If the answer is no I'd say this is redundant and shouldn't be exposed for the reasons given above If the answer is yes that's a different story |
When an instance exists in a scene, the PackedScene is not loaded, but the SceneState exists. Currently you need PackedScene to obtain SceneState, which means you need to load the scene (which can potentially take a few seconds if it's big). I think that's kind of fine, but |
So to clarify, if I do for example construct a For example: var my_tree := generate_some_node_tree() # This is some function that generates my tree for me, like a level.
var my_packed_scene := PackedScene.new()
my_packed_scene.pack(my_tree)
... # We do something with this, perhaps we pick one randomly or something.
var my_child = my_packed_scene.instantiate()
add_child(my_child)
my_packed_scene = null # For some reason we drop this.
...
var my_state := my_child.get_scene_instance_state() # For some reason we want this. Because in this case we have no other way of getting this, if it even matters What I'm getting at is that if this is a thing we can't do otherwise this is less of a workaround or convenience and more of a genuine necessary feature |
Right now you can do |
That doesn't work if the scene isn't from a file, does it? Check my example again please, does this work for scenes without paths |
Ah yes, the scene needs to be a file. |
It's a made up case in this case because I came up with it on the spot, but it's presented as a case where this method isn't redundant, assuming it does work for such a case I'd say that if evaluated from strictly not wanting to have to fetch the state again this is more clutter than it's worth IMO, but if we consider wanting to fetch the state from non-file based sources is relevant it has a value |
Closes godotengine/godot-proposals#12080.
This adds
Node::get_scene_instance_state
andNode::get_scene_inherited_state
to the script bindings, for the reasons laid out in the proposal linked above.Node::get_scene_inherited_state
is of course somewhat redundant, given the newly exposedSceneState.get_base_scene_state
, but the two seemed to go hand-in-hand, so I figured why not.