Files
UmaViewer/Assets/Plugins/UnityGLTF/Editor/Scripts/ShaderGraph/InternalURP/PBRGraphUniversalGUI.cs
T
左右看 0d848e4d07 bug fix
2023-06-28 00:35:46 +08:00

58 lines
1.9 KiB
C#

#if !NO_INTERNALS_ACCESS
#if UNITY_2021_3_OR_NEWER
#define HAVE_CATEGORIES
#endif
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace UnityGLTF
{
// matches ShaderGraphLitGUI.cs
public class PBRGraphUniversalGUI : PBRGraphGUI
{
#if HAVE_CATEGORIES
private PropertyInfo materialEditorPropertyAccessor;
private ShaderGraphLitGUI litGuiForwarder;
public override void ValidateMaterial(Material material)
{
if (material == null) throw new ArgumentNullException(nameof(material));
base.ValidateMaterial(material);
var automaticRenderQueue = GetAutomaticQueueControlSetting(material);
BaseShaderGUI.UpdateMaterialSurfaceOptions(material, automaticRenderQueue);
}
protected override void DrawSurfaceOptions(Material material)
{
if (material == null) throw new ArgumentNullException(nameof(material));
// Use default labelWidth
EditorGUIUtility.labelWidth = 0f;
if (litGuiForwarder == null) litGuiForwarder = new ShaderGraphLitGUI();
if (materialEditorPropertyAccessor == null) materialEditorPropertyAccessor = typeof(BaseShaderGUI).GetProperty("materialEditor", (BindingFlags) (-1));
if (materialEditorPropertyAccessor != null) materialEditorPropertyAccessor.SetValue(litGuiForwarder, materialEditor); // forwarder.materialEditor = materialEditor;
litGuiForwarder.FindProperties(properties);
litGuiForwarder.workflowMode = null;
litGuiForwarder.DrawSurfaceOptions(material);
}
protected override void DrawAdvancedOptions(Material material)
{
base.DrawAdvancedOptions(material);
materialEditor.DoubleSidedGIField();
materialEditor.LightmapEmissionFlagsProperty(0, enabled: true, ignoreEmissionColor: true);
}
#endif
}
}
#endif