You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-21 14:57:09 +00:00
Fixes inability to assign script after clearing
This commit is contained in:
@@ -409,7 +409,9 @@ bool PlaceHolderScriptInstance::set(const StringName &p_name, const Variant &p_v
|
|||||||
if (values.has(p_name)) {
|
if (values.has(p_name)) {
|
||||||
Variant defval;
|
Variant defval;
|
||||||
if (script->get_property_default_value(p_name, defval)) {
|
if (script->get_property_default_value(p_name, defval)) {
|
||||||
if (defval == p_value) {
|
// The evaluate function ensures that a NIL variant is equal to e.g. an empty Resource.
|
||||||
|
// Simply doing defval == p_value does not do this.
|
||||||
|
if (Variant::evaluate(Variant::OP_EQUAL, defval, p_value)) {
|
||||||
values.erase(p_name);
|
values.erase(p_name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -419,7 +421,7 @@ bool PlaceHolderScriptInstance::set(const StringName &p_name, const Variant &p_v
|
|||||||
} else {
|
} else {
|
||||||
Variant defval;
|
Variant defval;
|
||||||
if (script->get_property_default_value(p_name, defval)) {
|
if (script->get_property_default_value(p_name, defval)) {
|
||||||
if (defval != p_value) {
|
if (Variant::evaluate(Variant::OP_NOT_EQUAL, defval, p_value)) {
|
||||||
values[p_name] = p_value;
|
values[p_name] = p_value;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include "editor_properties.h"
|
#include "editor_properties.h"
|
||||||
|
|
||||||
#include "core/config/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
|
#include "core/core_string_names.h"
|
||||||
#include "editor/editor_file_dialog.h"
|
#include "editor/editor_file_dialog.h"
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
#include "editor/editor_properties_array_dict.h"
|
#include "editor/editor_properties_array_dict.h"
|
||||||
@@ -3844,8 +3845,11 @@ void EditorPropertyResource::_resource_selected(const Ref<Resource> &p_resource,
|
|||||||
void EditorPropertyResource::_resource_changed(const Ref<Resource> &p_resource) {
|
void EditorPropertyResource::_resource_changed(const Ref<Resource> &p_resource) {
|
||||||
// Make visual script the correct type.
|
// Make visual script the correct type.
|
||||||
Ref<Script> s = p_resource;
|
Ref<Script> s = p_resource;
|
||||||
|
|
||||||
|
// The bool is_script applies only to an object's main script.
|
||||||
|
// Changing the value of Script-type exported variables of the main script should not trigger saving/reloading properties.
|
||||||
bool is_script = false;
|
bool is_script = false;
|
||||||
if (get_edited_object() && s.is_valid()) {
|
if (get_edited_object() && s.is_valid() && get_edited_property() == CoreStringNames::get_singleton()->_script) {
|
||||||
is_script = true;
|
is_script = true;
|
||||||
InspectorDock::get_singleton()->store_script_properties(get_edited_object());
|
InspectorDock::get_singleton()->store_script_properties(get_edited_object());
|
||||||
s->call("set_instance_base_type", get_edited_object()->get_class());
|
s->call("set_instance_base_type", get_edited_object()->get_class());
|
||||||
|
|||||||
Reference in New Issue
Block a user