Expose set_edited and is_edited on EditorInterface#91703
Expose set_edited and is_edited on EditorInterface#91703Repiteo merged 1 commit intogodotengine:masterfrom
set_edited and is_edited on EditorInterface#91703Conversation
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. |
Mickeon
left a comment
There was a problem hiding this comment.
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
There was a problem hiding this comment.
| 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
There was a problem hiding this comment.
| 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]. |
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_versionset_edited and is_edited on EditorInterface
d5050ba to
dd2a9ea
Compare
dd2a9ea to
f575861
Compare
f575861 to
a37bc88
Compare
|
Any example plugin to test this?
Sounds like theoretical use-case. |
|
In Orchestrator for example, we want to have a way to mark our custom In addition, there are several spots in the editor where it explicitly uses Another example is in A custom resource that implements its own edited tracking can't make use of any of this behavior at all. So it's not only just a matter of convenience for tracking the state within one's own plugin, but it's also about making sure our custom resources work just like any other Godot resource does, @KoBeWi . |
|
Ah, so it's for resources edited outside the inspector? |
editor/editor_interface.cpp
Outdated
| } | ||
|
|
||
| void EditorInterface::set_object_edited(Object *p_object, bool p_edited) { | ||
| ERR_FAIL_COND_MSG(!p_object, "Cannot change edited status on a null object"); |
There was a problem hiding this comment.
| ERR_FAIL_COND_MSG(!p_object, "Cannot change edited status on a null object"); | |
| ERR_FAIL_NULL_MSG(p_object, "Cannot change edited status on a null object."); |
editor/editor_interface.cpp
Outdated
| } | ||
|
|
||
| bool EditorInterface::is_object_edited(Object *p_object) const { | ||
| ERR_FAIL_COND_V_MSG(!p_object, false, "Cannot check edit status on a null object"); |
There was a problem hiding this comment.
| ERR_FAIL_COND_V_MSG(!p_object, false, "Cannot check edit status on a null object"); | |
| ERR_FAIL_NULL_V_MSG(p_object, false, "Cannot check edit status on a null object."); |
a37bc88 to
ff561c1
Compare
KoBeWi
left a comment
There was a problem hiding this comment.
Still not convinced about is_object_edited(), but otherwise looks fine.
|
Thanks! |
Exposes several tools-based methods on
Object.The reason to expose these is simple. If an editor plugin provides a
EditorResourcePreviewGeneratorimplementation to create thumbnails for custom resources, there isn't a way for the plugin to have theEditorResourcePreviewregenerate 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.