Hi everyone, I want to set property for material, but I realize that the material instance is changed during the animation, this lead to the property I set before is disappeared. I know I can check if (previousMeshHashCode != currentMeshHashCode), then set those properties again, but I wonder if there're any official way or API to do this thing?
By the way, I realize most animations only change material one time at transition time, I quite understand why the material need to be changed. But there're some animations that change material
few time in an animation. If the material is changed quite frequency like that, I think it can be a hit to performance. Are there anyway to reduce that?
Set material property during the animation
@nam_nguyen Please see "I tried assigning materials at the MeshRenderer, but it is not possible. Why?" in the FAQ section:
https://esotericsoftware.com/spine-unity#Visual
nam_nguyen If the material is changed quite frequency like that, I think it can be a hit to performance. Are there anyway to reduce that?
If by the above sentence you mean that the materials change between frames, why would that be bad for performance?
If you mean that you are having multiple materials alternating at a single skeleton in a single frame, please see the linked documentation about Materials above.
Please see "I tried assigning materials at the MeshRenderer, but it is not possible. Why?" in the FAQ section:
https://esotericsoftware.com/spine-unity#Visual
Thank you, this's exactly what I need
If by the above sentence you mean that the materials change between frames, why would that be bad for performance?
I just afraid about creating new instance of material too often. But because I don't know how much it can hit to performance so I will ignore this until there're significant to the performance. Thank you so much.
nam_nguyen I just afraid about creating new instance of material too often.
Oh, you mean creating Material instances each frame. That would be bad indeed. When using the spine-unity runtime in the intended way, no Material instances should be created. If you see material instances as a result of setting custom Material values (like tint color), likely you should:
- a) only prepare your material once, or
- b) use other ways to set material properties every frame as described in this documentation section.
I have successfully made it not re-created anymore. Thank you so much