mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 08:23:29 +00:00
Tool Mode for Visualscript
Add the ability to VisualScript to function in Tool mode aka the Editor itself similar to GDScript or Mono
This commit is contained in:
parent
e4ec59b6ae
commit
097f47f064
4 changed files with 27 additions and 2 deletions
|
@ -579,6 +579,10 @@ void VisualScript::get_data_connection_list(const StringName &p_func, List<DataC
|
|||
}
|
||||
}
|
||||
|
||||
void VisualScript::set_tool_enabled(bool p_enabled) {
|
||||
is_tool_script = p_enabled;
|
||||
}
|
||||
|
||||
void VisualScript::add_variable(const StringName &p_name, const Variant &p_default_value, bool p_export) {
|
||||
|
||||
ERR_FAIL_COND(instances.size());
|
||||
|
@ -895,7 +899,7 @@ ScriptInstance *VisualScript::instance_create(Object *p_this) {
|
|||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
if (!ScriptServer::is_scripting_enabled()) {
|
||||
if (!ScriptServer::is_scripting_enabled() && !is_tool_script) {
|
||||
|
||||
PlaceHolderScriptInstance *sins = memnew(PlaceHolderScriptInstance(VisualScriptLanguage::singleton, Ref<Script>((Script *)this), p_this));
|
||||
placeholders.insert(sins);
|
||||
|
@ -959,7 +963,7 @@ Error VisualScript::reload(bool p_keep_state) {
|
|||
|
||||
bool VisualScript::is_tool() const {
|
||||
|
||||
return false;
|
||||
return is_tool_script;
|
||||
}
|
||||
|
||||
bool VisualScript::is_valid() const {
|
||||
|
@ -1165,6 +1169,11 @@ void VisualScript::_set_data(const Dictionary &p_data) {
|
|||
data_connect(name, data_connections[j + 0], data_connections[j + 1], data_connections[j + 2], data_connections[j + 3]);
|
||||
}
|
||||
}
|
||||
|
||||
if (d.has("is_tool_script"))
|
||||
is_tool_script = d["is_tool_script"];
|
||||
else
|
||||
is_tool_script = false;
|
||||
}
|
||||
|
||||
Dictionary VisualScript::_get_data() const {
|
||||
|
@ -1247,6 +1256,8 @@ Dictionary VisualScript::_get_data() const {
|
|||
|
||||
d["functions"] = funcs;
|
||||
|
||||
d["is_tool_script"] = is_tool_script;
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue