mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 04:06:14 +00:00
Merge pull request #41861 from Razoric480/fix-vscript-value-by-type
Add a function to sanitize variant values in visual script
This commit is contained in:
commit
a332e2f5b2
@ -1124,8 +1124,8 @@ void VisualScriptEditor::_update_members() {
|
||||
TreeItem *ti = members->create_item(variables);
|
||||
|
||||
ti->set_text(0, E->get());
|
||||
Variant var = script->get_variable_default_value(E->get());
|
||||
ti->set_suffix(0, "= " + String(var));
|
||||
|
||||
ti->set_suffix(0, "= " + _sanitized_variant_text(E->get()));
|
||||
ti->set_icon(0, type_icons[script->get_variable_info(E->get()).type]);
|
||||
|
||||
ti->set_selectable(0, true);
|
||||
@ -1167,6 +1167,18 @@ void VisualScriptEditor::_update_members() {
|
||||
updating_members = false;
|
||||
}
|
||||
|
||||
String VisualScriptEditor::_sanitized_variant_text(const StringName &property_name) {
|
||||
Variant var = script->get_variable_default_value(property_name);
|
||||
|
||||
if (script->get_variable_info(property_name).type != Variant::NIL) {
|
||||
Callable::CallError ce;
|
||||
const Variant *converted = &var;
|
||||
var = Variant::construct(script->get_variable_info(property_name).type, &converted, 1, ce, false);
|
||||
}
|
||||
|
||||
return String(var);
|
||||
}
|
||||
|
||||
void VisualScriptEditor::_member_selected() {
|
||||
if (updating_members) {
|
||||
return;
|
||||
|
@ -146,6 +146,7 @@ class VisualScriptEditor : public ScriptEditorBase {
|
||||
bool updating_members;
|
||||
|
||||
void _update_members();
|
||||
String _sanitized_variant_text(const StringName &property_name);
|
||||
|
||||
StringName selected;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user