Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | YP |
How can I load a shader file using script, just like we do it in the editor?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | YP |
How can I load a shader file using script, just like we do it in the editor?
Reply From: | MysteryGM |
The shader file is a resource so you can load it like any resource.
Once you have the resource you just assign it like this:
onready var WaterShader = preload("res://Water.shader")
func _ready():
self.material.shader = WaterShader
Hope this helps
Thank you that worked
YP | 2018-10-30 09:05
how can you access the material in 3d?
yellowsir | 2019-01-19 16:08
to supplement MysteryGM’s answer:
onready var WaterShader = preload("res://Water.shader")
func _ready():
some_sprite_node.material = ShaderMaterial.new()
some_sprite_node.material.shader = WaterShader
whoji | 2020-06-21 07:53