UnityGame/Library/PackageCache/com.unity.render-pipelines.universal/Editor/UniversalSpeedTree9MaterialUpgrader.cs

37 lines
1.3 KiB
C#
Raw Normal View History

2024-10-27 10:53:47 +03:00
using UnityEngine;
using UnityEngine.Rendering;
using UnityEditor.SpeedTree.Importer;
using UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
class UniversalSpeedTree9Upgrader : SpeedTree9MaterialUpgrader
{
const int kMaterialUpgraderVersion = 1;
[MaterialSettingsCallbackAttribute(kMaterialUpgraderVersion)]
private static void OnAssetPostProcessDelegate(GameObject mainObject)
{
if (IsCurrentPipelineURP())
{
SpeedTree9MaterialUpgrader.PostprocessSpeedTree9Materials(mainObject, UniversalSpeedTree9MaterialFinalizer);
}
}
static private bool IsCurrentPipelineURP()
{
return GraphicsSettings.currentRenderPipeline is UniversalRenderPipelineAsset;
}
static public void UniversalSpeedTree9MaterialFinalizer(Material mat)
{
if (mat.HasFloat("_TwoSided"))
mat.SetFloat(Property.CullMode, mat.GetFloat("_TwoSided"));
Unity.Rendering.Universal.ShaderUtils.UpdateMaterial(mat,
Unity.Rendering.Universal.ShaderUtils.MaterialUpdateType.CreatedNewMaterial,
Unity.Rendering.Universal.ShaderUtils.ShaderID.SpeedTree9);
}
}
}