浏览代码

Exposing edit_resource method of EditorNode in the EditorPlugin (#7355)

(cherry picked from commit 7e0d0d0bb912fbb774f5890792840a1a62485773)
Bruno Ortiz 8 年之前
父节点
当前提交
4f35fdd1e3
共有 3 个文件被更改,包括 14 次插入0 次删除
  1. 7 0
      doc/base/classes.xml
  2. 6 0
      tools/editor/editor_plugin.cpp
  3. 1 0
      tools/editor/editor_plugin.h

+ 7 - 0
doc/base/classes.xml

@@ -11669,6 +11669,13 @@
 				Get the main editor control. Use this as a parent for main screens.
 			</description>
 		</method>
+		<method name="edit_resource">
+			<argument index="0" name="p_resource" type="Resource">
+			</argument>
+			<description>
+				Tells the editor to handle the edit of the given resource. Ex: If you pass a Script as a argument, the editor will open the scriptEditor.
+			</description>
+		</method>
 		<method name="get_name" qualifiers="virtual">
 			<return type="String">
 			</return>

+ 6 - 0
tools/editor/editor_plugin.cpp

@@ -75,6 +75,11 @@ Control * EditorPlugin::get_editor_viewport() {
 	return EditorNode::get_singleton()->get_viewport();
 }
 
+void EditorPlugin::edit_resource(const Ref<Resource>& p_resource){
+
+	EditorNode::get_singleton()->edit_resource(p_resource);
+}
+
 void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Control *p_control) {
 
 	switch(p_location) {
@@ -327,6 +332,7 @@ void EditorPlugin::_bind_methods() {
 	ObjectTypeDB::bind_method(_MD("get_selection:EditorSelection"),&EditorPlugin::get_selection);
 	ObjectTypeDB::bind_method(_MD("get_editor_settings:EditorSettings"),&EditorPlugin::get_editor_settings);
 	ObjectTypeDB::bind_method(_MD("queue_save_layout"),&EditorPlugin::queue_save_layout);
+	ObjectTypeDB::bind_method(_MD("edit_resource"),&EditorPlugin::edit_resource);
 
 	ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"forward_input_event",PropertyInfo(Variant::INPUT_EVENT,"event")));
 	ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"forward_spatial_input_event",PropertyInfo(Variant::OBJECT,"camera",PROPERTY_HINT_RESOURCE_TYPE,"Camera"),PropertyInfo(Variant::INPUT_EVENT,"event")));

+ 1 - 0
tools/editor/editor_plugin.h

@@ -98,6 +98,7 @@ public:
 	void remove_control_from_docks(Control *p_control);
 	void remove_control_from_bottom_panel(Control *p_control);
 	Control* get_editor_viewport();
+	void edit_resource(const Ref<Resource>& p_resource);
 
 	virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial* p_spatial);
 	virtual bool forward_input_event(const InputEvent& p_event);