Hey there - idle question, which may or may not be dumb…
If I wanted an individual instance of a game object to fade out (examples: dead body, object exiting visibility range, scenery between camera and player avatar, floor and contents of building level above level with current focus) I would probably grab the object’s materials in question (renderer.material, assuming it has alpha) and repeatedly assign a colour which I lerp the alpha on over the course of a third of a second or whatever. I could do this with a coroutine or an animation clip. (Description’s a bit rough because I haven’t done this in a while - as I say, it’s an idle question)
However - if I want to maintain static and dynamic batching, I should in general avoid modifying renderer.material as this creates a new copy of the material, messing with the batching (and adding to memory usage). So there’s a conflict there.
Obviously creating an object pool can help a little for enemies, etc, but as I say, sometimes you just want to fade out an arbitrary wall or other scenery if a player’s behind it (again, ignoring solutions like having the player show x-ray like through the walls, or having the walls shrink in Y to show the player behind).
Does anybody have any best practice suggestions for having individual game objects fade out while maintaining material batching?
–Rev