Update custom pass to global custom pass

This commit is contained in:
Misaki
2024-10-23 20:15:07 +09:00
parent e441bb7911
commit d0554a73bb
64 changed files with 949 additions and 46128 deletions

View File

@@ -1,137 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Linq;
using System;
using System.Text;
using UnityEngine.UIElements;
namespace UnityEditor.Rendering.Toon
{
internal class ProjectSettingProvider : SettingsProvider
{
#region fields
GUIContent guiContentShowConverterStartup = new GUIContent("Show UTS2 converter on start up");
GUIContent guiContentShowDepracted = new GUIContent("Show deprecated features in the inspector");
#endregion
[SettingsProvider]
private static SettingsProvider CreateProjectSettingsProvider()
{
var path = "Project/Unity Toon Shader";
var provider = new ProjectSettingProvider(path, SettingsScope.Project);
provider.keywords = new[] { "Toon Shader", "ToonShader", "UTS" };
return provider;
}
internal ProjectSettingProvider(string path, SettingsScope scope)
: base(path, scope)
{
}
public override void OnActivate
(
string searchContext,
VisualElement rootElement
)
{
}
public override void OnDeactivate()
{
}
public override void OnGUI(string searchContext)
{
using (new GUIScope())
{
EditorGUILayout.BeginVertical();
UnityToonShaderSettings.instance.m_ShowConverter = GUI_Toggle(guiContentShowConverterStartup, UnityToonShaderSettings.instance.m_ShowConverter);
UnityToonShaderSettings.instance.m_ShowDepracated = GUI_Toggle(guiContentShowDepracted, UnityToonShaderSettings.instance.m_ShowDepracated);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.Space();
#if false
if (GUILayout.Button("Apply"))
{
AssetDatabase.SaveAssets();
}
#endif
EditorGUILayout.EndHorizontal();
EditorGUILayout.EndVertical();
}
}
public override void OnTitleBarGUI()
{
// EditorGUILayout.LabelField("");
}
public override void OnFooterBarGUI()
{
EditorGUILayout.LabelField("Settings become effective after pressing Apply button.");
}
bool GUI_Toggle(GUIContent label, bool val)
{
var target = UnityToonShaderSettings.instance;
EditorGUI.BeginChangeCheck();
var ret = EditorGUILayout.Toggle(label, val);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(target, "Changed " + label);
UnityToonShaderSettings.Save();
}
return ret;
}
}
internal class GUIScope : GUI.Scope
{
float m_LabelWidth;
public GUIScope(float layoutMaxWidth)
{
m_LabelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 250;
GUILayout.BeginHorizontal();
GUILayout.Space(10);
GUILayout.BeginVertical();
GUILayout.Space(15);
}
public GUIScope() : this(500)
{
}
protected override void CloseScope()
{
GUILayout.EndVertical();
GUILayout.EndHorizontal();
EditorGUIUtility.labelWidth = m_LabelWidth;
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 42ab09431d92af1408ca67b8f7b67f79
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
namespace Unity.Toonshader.Editor
{
public class UTSRendererSettingProvider : SettingsProvider
{
class Styles
{
public static GUIContent outline = new GUIContent("Outline Setting");
public static GUIContent hairShadow = new GUIContent("Hair Shadow Setting");
}
private SerializedObject _customSettings;
public UTSRendererSettingProvider(string path, SettingsScope scopes, IEnumerable<string> keywords = null) : base(path, scopes, keywords)
{
}
public override void OnActivate(string searchContext, VisualElement rootElement)
{
_customSettings = UTSRenderPassSetting.GetSerializedSettings();
}
public override void OnGUI(string searchContext)
{
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(_customSettings.FindProperty("outlineSetting"), Styles.outline);
EditorGUILayout.PropertyField(_customSettings.FindProperty("hairShadowSetting"), Styles.hairShadow);
_customSettings.ApplyModifiedPropertiesWithoutUndo();
if (EditorGUI.EndChangeCheck())
{
RegisterUTSRenderPass.NotifyRendererSettingChanged();
}
}
public static bool IsSettingsAvailable()
{
return File.Exists(UTSRenderPassSetting.RENDERER_SETTING_ASSET_PATH);
}
[SettingsProvider]
public static SettingsProvider Create()
{
if (IsSettingsAvailable())
{
var provider = new UTSRendererSettingProvider("Project/UTS", SettingsScope.Project)
{
keywords = GetSearchKeywordsFromGUIContentProperties<Styles>()
};
return provider;
}
return null;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 898c2ecbe9c789445bcb5726bbaabaee

View File

@@ -1,51 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEditorInternal;
namespace UnityEditor.Rendering.Toon
{
internal class UnityToonShaderSettings : ScriptableObject
{
const string kFilePath = "ProjectSettings/UnityToonShaderSettings.asset";
static UnityToonShaderSettings s_Instance;
internal static UnityToonShaderSettings instance => s_Instance ?? CreateOrLoad();
[SerializeField]
internal bool m_ShowConverter = true;
[SerializeField]
internal bool m_ShowDepracated = false;
UnityToonShaderSettings()
{
s_Instance = this;
}
static internal void Save()
{
string folderPath = Path.GetDirectoryName(kFilePath);
if (!Directory.Exists(folderPath))
Directory.CreateDirectory(folderPath);
InternalEditorUtility.SaveToSerializedFileAndForget(new[] { s_Instance }, kFilePath, allowTextSerialization: true);
}
static internal UnityToonShaderSettings CreateOrLoad()
{
InternalEditorUtility.LoadSerializedFileAndForget(kFilePath);
//else create
if (s_Instance == null)
{
UnityToonShaderSettings created = CreateInstance<UnityToonShaderSettings>();
created.hideFlags = HideFlags.HideAndDontSave;
}
return s_Instance;
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: eecda13b66564d944a3939865618b117
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: