I’m making a Pause Menu for a 3D game, I added a ColorRect to the menu and added a blur shader under “Inspector-CanvasItem-Material” and I have the code for the opening and closing of the Pause Menu in the Main Scene.
I want to make the blur fade in when you pause, and I do have a blur parameter in the shader. How do I access it in the code?
If I change this variable @onready var Blur = $PauseMenu/ColorRect.material.get_shader_parameter('blur_amount')
It doesn’t give me any errors anymore, but it doesn’t seem to work. Thank you btw
It gives me this error:
Only identifier, attribute access, and subscription access can be used as assignment target.
Maybe it is because the shader is assigned to the canvasItem and not the colorrect itself, but I’m not sure because changing ColorRect to CanvasItem does the same
colorrect or any Control inherits type class node has canvasItem being as its ancestor, so in theory, colorrect should have its own canvasitem’s properties
@onready var color_rect_node = $PauseMenu/ColorRect
@export blur_shader_material:ShaderMaterial
assign the blur shader material at inspector dock
then
to put the blur shader via code, you just need to
color_rect_node.material=blur_shader_material
this doesnt need to change the blur_amount uniform property of the shader, so set the default blur amount to where it blurs
when unpause, you can just set the material to null, so the blur gone
But if you really want to make the blur kind of animation from blur to not blur and from not blur to blur, then you need to access it via set_shader_parameter
I’m getting an error that there is an unexpected “Identifier” in the class body, at the @export line. I’m sorry that I’m asking so much from you but thanks