Skip to content

Commit ff561c1

Browse files
committed
Expose set_edited and is_edited on EditorInterface
1 parent 235a32a commit ff561c1

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

doc/classes/EditorInterface.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@
266266
Returns [code]true[/code] if the 3D editor currently has snapping mode enabled, and [code]false[/code] otherwise.
267267
</description>
268268
</method>
269+
<method name="is_object_edited" qualifiers="const">
270+
<return type="bool" />
271+
<param index="0" name="object" type="Object" />
272+
<description>
273+
Returns [code]true[/code] if the object has been marked as edited through [method set_object_edited].
274+
</description>
275+
</method>
269276
<method name="is_playing_scene" qualifiers="const">
270277
<return type="bool" />
271278
<description>
@@ -490,6 +497,16 @@
490497
Sets the editor's current main screen to the one specified in [param name]. [param name] must match the title of the tab in question exactly (e.g. [code]2D[/code], [code]3D[/code], [code skip-lint]Script[/code], [code]Game[/code], or [code]AssetLib[/code] for default tabs).
491498
</description>
492499
</method>
500+
<method name="set_object_edited">
501+
<return type="void" />
502+
<param index="0" name="object" type="Object" />
503+
<param index="1" name="edited" type="bool" />
504+
<description>
505+
If [param edited] is [code]true[/code], the object is marked as edited.
506+
[b]Note:[/b] This is primarily used by the editor for [Resource] based objects to track their modified state. For example, any changes to an open scene, a resource in the inspector, or an edited script will cause this method to be called with [code]true[/code]. Saving the scene, script, or resource resets the edited state by calling this method with [code]false[/code].
507+
[b]Note:[/b] Each call to this method increments the object's edited version. This is used to track changes in the editor and to trigger when thumbnails should be regenerated for resources.
508+
</description>
509+
</method>
493510
<method name="set_plugin_enabled">
494511
<return type="void" />
495512
<param index="0" name="plugin" type="String" />

editor/editor_interface.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,16 @@ void EditorInterface::reload_scene_from_path(const String &scene_path) {
705705
EditorNode::get_singleton()->reload_scene(scene_path);
706706
}
707707

708+
void EditorInterface::set_object_edited(Object *p_object, bool p_edited) {
709+
ERR_FAIL_NULL_MSG(p_object, "Cannot change edited status on a null object.");
710+
p_object->set_edited(p_edited);
711+
}
712+
713+
bool EditorInterface::is_object_edited(Object *p_object) const {
714+
ERR_FAIL_NULL_V_MSG(p_object, false, "Cannot check edit status on a null object.");
715+
return p_object->is_edited();
716+
}
717+
708718
Node *EditorInterface::get_edited_scene_root() const {
709719
return EditorNode::get_singleton()->get_edited_scene();
710720
}
@@ -895,6 +905,9 @@ void EditorInterface::_bind_methods() {
895905
ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath", "set_inherited"), &EditorInterface::open_scene_from_path, DEFVAL(false));
896906
ClassDB::bind_method(D_METHOD("reload_scene_from_path", "scene_filepath"), &EditorInterface::reload_scene_from_path);
897907

908+
ClassDB::bind_method(D_METHOD("set_object_edited", "object", "edited"), &EditorInterface::set_object_edited);
909+
ClassDB::bind_method(D_METHOD("is_object_edited", "object"), &EditorInterface::is_object_edited);
910+
898911
ClassDB::bind_method(D_METHOD("get_open_scenes"), &EditorInterface::get_open_scenes);
899912
ClassDB::bind_method(D_METHOD("get_open_scene_roots"), &EditorInterface::get_open_scene_roots);
900913
ClassDB::bind_method(D_METHOD("get_edited_scene_root"), &EditorInterface::get_edited_scene_root);

editor/editor_interface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ class EditorInterface : public Object {
175175
void open_scene_from_path(const String &scene_path, bool p_set_inherited = false);
176176
void reload_scene_from_path(const String &scene_path);
177177

178+
void set_object_edited(Object *p_object, bool p_edited);
179+
bool is_object_edited(Object *p_object) const;
180+
178181
PackedStringArray get_open_scenes() const;
179182
TypedArray<Node> get_open_scene_roots() const;
180183
Node *get_edited_scene_root() const;

0 commit comments

Comments
 (0)