我正在使用unity-URP支持包中的示例场景。
注意到SkeletonGraphic(UI)的描边再Canvas的RenderMode为Camera时仅有描边
请问有没有CanvasRenderMode为Camera时能让描边正常运作的方法
我正在使用unity-URP支持包中的示例场景。
注意到SkeletonGraphic(UI)的描边再Canvas的RenderMode为Camera时仅有描边
请问有没有CanvasRenderMode为Camera时能让描边正常运作的方法
@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
.
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 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 toRenderExistingMesh
) to render aSkeletonGraphic
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:
- Add a GameObject at the same hierarchy level as the reference SkeletonGraphic and move it before the reference SkeletonGraphic to render behind.
- Add a
RenderExistingMeshGraphic
component.- In the
RenderExistingMeshGraphic
component Inspector atReference Skeleton Graphic
assign the originalSkeletonGraphic
object.- At
Replacement Material
assign e.g. the included SkeletonGraphicDefaultOutline material to replace all materials with this material. Alternatively, ifMultiple CanvasRenderers
is enabled at the reference SkeletonGraphic, you can add entries to theReplacement Materials
list and at each entry assign the original SkeletonGraphic material (e.g. SkeletonGraphicDefault) to be replaced and the respectiveReplacement Material
(e.g. SkeletonGraphicDefaultOutline).
A new spine-unity 4.2 unitypackage is available here as usual:
https://esotericsoftware.com/spine-unity-download