• Unity
  • Possible to 'project' UI onto a Spine animation?

I'm trying to figure out if it's possible to somehow 'project' a dynamic UI onto a SkeletonGraphic Spine animation like this:

The closet I've come up with is to user a bone follow, but that's useful mostly for placement as the Spine object moves - not the actual animation, which involves deforming the mesh. I essentially want to treat this paper as a screen and a UI onto it at runtime so that it looks like the text is actually part of it. My best guess is that it might somehow be possible with RenderTexture(?) but not sure how exactly.

Any suggestions?

Related Discussions
...

I think you could place an image for text display on the skeleton and replace the text on the paper by replacing the texture at runtime. A similar topic is discussed in the following post:
Do template attachments deform?
Note that when replacing the texture of a mesh attachment, the texture should be exactly the same size before and after replacement.

However, if you want the text itself to have animation, such as appearing one character at a time, the above method may not work. Our Unity expert, Harald is on vacation at the moment, but maybe he can give you some good advice when he comes back.

6일 후

Sorry for the late reply! While BoneFollower based solutions might also include following rotation and scale, it would be a rather difficult setup and requires splitting your text at the folds, which would be a very complicated solution.

Likely the best solution would be to render the text to a RenderTexture as mentioned above, and overlay it on top of your atlas texture. The workflow is basically to create an additional Camera in your scene and assign a RenderTexture. Then you point this Camera at the desired UI text to be captured. It's recommended to have the Camera's Culling Mask set to a special layer (e.g. UI Render Texture) that you assign at your original text UI objects too, to not display this undeformed text in the main Camera. If you need to change the RenderTexture to a normal Texture2D, you can for sure find some code on the Unity forum, like this posting. The background color of the Camera should be set to black with alpha=0 (fully transparent), to make overlaying the text easier in the next step.

Now how to apply this RenderTexture on top of your existing skeleton or its atlas texture is a separate issue:

You could either write a copy of an existing Spine shader and adjust it so that it has an additional Texture input parameter. Then you would blend the previous result color with the Text texture color based on the ui text RenderTexture's alpha value, like color = lerp(color, textTextureColor.rgb, textTextureColor.a);. This however requires some shader coding.

Another approach would be to combine both textures, bake the original atlas texture and the ui text RenderTexture to a single new texture, and use this at your skeleton.

Another (perhaps easier) way would be to render the existing UI mesh again on top of it, with the texture changed from the atlas texture to the ui text RenderTexture.