• RuntimesUnity
  • 关于SkeletonGraphic的描边问题

我正在使用unity-URP支持包中的示例场景。
注意到SkeletonGraphic(UI)的描边再Canvas的RenderMode为Camera时仅有描边

请问有没有CanvasRenderMode为Camera时能让描边正常运作的方法

Related Discussions
...

@simonyrl Sorry to hear you're having troubles. Unfortunately with Canvas Render Mode Screen Space Camera only the first pass (the outline pass) of the two render passes (outline pass, then normal pass on top) is drawn by the Unity render pipeline. Unfortunately I'm not aware of a fix for this while still using only a single shader.

What you can do is render the same mesh again manually via a second GameObject. So you would have the normal SkeletonGraphic object with the default material and have a second GameObject for only the outline.

This is what the RenderExistingMesh example component is intended for with a MeshRenderer, but unfortunately is not compatible with SkeletonGraphic and CanvasRenderers. Please find below a new RenderExistingMeshGraphic sample component, which supports any MaskableGraphic and can be used for SkeletonGraphic.

renderexistingmeshgraphic.zip
2kB
  • simonyrl ответили на это сообщение.

    @simonyrl Please let us know if this helps with your use case. We will later release this sample component officially with the package once we're happy with it.

    Harald
    感谢回答。脚本报告了错误:
    RenderExistingMeshGraphic.cs(133,79): error CS1061: 'CanvasRenderer' does not contain a definition for 'GetMesh' and no accessible extension method 'GetMesh' accepting a first argument of type 'CanvasRenderer' could be found (are you missing a using directive or an assembly reference?)
    我的Spine版本是4.1
    Unity版本是2020.3.38f1

    @simonyrl Oh, thanks for reporting, this method has indeed been added in Unity 2022.2 and newer. You can find a new package below:

    renderexistingmeshgraphicv11.zip
    2kB

    Please let us know if this resolves your issues.

    • simonyrl ответили на это сообщение.
    • simonyrl оценил это.

      Harald 问题解决,完美无瑕,非常感谢。

      @simonyrl Glad it helped, thanks for letting us know.

      12 дней спустя

      @simonyrl FYI: We have just released an official RenderExistingMeshGraphic sample component at the 4.2 branch (you would need to manualy copy it into your 4.1 project):
      EsotericSoftware/spine-runtimesblob/4.2/spine-unity/Assets/Spine%20Examples/Scripts/Sample%20Components/RenderExistingMeshGraphic.cs
      It provides a more flexible and robust implementation and supports Multiple CanvasRenderers as well.

      From the changelog:

      • Added example component RenderExistingMeshGraphic (similar to RenderExistingMesh) to render a SkeletonGraphic mesh again with different materials. This might be required by e.g. URP and SkeletonGraphic outline shaders skipping additional render passes. To add a second outline variant of your SkeletonGraphic:
        1. Add a GameObject at the same hierarchy level as the reference SkeletonGraphic and move it before the reference SkeletonGraphic to render behind.
        2. Add a RenderExistingMeshGraphic component.
        3. In the RenderExistingMeshGraphic component Inspector at Reference Skeleton Graphic assign the original SkeletonGraphic object.
        4. At Replacement Material assign e.g. the included SkeletonGraphicDefaultOutline material to replace all materials with this material. Alternatively, if Multiple CanvasRenderers is enabled at the reference SkeletonGraphic, you can add entries to the Replacement Materials list and at each entry assign the original SkeletonGraphic material (e.g. SkeletonGraphicDefault) to be replaced and the respective Replacement Material (e.g. SkeletonGraphicDefaultOutline).

      A new spine-unity 4.2 unitypackage is available here as usual:
      https://esotericsoftware.com/spine-unity-download