How do you load two different material in CSGBox gdscript?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kakcalu13

I have two different material, but I am not sure how to load the material(*.material) inside the CSGBox script. I couldn’t find a good example to do it.

Is this ?
$CSGbox.get_surface_material(0)

Maybe this
https://forum.godotengine.org/3488/how-to-generate-a-mesh-with-multiple-materials

ramazan | 2022-01-19 19:07

Thank you so much for your reply!

getsurfacematerial(0) returns error:

but set_material(material) worked!

I actually had another way that worked for me

I was going to update the answer but you beat me at it!

So what I did was:
onready var selected = preload("res://selected.material")

and in the function:
material = selected

I’m marking your answer as a correct as it seems more standard and professional answer than mine!

kakcalu13 | 2022-01-19 19:33

Ah, feel free to post as an answer. Yours worked

kakcalu13 | 2022-01-19 19:34

The important thing is to solve problem. Good evening!

ramazan | 2022-01-19 19:58

:bust_in_silhouette: Reply From: ramazan

$CSGbox.getsurfacematerial(0)

https://forum.godotengine.org/3488/how-to-generate-a-mesh-with-multiple-materials

by [kakcalu13 ]
getsurfacematerial(0) returns error:
but set_material(material) worked!