mirror of https://github.com/godotengine/godot
Merge adb5e0e207 into 15ff450680
This commit is contained in:
commit
40ff19c083
|
|
@ -43,6 +43,20 @@
|
|||
Edits the given [Script]. The line and column on which to open the script can also be specified. The script will be open with the user-configured editor for the script's language which may be an external editor.
|
||||
</description>
|
||||
</method>
|
||||
<method name="find_resource_conversion_plugin_for_resource">
|
||||
<return type="Array" />
|
||||
<param index="0" name="for_resource" type="Resource" />
|
||||
<description>
|
||||
Returns an [Array] of [EditorResourceConversionPlugin] that can handle the [param for_resource].
|
||||
</description>
|
||||
</method>
|
||||
<method name="find_resource_conversion_plugin_for_type_name">
|
||||
<return type="Array" />
|
||||
<param index="0" name="type" type="String" />
|
||||
<description>
|
||||
Returns an [Array] of [EditorResourceConversionPlugin] that can handle the [param type].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_base_control" qualifiers="const">
|
||||
<return type="Control" />
|
||||
<description>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderConversionPlugin" inherits="EditorResourceConversionPlugin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
Plugin for converting from [VisualShader] to [Shader].
|
||||
</brief_description>
|
||||
<description>
|
||||
[VisualShaderConversionPlugin] is invoked when the context menu is brought up for a [VisualShader] in the editor inspector.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="convert" qualifiers="const">
|
||||
<return type="Resource" />
|
||||
<param index="0" name="resource" type="Resource" />
|
||||
<description>
|
||||
Takes an input [Resource] expected to be of type [VisualShader] and converts it to [Shader] in [method converts_to]. The returned [Resource] is the resulting [Shader] of the conversion, and the input [Resource] remains unchanged.
|
||||
</description>
|
||||
</method>
|
||||
<method name="converts_to" qualifiers="const">
|
||||
<return type="String" />
|
||||
<description>
|
||||
Returns "Shader" which is the class name [Shader] this plugin converts the source resource [VisualShader] to.
|
||||
</description>
|
||||
</method>
|
||||
<method name="handles" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="resource" type="Resource" />
|
||||
<description>
|
||||
Called to determine whether a particular [Resource] can be converted to the [Shader] resource type by this plugin. Will return false if the particular [Resource] is not of type [VisualShader].
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
</class>
|
||||
|
|
@ -48,6 +48,7 @@
|
|||
#include "editor/gui/editor_toaster.h"
|
||||
#include "editor/gui/scene_tree_editor.h"
|
||||
#include "editor/inspector_dock.h"
|
||||
#include "editor/plugins/editor_resource_conversion_plugin.h"
|
||||
#include "editor/plugins/node_3d_editor_plugin.h"
|
||||
#include "editor/property_selector.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
|
|
@ -368,6 +369,36 @@ bool EditorInterface::is_plugin_enabled(const String &p_plugin) const {
|
|||
return EditorNode::get_singleton()->is_addon_plugin_enabled(p_plugin);
|
||||
}
|
||||
|
||||
Array EditorInterface::find_resource_conversion_plugin_for_resource(const Ref<Resource> &p_for_resource) {
|
||||
Array ret = Array();
|
||||
Vector<Ref<EditorResourceConversionPlugin>> converters = EditorNode::get_singleton()->find_resource_conversion_plugin_for_resource(p_for_resource);
|
||||
|
||||
if (converters.is_empty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (int i = 0; i < converters.size(); i++) {
|
||||
ret.push_back(converters[i]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Array EditorInterface::find_resource_conversion_plugin_for_type_name(const String &p_type) {
|
||||
Array ret = Array();
|
||||
Vector<Ref<EditorResourceConversionPlugin>> converters = EditorNode::get_singleton()->find_resource_conversion_plugin_for_type_name(p_type);
|
||||
|
||||
if (converters.is_empty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (int i = 0; i < converters.size(); i++) {
|
||||
ret.push_back(converters[i]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Editor GUI.
|
||||
|
||||
Ref<Theme> EditorInterface::get_editor_theme() const {
|
||||
|
|
@ -774,6 +805,8 @@ void EditorInterface::_bind_methods() {
|
|||
|
||||
ClassDB::bind_method(D_METHOD("set_plugin_enabled", "plugin", "enabled"), &EditorInterface::set_plugin_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_plugin_enabled", "plugin"), &EditorInterface::is_plugin_enabled);
|
||||
ClassDB::bind_method(D_METHOD("find_resource_conversion_plugin_for_resource", "for_resource"), &EditorInterface::find_resource_conversion_plugin_for_resource);
|
||||
ClassDB::bind_method(D_METHOD("find_resource_conversion_plugin_for_type_name", "type"), &EditorInterface::find_resource_conversion_plugin_for_type_name);
|
||||
|
||||
// Editor GUI.
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class EditorFileSystem;
|
|||
class EditorInspector;
|
||||
class EditorPaths;
|
||||
class EditorPlugin;
|
||||
class EditorResourceConversionPlugin;
|
||||
class EditorResourcePreview;
|
||||
class EditorSelection;
|
||||
class EditorSettings;
|
||||
|
|
@ -115,6 +116,8 @@ public:
|
|||
|
||||
void set_plugin_enabled(const String &p_plugin, bool p_enabled);
|
||||
bool is_plugin_enabled(const String &p_plugin) const;
|
||||
Array find_resource_conversion_plugin_for_resource(const Ref<Resource> &p_for_resource);
|
||||
Array find_resource_conversion_plugin_for_type_name(const String &p_type);
|
||||
|
||||
// Editor GUI.
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include "core/config/project_settings.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/math/math_defs.h"
|
||||
#include "core/object/class_db.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_properties.h"
|
||||
|
|
@ -8256,6 +8257,12 @@ void VisualShaderNodePortPreview::_notification(int p_what) {
|
|||
|
||||
//////////////////////////////////
|
||||
|
||||
void VisualShaderConversionPlugin::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("converts_to"), &VisualShaderConversionPlugin::converts_to);
|
||||
ClassDB::bind_method(D_METHOD("handles", "resource"), &VisualShaderConversionPlugin::handles);
|
||||
ClassDB::bind_method(D_METHOD("convert", "resource"), &VisualShaderConversionPlugin::convert);
|
||||
}
|
||||
|
||||
String VisualShaderConversionPlugin::converts_to() const {
|
||||
return "Shader";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -715,6 +715,9 @@ public:
|
|||
class VisualShaderConversionPlugin : public EditorResourceConversionPlugin {
|
||||
GDCLASS(VisualShaderConversionPlugin, EditorResourceConversionPlugin);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual String converts_to() const override;
|
||||
virtual bool handles(const Ref<Resource> &p_resource) const override;
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@
|
|||
#include "editor/plugins/theme_editor_plugin.h"
|
||||
#include "editor/plugins/tiles/tiles_editor_plugin.h"
|
||||
#include "editor/plugins/tool_button_editor_plugin.h"
|
||||
#include "editor/plugins/visual_shader_editor_plugin.h"
|
||||
#include "editor/plugins/voxel_gi_editor_plugin.h"
|
||||
#include "editor/register_exporters.h"
|
||||
|
||||
|
|
@ -168,6 +169,7 @@ void register_editor_types() {
|
|||
register_exporter_types();
|
||||
|
||||
GDREGISTER_CLASS(EditorResourceConversionPlugin);
|
||||
GDREGISTER_CLASS(VisualShaderConversionPlugin);
|
||||
GDREGISTER_CLASS(EditorSceneFormatImporter);
|
||||
GDREGISTER_CLASS(EditorScenePostImportPlugin);
|
||||
GDREGISTER_CLASS(EditorInspector);
|
||||
|
|
|
|||
Loading…
Reference in New Issue