Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Material UI not responding when updating shader params in tool mode #38982

Open
GameDevLlama opened this issue May 23, 2020 · 1 comment
Open

Comments

@GameDevLlama
Copy link
Contributor

Godot version:
3.2.2 Beta 3 Official

OS/device including version:
Windows 10

Issue description:
Having a sprite node with a tool script attached to it:

tool
extends Sprite

func _process(delta: float) -> void:
	material["shader_param/Uniform"] = ArbitraryValue

And having a material which is using a VisualShader, the editor UI for the material shader will not be clickable anymore. This is preventing the shader being opened via the sprites material property panel.

Steps to reproduce:
add a sprite to the scene.
add a new material to the sprite with a visual shader.
Add a uniform to the visual shader and use it somehow. (a color uniform for example)
also attach a new script with tool mode in which updates a material uniform in the process function.
Reopen the scene, so that the tool starts processing.
Try opening the Visual script via the sprite's property panels.

Minimal reproduction project:

@pavlexander
Copy link

I apologize if this has already been fixed or a different use-case but I came looking for the same issue in godot 4 and apparently the issue was that I needed to rebuild the project and reload (close and open) the scene! Reopening is very important. I think that by default the editor is not tracking the script changes so you have to force reload it. I would actually file an issue for the particular problem..

Regardless, I am not sure if my problem is applicable, but here is the completely working editor-friendly shader update script in C# in godot 4.

[Tool]
public partial class Grid : Node2D
{
    private ColorRect _colorRect;

    public override void _Ready()
    {
        _colorRect = GetNode<ColorRect>("ColorRect");

        UpdateShaderSize();

        _colorRect.Connect(ColorRect.SignalName.Resized, Callable.From(_on_SizeChanged));
    }

    private void _on_SizeChanged()
    {
        UpdateShaderSize();
    }

    private void UpdateShaderSize()
    {
        if (_colorRect.Material is ShaderMaterial shaderMaterial)
        {
            shaderMaterial.SetShaderParameter("node_size", _colorRect.Size);
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants