您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

66 行
2.4 KiB

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
public class HDEditorUtils
{
delegate void MaterialResetter(Material material);
static Dictionary<string, MaterialResetter> k_MaterialResetters = new Dictionary<string, MaterialResetter>()
{
{ "HDRenderPipeline/LayeredLit", LayeredLitGUI.SetupMaterialKeywordsAndPass },
{ "HDRenderPipeline/LayeredLitTessellation", LayeredLitGUI.SetupMaterialKeywordsAndPass },
{ "HDRenderPipeline/Lit", LitGUI.SetupMaterialKeywordsAndPass },
{ "HDRenderPipeline/LitTessellation", LitGUI.SetupMaterialKeywordsAndPass },
{ "HDRenderPipeline/Unlit", UnlitGUI.SetupMaterialKeywordsAndPass },
{ "HDRenderPipeline/Decal", DecalUI.SetupMaterialKeywordsAndPass }
};
public static string GetHDRenderPipelinePath()
{
return "Packages/com.unity.render-pipelines.high-definition/HDRP/";
}
public static string GetPostProcessingPath()
{
return "Packages/com.unity.postprocessing/";
}
public static string GetCorePath()
{
return "Packages/com.unity.render-pipelines.core/CoreRP/";
}
public static bool ResetMaterialKeywords(Material material)
{
MaterialResetter resetter;
if (k_MaterialResetters.TryGetValue(material.shader.name, out resetter))
{
CoreEditorUtils.RemoveMaterialKeywords(material);
// We need to reapply ToggleOff/Toggle keyword after reset via ApplyMaterialPropertyDrawers
MaterialEditor.ApplyMaterialPropertyDrawers(material);
resetter(material);
EditorUtility.SetDirty(material);
return true;
}
return false;
}
public static List<BaseShaderPreprocessor> GetBaseShaderPreprocessorList()
{
var baseType = typeof(BaseShaderPreprocessor);
var assembly = baseType.Assembly;
var types = assembly.GetTypes()
.Where(t => t.IsSubclassOf(baseType))
.Select(Activator.CreateInstance)
.Cast<BaseShaderPreprocessor>()
.ToList();
return types;
}
}
}