Unity URP は透明性ソート モードを設定できません

Unity URP は透明性ソート モードを設定できません

質問

通常、Unity を使用して 2D ゲームを作成する場合、ソートを容易にするためにと がTransparency Sort Mode設定されますが、レンダリング パイプラインと消えます。Custom AxisTransparency Sort Axis0,1,0Spirte
通常設定されている
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);
    }
}

参考

接続:透明ソート モードと軽量レンダー パイプライン

おすすめ

転載: blog.csdn.net/a71468293a/article/details/128858742