You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Merge pull request #30152 from Chaosus/vs_conversion
Added convertor from VisualShader to Shader
This commit is contained in:
@@ -2771,3 +2771,30 @@ void VisualShaderNodePortPreview::_bind_methods() {
|
||||
|
||||
VisualShaderNodePortPreview::VisualShaderNodePortPreview() {
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
|
||||
String VisualShaderConversionPlugin::converts_to() const {
|
||||
|
||||
return "Shader";
|
||||
}
|
||||
|
||||
bool VisualShaderConversionPlugin::handles(const Ref<Resource> &p_resource) const {
|
||||
|
||||
Ref<VisualShader> vshader = p_resource;
|
||||
return vshader.is_valid();
|
||||
}
|
||||
|
||||
Ref<Resource> VisualShaderConversionPlugin::convert(const Ref<Resource> &p_resource) const {
|
||||
|
||||
Ref<VisualShader> vshader = p_resource;
|
||||
ERR_FAIL_COND_V(!vshader.is_valid(), Ref<Resource>());
|
||||
|
||||
Ref<Shader> shader;
|
||||
shader.instance();
|
||||
|
||||
String code = vshader->get_code();
|
||||
shader->set_code(code);
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user