Added HairBlendingSetting in UTSRenderPassSetting; Added MaterialType to UTS; Added MaterialFeature scope to UTS material editor; Merged HairBlendingPass and HairShadowPass into UTSPass; Fixed the bug that character box light can not update rotation correctly according to bound light source;
87 lines
2.6 KiB
C#
87 lines
2.6 KiB
C#
using System;
|
|
using System.IO;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace Misaki.HdrpToon
|
|
{
|
|
internal enum BufferQuality
|
|
{
|
|
Low,
|
|
High
|
|
}
|
|
|
|
[Serializable]
|
|
internal struct UtsHairShadowSetting
|
|
{
|
|
public bool enable;
|
|
public BufferQuality quality;
|
|
}
|
|
|
|
[Serializable]
|
|
internal struct UtsHairBlendingSetting
|
|
{
|
|
public bool enable;
|
|
public BufferQuality quality;
|
|
}
|
|
|
|
[Serializable]
|
|
internal struct UTSOutlineSetting
|
|
{
|
|
public bool enable;
|
|
}
|
|
|
|
[CreateAssetMenu(fileName = "UTSRenderSetting", menuName = "UTS/RenderSetting")]
|
|
public class UTSRenderPassSettings : ScriptableObject
|
|
{
|
|
public const string UTS_RENDERING_SETTINGS_NAME = "UTSRenderingSettings";
|
|
public const string UTS_RENDERING_SETTINGS_PATH = "Assets/Resources/Settings/UTSRenderSettings.asset";
|
|
public const string UTS_RENDERING_SETTINGS_RESOURCES_PATH = "Settings/UTSRenderSettings";
|
|
|
|
[SerializeField]
|
|
internal UtsHairShadowSetting hairShadowSetting;
|
|
[SerializeField]
|
|
internal UtsHairBlendingSetting hairBlendingSetting;
|
|
[SerializeField]
|
|
internal UTSOutlineSetting outlineSetting;
|
|
|
|
internal static UTSRenderPassSettings GetOrCreateSettings()
|
|
{
|
|
#if UNITY_EDITOR
|
|
if (EditorBuildSettings.TryGetConfigObject<UTSRenderPassSettings>(UTS_RENDERING_SETTINGS_NAME, out var settings))
|
|
{
|
|
return settings;
|
|
}
|
|
|
|
UTSRenderPassSettings renderingSettings = null;
|
|
if (File.Exists(UTS_RENDERING_SETTINGS_PATH))
|
|
{
|
|
renderingSettings = AssetDatabase.LoadAssetAtPath<UTSRenderPassSettings>(UTS_RENDERING_SETTINGS_PATH);
|
|
}
|
|
else
|
|
{
|
|
var directory = Path.GetDirectoryName(UTS_RENDERING_SETTINGS_PATH);
|
|
if (!Directory.Exists(directory))
|
|
{
|
|
Directory.CreateDirectory(directory);
|
|
}
|
|
|
|
renderingSettings = CreateInstance<UTSRenderPassSettings>();
|
|
AssetDatabase.CreateAsset(renderingSettings, UTS_RENDERING_SETTINGS_PATH);
|
|
AssetDatabase.Refresh();
|
|
}
|
|
|
|
EditorBuildSettings.AddConfigObject(UTS_RENDERING_SETTINGS_NAME, renderingSettings, true);
|
|
|
|
return renderingSettings;
|
|
#else
|
|
return Resources.Load<UTSRenderPassSettings>(UTS_RENDERING_SETTINGS_RESOURCES_PATH);
|
|
#endif
|
|
}
|
|
|
|
public static SerializedObject GetSerializedSettings()
|
|
{
|
|
return new(GetOrCreateSettings());
|
|
}
|
|
}
|
|
} |