summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/image.cpp12
-rw-r--r--doc/classes/TextEdit.xml1
-rw-r--r--editor/editor_properties.cpp38
-rw-r--r--modules/gridmap/grid_map.cpp80
-rw-r--r--modules/gridmap/grid_map.h19
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp57
-rw-r--r--modules/gridmap/grid_map_editor_plugin.h2
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs10
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.cpp4
9 files changed, 129 insertions, 94 deletions
diff --git a/core/image.cpp b/core/image.cpp
index e2b184fcde..e2f353698f 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -1895,8 +1895,10 @@ Vector<uint8_t> Image::get_data() const {
}
void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_format) {
- ERR_FAIL_INDEX(p_width - 1, MAX_WIDTH);
- ERR_FAIL_INDEX(p_height - 1, MAX_HEIGHT);
+ ERR_FAIL_COND_MSG(p_width <= 0, "Image width must be greater than 0.");
+ ERR_FAIL_COND_MSG(p_height <= 0, "Image height must be greater than 0.");
+ ERR_FAIL_COND_MSG(p_width > MAX_WIDTH, "Image width cannot be greater than " + itos(MAX_WIDTH) + ".");
+ ERR_FAIL_COND_MSG(p_height > MAX_HEIGHT, "Image height cannot be greater than " + itos(MAX_HEIGHT) + ".");
ERR_FAIL_COND_MSG(p_width * p_height > MAX_PIXELS, "Too many pixels for image, maximum is " + itos(MAX_PIXELS));
int mm = 0;
@@ -1915,8 +1917,10 @@ void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_forma
}
void Image::create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const Vector<uint8_t> &p_data) {
- ERR_FAIL_INDEX(p_width - 1, MAX_WIDTH);
- ERR_FAIL_INDEX(p_height - 1, MAX_HEIGHT);
+ ERR_FAIL_COND_MSG(p_width <= 0, "Image width must be greater than 0.");
+ ERR_FAIL_COND_MSG(p_height <= 0, "Image height must be greater than 0.");
+ ERR_FAIL_COND_MSG(p_width > MAX_WIDTH, "Image width cannot be greater than " + itos(MAX_WIDTH) + ".");
+ ERR_FAIL_COND_MSG(p_height > MAX_HEIGHT, "Image height cannot be greater than " + itos(MAX_HEIGHT) + ".");
ERR_FAIL_COND_MSG(p_width * p_height > MAX_PIXELS, "Too many pixels for image, maximum is " + itos(MAX_PIXELS));
int mm;
diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml
index 4bdab50b0f..374d50647b 100644
--- a/doc/classes/TextEdit.xml
+++ b/doc/classes/TextEdit.xml
@@ -48,6 +48,7 @@
<return type="void">
</return>
<description>
+ Centers the viewport on the line the editing cursor is at. This also resets the [member scroll_horizontal] value to [code]0[/code].
</description>
</method>
<method name="clear_colors">
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 23db6ebb4e..8f9c92ea15 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -2983,8 +2983,16 @@ bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const
String allowed_type = base_type;
Dictionary drag_data = p_drag_data;
- if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
- Ref<Resource> res = drag_data["resource"];
+
+ Ref<Resource> res;
+ if (drag_data.has("type") && String(drag_data["type"]) == "script_list_element") {
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(drag_data["script_list_element"]);
+ res = se->get_edited_resource();
+ } else if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
+ res = drag_data["resource"];
+ }
+
+ if (res.is_valid()) {
for (int i = 0; i < allowed_type.get_slice_count(","); i++) {
String at = allowed_type.get_slice(",", i).strip_edges();
if (res.is_valid() && ClassDB::is_parent_class(res->get_class(), at)) {
@@ -3022,13 +3030,19 @@ void EditorPropertyResource::drop_data_fw(const Point2 &p_point, const Variant &
ERR_FAIL_COND(!_is_drop_valid(p_data));
Dictionary drag_data = p_data;
- if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
- Ref<Resource> res = drag_data["resource"];
- if (res.is_valid()) {
- emit_changed(get_edited_property(), res);
- update_property();
- return;
- }
+
+ Ref<Resource> res;
+ if (drag_data.has("type") && String(drag_data["type"]) == "script_list_element") {
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(drag_data["script_list_element"]);
+ res = se->get_edited_resource();
+ } else if (drag_data.has("type") && String(drag_data["type"]) == "resource") {
+ res = drag_data["resource"];
+ }
+
+ if (res.is_valid()) {
+ emit_changed(get_edited_property(), res);
+ update_property();
+ return;
}
if (drag_data.has("type") && String(drag_data["type"]) == "files") {
@@ -3036,9 +3050,9 @@ void EditorPropertyResource::drop_data_fw(const Point2 &p_point, const Variant &
if (files.size() == 1) {
String file = files[0];
- RES res = ResourceLoader::load(file);
- if (res.is_valid()) {
- emit_changed(get_edited_property(), res);
+ RES file_res = ResourceLoader::load(file);
+ if (file_res.is_valid()) {
+ emit_changed(get_edited_property(), file_res);
update_property();
return;
}
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 2975a97bfe..ccf1e49693 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -244,26 +244,26 @@ bool GridMap::get_center_z() const {
return center_z;
}
-void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
+void GridMap::set_cell_item(const Vector3i &p_position, int p_item, int p_rot) {
if (baked_meshes.size() && !recreating_octants) {
//if you set a cell item, baked meshes go good bye
clear_baked_meshes();
_recreate_octant_data();
}
- ERR_FAIL_INDEX(ABS(p_x), 1 << 20);
- ERR_FAIL_INDEX(ABS(p_y), 1 << 20);
- ERR_FAIL_INDEX(ABS(p_z), 1 << 20);
+ ERR_FAIL_INDEX(ABS(p_position.x), 1 << 20);
+ ERR_FAIL_INDEX(ABS(p_position.y), 1 << 20);
+ ERR_FAIL_INDEX(ABS(p_position.z), 1 << 20);
IndexKey key;
- key.x = p_x;
- key.y = p_y;
- key.z = p_z;
+ key.x = p_position.x;
+ key.y = p_position.y;
+ key.z = p_position.z;
OctantKey ok;
- ok.x = p_x / octant_size;
- ok.y = p_y / octant_size;
- ok.z = p_z / octant_size;
+ ok.x = p_position.x / octant_size;
+ ok.y = p_position.y / octant_size;
+ ok.z = p_position.z / octant_size;
if (p_item < 0) {
//erase
@@ -318,15 +318,15 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
cell_map[key] = c;
}
-int GridMap::get_cell_item(int p_x, int p_y, int p_z) const {
- ERR_FAIL_INDEX_V(ABS(p_x), 1 << 20, INVALID_CELL_ITEM);
- ERR_FAIL_INDEX_V(ABS(p_y), 1 << 20, INVALID_CELL_ITEM);
- ERR_FAIL_INDEX_V(ABS(p_z), 1 << 20, INVALID_CELL_ITEM);
+int GridMap::get_cell_item(const Vector3i &p_position) const {
+ ERR_FAIL_INDEX_V(ABS(p_position.x), 1 << 20, INVALID_CELL_ITEM);
+ ERR_FAIL_INDEX_V(ABS(p_position.y), 1 << 20, INVALID_CELL_ITEM);
+ ERR_FAIL_INDEX_V(ABS(p_position.z), 1 << 20, INVALID_CELL_ITEM);
IndexKey key;
- key.x = p_x;
- key.y = p_y;
- key.z = p_z;
+ key.x = p_position.x;
+ key.y = p_position.y;
+ key.z = p_position.z;
if (!cell_map.has(key)) {
return INVALID_CELL_ITEM;
@@ -334,15 +334,15 @@ int GridMap::get_cell_item(int p_x, int p_y, int p_z) const {
return cell_map[key].item;
}
-int GridMap::get_cell_item_orientation(int p_x, int p_y, int p_z) const {
- ERR_FAIL_INDEX_V(ABS(p_x), 1 << 20, -1);
- ERR_FAIL_INDEX_V(ABS(p_y), 1 << 20, -1);
- ERR_FAIL_INDEX_V(ABS(p_z), 1 << 20, -1);
+int GridMap::get_cell_item_orientation(const Vector3i &p_position) const {
+ ERR_FAIL_INDEX_V(ABS(p_position.x), 1 << 20, -1);
+ ERR_FAIL_INDEX_V(ABS(p_position.y), 1 << 20, -1);
+ ERR_FAIL_INDEX_V(ABS(p_position.z), 1 << 20, -1);
IndexKey key;
- key.x = p_x;
- key.y = p_y;
- key.z = p_z;
+ key.x = p_position.x;
+ key.y = p_position.y;
+ key.z = p_position.z;
if (!cell_map.has(key)) {
return -1;
@@ -350,20 +350,20 @@ int GridMap::get_cell_item_orientation(int p_x, int p_y, int p_z) const {
return cell_map[key].rot;
}
-Vector3 GridMap::world_to_map(const Vector3 &p_world_pos) const {
- Vector3 map_pos = p_world_pos / cell_size;
- map_pos.x = floor(map_pos.x);
- map_pos.y = floor(map_pos.y);
- map_pos.z = floor(map_pos.z);
- return map_pos;
+Vector3i GridMap::world_to_map(const Vector3 &p_world_position) const {
+ Vector3 map_position = p_world_position / cell_size;
+ map_position.x = floor(map_position.x);
+ map_position.y = floor(map_position.y);
+ map_position.z = floor(map_position.z);
+ return Vector3i(map_position);
}
-Vector3 GridMap::map_to_world(int p_x, int p_y, int p_z) const {
+Vector3 GridMap::map_to_world(const Vector3i &p_map_position) const {
Vector3 offset = _get_offset();
Vector3 world_pos(
- p_x * cell_size.x + offset.x,
- p_y * cell_size.y + offset.y,
- p_z * cell_size.z + offset.z);
+ p_map_position.x * cell_size.x + offset.x,
+ p_map_position.y * cell_size.y + offset.y,
+ p_map_position.z * cell_size.z + offset.z);
return world_pos;
}
@@ -725,7 +725,7 @@ void GridMap::_recreate_octant_data() {
Map<IndexKey, Cell> cell_copy = cell_map;
_clear_internal();
for (Map<IndexKey, Cell>::Element *E = cell_copy.front(); E; E = E->next()) {
- set_cell_item(E->key().x, E->key().y, E->key().z, E->get().item, E->get().rot);
+ set_cell_item(Vector3i(E->key()), E->get().item, E->get().rot);
}
recreating_octants = false;
}
@@ -799,12 +799,12 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_octant_size", "size"), &GridMap::set_octant_size);
ClassDB::bind_method(D_METHOD("get_octant_size"), &GridMap::get_octant_size);
- ClassDB::bind_method(D_METHOD("set_cell_item", "x", "y", "z", "item", "orientation"), &GridMap::set_cell_item, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("get_cell_item", "x", "y", "z"), &GridMap::get_cell_item);
- ClassDB::bind_method(D_METHOD("get_cell_item_orientation", "x", "y", "z"), &GridMap::get_cell_item_orientation);
+ ClassDB::bind_method(D_METHOD("set_cell_item", "position", "item", "orientation"), &GridMap::set_cell_item, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_cell_item", "position"), &GridMap::get_cell_item);
+ ClassDB::bind_method(D_METHOD("get_cell_item_orientation", "position"), &GridMap::get_cell_item_orientation);
- ClassDB::bind_method(D_METHOD("world_to_map", "pos"), &GridMap::world_to_map);
- ClassDB::bind_method(D_METHOD("map_to_world", "x", "y", "z"), &GridMap::map_to_world);
+ ClassDB::bind_method(D_METHOD("world_to_map", "world_position"), &GridMap::world_to_map);
+ ClassDB::bind_method(D_METHOD("map_to_world", "map_position"), &GridMap::map_to_world);
ClassDB::bind_method(D_METHOD("_update_octants_callback"), &GridMap::_update_octants_callback);
ClassDB::bind_method(D_METHOD("resource_changed", "resource"), &GridMap::resource_changed);
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index 9eb9aee7d1..ca7429ea26 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -59,6 +59,15 @@ class GridMap : public Node3D {
return key < p_key.key;
}
+ _FORCE_INLINE_ operator Vector3i() const {
+ return Vector3i(x, y, z);
+ }
+
+ IndexKey(Vector3i p_vector) {
+ x = (int16_t)p_vector.x;
+ y = (int16_t)p_vector.y;
+ z = (int16_t)p_vector.z;
+ }
IndexKey() { key = 0; }
};
@@ -234,12 +243,12 @@ public:
void set_center_z(bool p_enable);
bool get_center_z() const;
- void set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot = 0);
- int get_cell_item(int p_x, int p_y, int p_z) const;
- int get_cell_item_orientation(int p_x, int p_y, int p_z) const;
+ void set_cell_item(const Vector3i &p_position, int p_item, int p_rot = 0);
+ int get_cell_item(const Vector3i &p_position) const;
+ int get_cell_item_orientation(const Vector3i &p_position) const;
- Vector3 world_to_map(const Vector3 &p_world_pos) const;
- Vector3 map_to_world(int p_x, int p_y, int p_z) const;
+ Vector3i world_to_map(const Vector3 &p_world_position) const;
+ Vector3 map_to_world(const Vector3i &p_map_position) const;
void set_clip(bool p_enabled, bool p_clip_above = true, int p_floor = 0, Vector3::Axis p_axis = Vector3::AXIS_X);
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 1b7ce98721..0e6ec7f520 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -291,15 +291,15 @@ void GridMapEditor::_update_selection_transform() {
} else {
Vector3 scale = (selection.end - selection.begin + Vector3(1, 1, 1));
scale[edit_axis] = 1.0;
- Vector3 pos = selection.begin;
- pos[edit_axis] = edit_floor[edit_axis];
+ Vector3 position = selection.begin;
+ position[edit_axis] = edit_floor[edit_axis];
scale *= node->get_cell_size();
- pos *= node->get_cell_size();
+ position *= node->get_cell_size();
Transform xf2;
xf2.basis.scale(scale);
- xf2.origin = pos;
+ xf2.origin = position;
RenderingServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf2);
}
@@ -414,11 +414,11 @@ bool GridMapEditor::do_input_action(Camera3D *p_camera, const Point2 &p_point, b
}
if (input_action == INPUT_PASTE) {
- paste_indicator.current = Vector3(cell[0], cell[1], cell[2]);
+ paste_indicator.current = Vector3i(cell[0], cell[1], cell[2]);
_update_paste_indicator();
} else if (input_action == INPUT_SELECT) {
- selection.current = Vector3(cell[0], cell[1], cell[2]);
+ selection.current = Vector3i(cell[0], cell[1], cell[2]);
if (p_click) {
selection.click = selection.current;
}
@@ -427,7 +427,7 @@ bool GridMapEditor::do_input_action(Camera3D *p_camera, const Point2 &p_point, b
return true;
} else if (input_action == INPUT_PICK) {
- int item = node->get_cell_item(cell[0], cell[1], cell[2]);
+ int item = node->get_cell_item(Vector3i(cell[0], cell[1], cell[2]));
if (item >= 0) {
selected_palette = item;
mesh_library_palette->set_current(item);
@@ -438,23 +438,23 @@ bool GridMapEditor::do_input_action(Camera3D *p_camera, const Point2 &p_point, b
}
if (input_action == INPUT_PAINT) {
SetItem si;
- si.pos = Vector3(cell[0], cell[1], cell[2]);
+ si.position = Vector3i(cell[0], cell[1], cell[2]);
si.new_value = selected_palette;
si.new_orientation = cursor_rot;
- si.old_value = node->get_cell_item(cell[0], cell[1], cell[2]);
- si.old_orientation = node->get_cell_item_orientation(cell[0], cell[1], cell[2]);
+ si.old_value = node->get_cell_item(Vector3i(cell[0], cell[1], cell[2]));
+ si.old_orientation = node->get_cell_item_orientation(Vector3i(cell[0], cell[1], cell[2]));
set_items.push_back(si);
- node->set_cell_item(cell[0], cell[1], cell[2], selected_palette, cursor_rot);
+ node->set_cell_item(Vector3i(cell[0], cell[1], cell[2]), selected_palette, cursor_rot);
return true;
} else if (input_action == INPUT_ERASE) {
SetItem si;
- si.pos = Vector3(cell[0], cell[1], cell[2]);
+ si.position = Vector3i(cell[0], cell[1], cell[2]);
si.new_value = -1;
si.new_orientation = 0;
- si.old_value = node->get_cell_item(cell[0], cell[1], cell[2]);
- si.old_orientation = node->get_cell_item_orientation(cell[0], cell[1], cell[2]);
+ si.old_value = node->get_cell_item(Vector3i(cell[0], cell[1], cell[2]));
+ si.old_orientation = node->get_cell_item_orientation(Vector3i(cell[0], cell[1], cell[2]));
set_items.push_back(si);
- node->set_cell_item(cell[0], cell[1], cell[2], -1);
+ node->set_cell_item(Vector3i(cell[0], cell[1], cell[2]), -1);
return true;
}
@@ -470,8 +470,9 @@ void GridMapEditor::_delete_selection() {
for (int i = selection.begin.x; i <= selection.end.x; i++) {
for (int j = selection.begin.y; j <= selection.end.y; j++) {
for (int k = selection.begin.z; k <= selection.end.z; k++) {
- undo_redo->add_do_method(node, "set_cell_item", i, j, k, GridMap::INVALID_CELL_ITEM);
- undo_redo->add_undo_method(node, "set_cell_item", i, j, k, node->get_cell_item(i, j, k), node->get_cell_item_orientation(i, j, k));
+ Vector3i selected = Vector3i(i, j, k);
+ undo_redo->add_do_method(node, "set_cell_item", selected, GridMap::INVALID_CELL_ITEM);
+ undo_redo->add_undo_method(node, "set_cell_item", selected, node->get_cell_item(selected), node->get_cell_item_orientation(selected));
}
}
}
@@ -489,8 +490,9 @@ void GridMapEditor::_fill_selection() {
for (int i = selection.begin.x; i <= selection.end.x; i++) {
for (int j = selection.begin.y; j <= selection.end.y; j++) {
for (int k = selection.begin.z; k <= selection.end.z; k++) {
- undo_redo->add_do_method(node, "set_cell_item", i, j, k, selected_palette, cursor_rot);
- undo_redo->add_undo_method(node, "set_cell_item", i, j, k, node->get_cell_item(i, j, k), node->get_cell_item_orientation(i, j, k));
+ Vector3i selected = Vector3i(i, j, k);
+ undo_redo->add_do_method(node, "set_cell_item", selected, selected_palette, cursor_rot);
+ undo_redo->add_undo_method(node, "set_cell_item", selected, node->get_cell_item(selected), node->get_cell_item_orientation(selected));
}
}
}
@@ -515,7 +517,8 @@ void GridMapEditor::_set_clipboard_data() {
for (int i = selection.begin.x; i <= selection.end.x; i++) {
for (int j = selection.begin.y; j <= selection.end.y; j++) {
for (int k = selection.begin.z; k <= selection.end.z; k++) {
- int itm = node->get_cell_item(i, j, k);
+ Vector3i selected = Vector3i(i, j, k);
+ int itm = node->get_cell_item(selected);
if (itm == GridMap::INVALID_CELL_ITEM) {
continue;
}
@@ -524,8 +527,8 @@ void GridMapEditor::_set_clipboard_data() {
ClipboardItem item;
item.cell_item = itm;
- item.grid_offset = Vector3(i, j, k) - selection.begin;
- item.orientation = node->get_cell_item_orientation(i, j, k);
+ item.grid_offset = Vector3(selected) - selection.begin;
+ item.orientation = node->get_cell_item_orientation(selected);
item.instance = RenderingServer::get_singleton()->instance_create2(mesh->get_rid(), get_tree()->get_root()->get_world_3d()->get_scenario());
clipboard_items.push_back(item);
@@ -583,14 +586,14 @@ void GridMapEditor::_do_paste() {
for (List<ClipboardItem>::Element *E = clipboard_items.front(); E; E = E->next()) {
ClipboardItem &item = E->get();
- Vector3 pos = rot.xform(item.grid_offset) + paste_indicator.begin + ofs;
+ Vector3 position = rot.xform(item.grid_offset) + paste_indicator.begin + ofs;
Basis orm;
orm.set_orthogonal_index(item.orientation);
orm = rot * orm;
- undo_redo->add_do_method(node, "set_cell_item", pos.x, pos.y, pos.z, item.cell_item, orm.get_orthogonal_index());
- undo_redo->add_undo_method(node, "set_cell_item", pos.x, pos.y, pos.z, node->get_cell_item(pos.x, pos.y, pos.z), node->get_cell_item_orientation(pos.x, pos.y, pos.z));
+ undo_redo->add_do_method(node, "set_cell_item", position, item.cell_item, orm.get_orthogonal_index());
+ undo_redo->add_undo_method(node, "set_cell_item", position, node->get_cell_item(position), node->get_cell_item_orientation(position));
}
if (reselect) {
@@ -667,11 +670,11 @@ bool GridMapEditor::forward_spatial_input_event(Camera3D *p_camera, const Ref<In
undo_redo->create_action(TTR("GridMap Paint"));
for (List<SetItem>::Element *E = set_items.front(); E; E = E->next()) {
const SetItem &si = E->get();
- undo_redo->add_do_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.new_value, si.new_orientation);
+ undo_redo->add_do_method(node, "set_cell_item", si.position, si.new_value, si.new_orientation);
}
for (List<SetItem>::Element *E = set_items.back(); E; E = E->prev()) {
const SetItem &si = E->get();
- undo_redo->add_undo_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.old_value, si.old_orientation);
+ undo_redo->add_undo_method(node, "set_cell_item", si.position, si.old_value, si.old_orientation);
}
undo_redo->commit_action();
diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h
index 31a01cdc91..84b68ba6e7 100644
--- a/modules/gridmap/grid_map_editor_plugin.h
+++ b/modules/gridmap/grid_map_editor_plugin.h
@@ -84,7 +84,7 @@ class GridMapEditor : public VBoxContainer {
Label *spin_box_label;
struct SetItem {
- Vector3 pos;
+ Vector3i position;
int new_value;
int new_orientation;
int old_value;
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs
index 9384da0e48..e050d1fdd1 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs
@@ -84,7 +84,7 @@ namespace Godot
public static void Print(params object[] what)
{
- godot_icall_GD_print(Array.ConvertAll(what, x => x?.ToString()));
+ godot_icall_GD_print(Array.ConvertAll(what ?? new object[]{"null"}, x => x != null ? x.ToString() : "null"));
}
public static void PrintStack()
@@ -94,22 +94,22 @@ namespace Godot
public static void PrintErr(params object[] what)
{
- godot_icall_GD_printerr(Array.ConvertAll(what, x => x?.ToString()));
+ godot_icall_GD_printerr(Array.ConvertAll(what ?? new object[]{"null"}, x => x != null ? x.ToString() : "null"));
}
public static void PrintRaw(params object[] what)
{
- godot_icall_GD_printraw(Array.ConvertAll(what, x => x?.ToString()));
+ godot_icall_GD_printraw(Array.ConvertAll(what ?? new object[]{"null"}, x => x != null ? x.ToString() : "null"));
}
public static void PrintS(params object[] what)
{
- godot_icall_GD_prints(Array.ConvertAll(what, x => x?.ToString()));
+ godot_icall_GD_prints(Array.ConvertAll(what ?? new object[]{"null"}, x => x != null ? x.ToString() : "null"));
}
public static void PrintT(params object[] what)
{
- godot_icall_GD_printt(Array.ConvertAll(what, x => x?.ToString()));
+ godot_icall_GD_printt(Array.ConvertAll(what ?? new object[]{"null"}, x => x != null ? x.ToString() : "null"));
}
public static float Randf()
diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp
index 158742846b..92734a0792 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.cpp
+++ b/modules/mono/mono_gd/gd_mono_marshal.cpp
@@ -1035,6 +1035,10 @@ Variant mono_object_to_variant_no_err(MonoObject *p_obj, const ManagedType &p_ty
}
String mono_object_to_variant_string(MonoObject *p_obj, MonoException **r_exc) {
+ if (p_obj == nullptr) {
+ return String("null");
+ }
+
ManagedType type = ManagedType::from_class(mono_object_get_class(p_obj));
Variant var = GDMonoMarshal::mono_object_to_variant_no_err(p_obj, type);