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

58 行
2.3 KiB

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEngine.Experimental.Rendering.HDPipeline;
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/Fabric", FabricGUI.SetupMaterialKeywordsAndPass },
{ "HDRenderPipeline/Decal", DecalUI.SetupMaterialKeywordsAndPass }
};
public static T LoadAsset<T>(string relativePath) where T : UnityEngine.Object
{
return AssetDatabase.LoadAssetAtPath<T>(HDUtils.GetHDRenderPipelinePath() + relativePath);
}
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;
}
}
}