diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-08-03 09:38:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-03 09:38:03 +0200 |
commit | 57a5186b08af19f9e8c88df836b36d6ed2da76a8 (patch) | |
tree | 97886de69b3b3f7914c182e0c6e398344b75f9cf /editor | |
parent | c6879b150f6094d3836a86b0182d017f8cb8d3d1 (diff) | |
parent | 07a8f0fe3822edf39df737dcd82071e8ab80b4b0 (diff) |
Merge pull request #51006 from foxydevloper/drag-drop-naming
Name nodes added when drag & dropping an image by `name_casing`
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 61d435cde1..16e224b105 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -5815,7 +5815,22 @@ bool CanvasItemEditorViewport::_cyclical_dependency_exists(const String &p_targe } void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point) { - child->set_name(path.get_file().get_basename()); + // Adjust casing according to project setting. The file name is expected to be in snake_case, but will work for others. + String name = path.get_file().get_basename(); + switch (ProjectSettings::get_singleton()->get("editor/node_naming/name_casing").operator int()) { + case NAME_CASING_PASCAL_CASE: + name = name.capitalize().replace(" ", ""); + break; + case NAME_CASING_CAMEL_CASE: + name = name.capitalize().replace(" ", ""); + name[0] = name.to_lower()[0]; + break; + case NAME_CASING_SNAKE_CASE: + name = name.capitalize().replace(" ", "_").to_lower(); + break; + } + child->set_name(name); + Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(ResourceCache::get(path))); Size2 texture_size = texture->get_size(); |