1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

Merge pull request #8202 from williamd1k0/add-script-button

Add Attach and Clear Script buttons (2.1)
This commit is contained in:
Rémi Verschelde
2017-04-07 08:54:39 +02:00
committed by GitHub
9 changed files with 264 additions and 29 deletions

View File

@@ -194,6 +194,12 @@ void CustomPropertyEditor::_menu_option(int p_which) {
}
}
} break;
case OBJ_MENU_NEW_SCRIPT: {
if (owner->cast_to<Node>())
EditorNode::get_singleton()->get_scene_tree_dock()->open_script_dialog(owner->cast_to<Node>());
} 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<Node>()) {
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++) {