I was hoping to use BlendModeMaterialsAsset to enable some compositing effects for our artist, but there have been a number of issues so far. The easiest way to repro one of these issues is something like:
- Make a spine containing a blendmode slot + an attachment (also gotta hook up a valid BlendModeMaterialsAsset). This attachment needs to be hidden during 'setup pose' in order for the bug to manifest; but do make an animation in which the attachment becomes visible
- Make a test scene containing this spine, and a PlayableDirector with a Timeline that calls for the animation you made (we'll need to test its edit-mode rendering)
- Enter playmode (the attachment should work)
- Exit playmode and use the timeline window to play out the animation we just made (the attachment should now have some purple 'error' shader shit instead of our generated material instance)
An additional note: If you happen to be using the experimental 'Fast Enter Play Mode' settings as we are, the attachment will actually only render properly once: The first time you enter playmode after reloading scripts. Beyond this the purple 'error' shader will remain visible both in playmode and editmode until you either reload the skeleton or reload the whole scripting context.
I've been looking into this today & it seems to me what's happening is: There are many cases during which the new Material instances created by skeleton modifiers get automatically cleaned up during transitions into/out of playmode (probably by Unity's 'unload unused resources' process). In cases where the new materials (e.g. 'SpineTest Screen') wind up mapped directly into a SkeletonRenderer's sharedMaterials array, they do tend to survive the playmode->editmode transition; but otherwise (say if the attachment isn't visible during the transition) lots of undesired cleanup will take place.
For us it makes the skeleton data modifier system unusable, which is a shame because it seems like the ideal way to apply shader effects to certain attachments! I've been trying a variety of approaches to solving all the purple error shader cases (playing with the enter/exit playmode callbacks, trying in various ways to 'cache' the generated materials) but it seems like the cleanup thing strikes at weird moments & leaves our running SkeletonRender components in a busted state!
This demo project manifests the problem for me ( unity 2020.1.9f1, spine-unity-3.8 ): UnityProject.zip