-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
Expose set_edited
and is_edited
on EditorInterface
#91703
base: master
Are you sure you want to change the base?
Conversation
doc/classes/Object.xml
Outdated
<return type="void" /> | ||
<param index="0" name="edited" type="bool" /> | ||
<description> | ||
Set whether the object has been edited based on the [param edited] value. |
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.
You may want to include information about when this is changed to true/false by the engine. For example the fact that it is set to false on save.
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.
Updated with the suggestions, thanks.
02515d0
to
60d7146
Compare
60d7146
to
400d3fe
Compare
400d3fe
to
2665d37
Compare
Looks OK, its just adding existing methods to the ClassDB registration so shouldn't think too hard about merging this. |
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.
Starting thoughts, I'm not particularly fond of this. Mainly, these methods feel too "technical", "mechanical" to be needing to be exposed. The additional documentation does not help. Yes, these are used by the engine, but what can the user... use this for?
The above questioning is why we decided to "unexpose" Resource's setup_local_to_scene
(#67082). The method is literally just an internal method exposed for little to no reason: The user could implement it on their own, and documenting its internal purpose was difficult. So we gotta be a bit careful to expose these willy-nilly.
A quick skim over this has me believe that it would be a better fit to expose this in Resource, instead.
And furthermore, these are purely editor-exclusive, and very situational. Too much to be in Object, personally.
This has me think there's got to be a better way to accomplish what one may need this for. Namely, exposing these methods through another Editor-exclusive class.
doc/classes/Object.xml
Outdated
<return type="void" /> | ||
<param index="0" name="edited" type="bool" /> | ||
<description> | ||
Set whether the object has been edited based on the [param edited] value. |
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.
Set whether the object has been edited based on the [param edited] value. | |
If [param edited] is [code]true[/code], the object is marked as edited. |
doc/classes/Object.xml
Outdated
<method name="is_edited" qualifiers="const"> | ||
<return type="bool" /> | ||
<description> | ||
Returns whether the object has been marked as edited using [method set_edited]. |
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.
Returns whether the object has been marked as edited using [method set_edited]. | |
Returns [code]true[/code] if the object has been marked as edited through [method set_edited]. |
doc/classes/Object.xml
Outdated
<method name="get_edited_version" qualifiers="const"> | ||
<return type="int" /> | ||
<description> | ||
Returns the object's current edited version. This version is incremented each time the object's [method set_edited] is called. |
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.
Returns the object's current edited version. This version is incremented each time the object's [method set_edited] is called. | |
Returns the object's current edited version. This value is incremented each time the object's [method set_edited] is called. |
Hi, @Mickeon. There are several reasons for exposing these methods. set_edited: It's common practice in when serializing sub-resources during a save operation to set the resource edited state to is_edited: This one is chosen to be exposed mainly because if GDExtension needs a way to set the state to get_edited_version: This was being exposed primarily to support
For our purposes, exposing this on the void EditorInterface::set_object_edited(Object* p_object, bool p_edited);
bool EditorInterface::is_object_edited(Object* p_object) const; As for the Whats your thoughts on that approach @Mickeon ? |
Sorry for not having much else to add. I am mostly looking at this from a general user perspective. Whether this is actually implemented should not be up to me.
As I hinted at, delegating this to another class may be a better choice. So, personally, yes. |
2665d37
to
d5050ba
Compare
@AThousandShips so I decided on the following, in an attempt to get this into 4.4.
Let me know if you think anything else is needed here. |
set_edited
, is_edited
, and get_edited_version
set_edited
and is_edited
on EditorInterface
Exposes several tools-based methods on
Object
.The reason to expose these is simple. If an editor plugin provides a
EditorResourcePreviewGenerator
implementation to create thumbnails for custom resources, there isn't a way for the plugin to have theEditorResourcePreview
regenerate thumbnails when the resource is modified. In the engine, this is handled by callingset_edited(true)
, which increments the edited version that is used by the hash algorithm to determine whether the cached thumbnail should be discarded and regenerated.By exposing these three methods, addons can easily use the thumbnail generator framework and regenerate the thumbnails when the underlying resource is changed rather than requiring an editor restart.