SabreCSG icon indicating copy to clipboard operation
SabreCSG copied to clipboard

[Request]Example how Materials can be changed in the script

Open skipadu opened this issue 9 years ago • 1 comments

I would like to see an example how I can change material with my own script. I'm thinking of creating some predefined "blocks" and then randomly changing the material to some existing material that I have given in a list. And I want to decide which faces I will replace with the new material.

Does someone have some experience of doing such a thing with SabreCSG? Thanks.

skipadu avatar Apr 23 '17 11:04 skipadu

SetAllPolygonsMaterials can be used to set the material of a brush. In this case you would want material_name to be selected from a list of strings which represent materials in your resources folder.

GameObject cubeObject= CSG.CreateBrush(PrimitiveBrushType.Cube, position, size, rotation, null, CSGMode.Add); PrimitiveBrush activeBrush = cubeObject.GetComponent(); activeBrush.SetAllPolygonsMaterials(Resources.Load(material_name) as Material);

WallHackJack avatar Jun 27 '17 18:06 WallHackJack