black_out.gd 505 B

1234567891011121314151617181920212223
  1. @tool
  2. extends Node3D
  3. @export_range(0, 1, 0.1) var fade = 0.0:
  4. set(value):
  5. fade = value
  6. if is_inside_tree():
  7. _update_fade()
  8. var material : ShaderMaterial
  9. func _update_fade():
  10. if fade == 0.0:
  11. $MeshInstance3D.visible = false
  12. else:
  13. if material:
  14. material.set_shader_parameter("albedo", Color(0.0, 0.0, 0.0, fade))
  15. $MeshInstance3D.visible = true
  16. # Called when the node enters the scene tree for the first time.
  17. func _ready():
  18. material = $MeshInstance3D.material_override
  19. _update_fade()