diff --git a/editor/icons/2x/icon_script_create.png b/editor/icons/2x/icon_script_create.png
new file mode 100644
index 00000000000..67f80e8760f
Binary files /dev/null and b/editor/icons/2x/icon_script_create.png differ
diff --git a/editor/icons/icon_script_create.png b/editor/icons/icon_script_create.png
new file mode 100644
index 00000000000..f5d8b0cfd6f
Binary files /dev/null and b/editor/icons/icon_script_create.png differ
diff --git a/editor/icons/source/icon_script_create.svg b/editor/icons/source/icon_script_create.svg
new file mode 100644
index 00000000000..c3f69c46017
--- /dev/null
+++ b/editor/icons/source/icon_script_create.svg
@@ -0,0 +1,96 @@
+
+
+
+
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 1b99ecdd7a9..1d0449e440e 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -194,6 +194,12 @@ void CustomPropertyEditor::_menu_option(int p_which) {
}
}
} break;
+ case OBJ_MENU_NEW_SCRIPT: {
+
+ if (owner->cast_to())
+ EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(owner->cast_to());
+
+ } break;
default: {
ERR_FAIL_COND(inheritors_array.empty());
@@ -212,6 +218,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
}
} break;
+
default: {}
}
}
@@ -647,7 +654,10 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
menu->clear();
menu->set_size(Size2(1, 1));
- if (hint_text != "") {
+ if (p_name=="script/script" && hint_text=="Script" && owner->cast_to()) {
+ menu->add_icon_item(get_icon("Script","EditorIcons"),TTR("New Script"),OBJ_MENU_NEW_SCRIPT);
+ menu->add_separator();
+ } else if (hint_text!="") {
int idx = 0;
for (int i = 0; i < hint_text.get_slice_count(","); i++) {
diff --git a/editor/property_editor.h b/editor/property_editor.h
index 52fe6dbaf3e..a585315f093 100644
--- a/editor/property_editor.h
+++ b/editor/property_editor.h
@@ -63,6 +63,7 @@ class CustomPropertyEditor : public Popup {
OBJ_MENU_COPY = 4,
OBJ_MENU_PASTE = 5,
OBJ_MENU_REIMPORT = 6,
+ OBJ_MENU_NEW_SCRIPT=7,
TYPE_BASE_ID = 100
};
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 8c2aa4097f2..03c05c9c141 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -57,8 +57,10 @@ void SceneTreeDock::_unhandled_key_input(InputEvent p_event) {
_tool_selected(TOOL_REPLACE);
} else if (ED_IS_SHORTCUT("scene_tree/duplicate", p_event)) {
_tool_selected(TOOL_DUPLICATE);
- } else if (ED_IS_SHORTCUT("scene_tree/add_script", p_event)) {
- _tool_selected(TOOL_SCRIPT);
+ } else if (ED_IS_SHORTCUT("scene_tree/attach_script", p_event)) {
+ _tool_selected(TOOL_ATTACH_SCRIPT);
+ } else if(ED_IS_SHORTCUT("scene_tree/clear_script", p_event)) {
+ _tool_selected(TOOL_CLEAR_SCRIPT);
} else if (ED_IS_SHORTCUT("scene_tree/move_up", p_event)) {
_tool_selected(TOOL_MOVE_UP);
} else if (ED_IS_SHORTCUT("scene_tree/move_down", p_event)) {
@@ -328,7 +330,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
//groups_editor->set_current(current);
//groups_editor->popup_centered_ratio();
} break;
- case TOOL_SCRIPT: {
+ case TOOL_ATTACH_SCRIPT: {
Node *selected = scene_tree->get_selected();
if (!selected)
@@ -347,6 +349,18 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
//script_create_dialog->popup_centered_minsize();
}
+ } break;
+ case TOOL_CLEAR_SCRIPT: {
+ Node *selected = scene_tree->get_selected();
+ if(!selected)
+ break;
+
+ Ref