Hello. I’ve made a script that is supposed to grab the material from an object and then decide from a switch how much density that material has. The problem however is that I can’t grab the texture/sprite the material has, because then I’m forced to specify the name of the texture, and since I will most likely make a few variants of the same texture type this will be a nightmare to code while adding in new textures, so I’ve thought up a few other ways to do it, but I can’t decide on which I should pick:
Adding a script “materialData” to every object in the scene I want the script to interact with
Pro
Straight forward
Con
Gets kinda messy in the inspector
Using/abusing the “physics material” to check for the name of the chosen physics material and then funnel it through a large switch
Pro
Much less messy in editor since its integrated to the collider
A bit less time consuming adding to every object in the scene
I have to use them anyway for a lot of objects
Con
Not really what it was meant to do?
Slow string comparison? (not really sure if you have to do it)
I have to have them on static objects too, which it’s not really made for
Using tags on every object
Pro
Not messy in inspector
Con
Tags loose their performance value when searching due to every object having a tag I believe
Using the built-in auto density thing is not an option for me since its so hard to get the physics right that way since the density depends on the object’s weight. If you know any other solutions to my problem, please tell me
Thanks