Facepunch / sbox-issues

176 stars 12 forks source link

Expose SetMaterialOverride( Material material, string attributeName, int attributeValue ) to ModelRenderer Component #4155

Open CarsonKompon opened 10 months ago

CarsonKompon commented 10 months ago

For?

S&Box

What can't you do?

The ModelRenderer component has a MaterialOverride which overrides all materials in the rendered model. I instead want to override only one material.

How would you like it to work?

Same as you could before but instead directly with the component instead of interfacing with the SceneObject

modelRenderer.SetMaterialOverride(myMaterial, "screen") // Checks for == "1" with no argument
// or
modelRenderer.SetMaterialOverride(myMaterial, "wall", "left") // Checks for == "left"

https://asset.party/api/Sandbox.SceneObject.SetMaterialOverride(Material,string,int)

This function allows you to override the material of a screen on a tv if its material has the attribute "screen" set to 1.

What have you tried?

Making my own custom ModelRenderer component based on the code in previous versions of the scenetesting branch but it would be nice if it was part of the ModelRenderer so I don't have to manage two different ModelRenderers for my project.

Additional context

No response

CarsonKompon commented 9 months ago

SceneObject was made public at some point within ModelRenderer so you can technically do this now through

modelRenderer.SceneObject.SetMaterialOverride(myMaterial, "screen")

But it feels weird to have the SceneObject exposed like that (may just be me, there's probably other benefits to having it exposed)