Unity URP无法设置Transparency Sort Mode

9 篇文章 0 订阅
在Unity的UniversalRenderPipeline(URP)中,TransparencySortMode选项不可见,但可以通过编程方式设置。可以临时将渲染管线设置为无,应用透明度排序模式,然后重置;或者在项目中添加特定的C#脚本来设置TransparencySortMode为CustomAxis和自定义轴向。
摘要由CSDN通过智能技术生成

Unity URP无法设置Transparency Sort Mode

问题

一般使用Unity制作2D游戏时会将Transparency Sort Mode设置为Custom Axis并将Transparency Sort Axis设置为0,1,0来方便Spirte排序
通常设置
但是当渲染管线切换为Universal Render Pipeline(通用渲染管线)
URP设置
Transparency Sort Mode就消失了

解决方案

1.(推荐 )可以将渲染管线资产设置为无,设置透明度排序模式设置,因为该选项已经存在,然后重置渲染管线资产。即使看不见该选项了,透明度排序模式设置仍将被设置。

2.在项目中添加以下代码

#if UNITY_EDITOR
using UnityEditor;
#endif
 
using UnityEngine;
using UnityEngine.Rendering;
 
#if UNITY_EDITOR
[InitializeOnLoad]
#endif
class TransparencySortGraphicsHelper
{
    static TransparencySortGraphicsHelper()
    {
        OnLoad();
    }
 
    [RuntimeInitializeOnLoadMethod]
    static void OnLoad()
    {
        GraphicsSettings.transparencySortMode = TransparencySortMode.CustomAxis;
        GraphicsSettings.transparencySortAxis = new Vector3(0.0f, 1.0f, 0.0f);
    }
}

参考

链接: Transparency Sort Mode and Lightweight Render Pipeline

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值