Expose editor viewports
This commit is contained in:
parent
0ca8542329
commit
110130bb69
@ -116,6 +116,19 @@
|
||||
[b]Note:[/b] When creating custom editor UI, prefer accessing theme items directly from your GUI nodes using the [code]get_theme_*[/code] methods.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_editor_viewport_2d" qualifiers="const">
|
||||
<return type="SubViewport" />
|
||||
<description>
|
||||
Returns the 2D editor [SubViewport]. It does not have a camera. Instead, the view transforms are done directly and can be accessed with [member Viewport.global_canvas_transform].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_editor_viewport_3d" qualifiers="const">
|
||||
<return type="SubViewport" />
|
||||
<param index="0" name="idx" type="int" default="0" />
|
||||
<description>
|
||||
Returns the specified 3D editor [SubViewport], from [code]0[/code] to [code]3[/code]. The viewport can be used to access the active editor cameras with [method Viewport.get_camera_3d].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_file_system_dock" qualifiers="const">
|
||||
<return type="FileSystemDock" />
|
||||
<description>
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "editor/filesystem_dock.h"
|
||||
#include "editor/gui/editor_run_bar.h"
|
||||
#include "editor/inspector_dock.h"
|
||||
#include "editor/plugins/node_3d_editor_plugin.h"
|
||||
#include "main/main.h"
|
||||
#include "scene/gui/box_container.h"
|
||||
#include "scene/gui/control.h"
|
||||
@ -213,6 +214,15 @@ ScriptEditor *EditorInterface::get_script_editor() const {
|
||||
return ScriptEditor::get_singleton();
|
||||
}
|
||||
|
||||
SubViewport *EditorInterface::get_editor_viewport_2d() const {
|
||||
return EditorNode::get_singleton()->get_scene_root();
|
||||
}
|
||||
|
||||
SubViewport *EditorInterface::get_editor_viewport_3d(int p_idx) const {
|
||||
ERR_FAIL_INDEX_V(p_idx, static_cast<int>(Node3DEditor::VIEWPORTS_COUNT), nullptr);
|
||||
return Node3DEditor::get_singleton()->get_editor_viewport(p_idx)->get_viewport_node();
|
||||
}
|
||||
|
||||
void EditorInterface::set_main_screen_editor(const String &p_name) {
|
||||
EditorNode::get_singleton()->select_editor_by_name(p_name);
|
||||
}
|
||||
@ -414,6 +424,8 @@ void EditorInterface::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_base_control"), &EditorInterface::get_base_control);
|
||||
ClassDB::bind_method(D_METHOD("get_editor_main_screen"), &EditorInterface::get_editor_main_screen);
|
||||
ClassDB::bind_method(D_METHOD("get_script_editor"), &EditorInterface::get_script_editor);
|
||||
ClassDB::bind_method(D_METHOD("get_editor_viewport_2d"), &EditorInterface::get_editor_viewport_2d);
|
||||
ClassDB::bind_method(D_METHOD("get_editor_viewport_3d", "idx"), &EditorInterface::get_editor_viewport_3d, DEFVAL(0));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_main_screen_editor", "name"), &EditorInterface::set_main_screen_editor);
|
||||
ClassDB::bind_method(D_METHOD("set_distraction_free_mode", "enter"), &EditorInterface::set_distraction_free_mode);
|
||||
|
@ -49,6 +49,7 @@ class FileSystemDock;
|
||||
class Mesh;
|
||||
class Node;
|
||||
class ScriptEditor;
|
||||
class SubViewport;
|
||||
class Texture2D;
|
||||
class Theme;
|
||||
class VBoxContainer;
|
||||
@ -92,6 +93,8 @@ public:
|
||||
Control *get_base_control() const;
|
||||
VBoxContainer *get_editor_main_screen() const;
|
||||
ScriptEditor *get_script_editor() const;
|
||||
SubViewport *get_editor_viewport_2d() const;
|
||||
SubViewport *get_editor_viewport_3d(int p_idx = 0) const;
|
||||
|
||||
void set_main_screen_editor(const String &p_name);
|
||||
void set_distraction_free_mode(bool p_enter);
|
||||
|
Loading…
Reference in New Issue
Block a user