123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- #include "camera_editor_plugin.h"
- #include "spatial_editor_plugin.h"
- void CameraEditor::_node_removed(Node *p_node) {
- if (p_node == node) {
- node = NULL;
- SpatialEditor::get_singleton()->set_custom_camera(NULL);
- hide();
- }
- }
- void CameraEditor::_pressed() {
- Node *sn = (node && preview->is_pressed()) ? node : NULL;
- SpatialEditor::get_singleton()->set_custom_camera(sn);
- }
- void CameraEditor::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_pressed"), &CameraEditor::_pressed);
- }
- void CameraEditor::edit(Node *p_camera) {
- node = p_camera;
- if (!node) {
- preview->set_pressed(false);
- SpatialEditor::get_singleton()->set_custom_camera(NULL);
- } else {
- if (preview->is_pressed())
- SpatialEditor::get_singleton()->set_custom_camera(p_camera);
- else
- SpatialEditor::get_singleton()->set_custom_camera(NULL);
- }
- }
- CameraEditor::CameraEditor() {
- preview = memnew(Button);
- add_child(preview);
- preview->set_text(TTR("Preview"));
- preview->set_toggle_mode(true);
- preview->set_anchor(MARGIN_LEFT, Control::ANCHOR_END);
- preview->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END);
- preview->set_margin(MARGIN_LEFT, -60);
- preview->set_margin(MARGIN_RIGHT, 0);
- preview->set_margin(MARGIN_TOP, 0);
- preview->set_margin(MARGIN_BOTTOM, 10);
- preview->connect("pressed", this, "_pressed");
- }
- void CameraEditorPlugin::edit(Object *p_object) {
- SpatialEditor::get_singleton()->set_can_preview(Object::cast_to<Camera>(p_object));
-
- }
- bool CameraEditorPlugin::handles(Object *p_object) const {
- return p_object->is_class("Camera");
- }
- void CameraEditorPlugin::make_visible(bool p_visible) {
- if (p_visible) {
-
- } else {
- SpatialEditor::get_singleton()->set_can_preview(NULL);
- }
- }
- CameraEditorPlugin::CameraEditorPlugin(EditorNode *p_node) {
- editor = p_node;
-
- }
- CameraEditorPlugin::~CameraEditorPlugin() {
- }
|