fix: added "Show Readme" to the auto-import menu

This commit is contained in:
mob-sakai
2026-11-16 23:07:55 +09:00
parent bb2efc0790
commit 27629cdd7c
2 changed files with 26 additions and 2 deletions
@@ -11,11 +11,17 @@ namespace Coffee.UIEffectInternal
{ {
internal static class ShaderSampleImporter internal static class ShaderSampleImporter
{ {
private static string s_ReadmeUrl;
private static (string shaderName, string sampleName, string version)[] s_Samples; private static (string shaderName, string sampleName, string version)[] s_Samples;
private static (string guid, string fileName)[] s_DeprecatedShaders; private static (string guid, string fileName)[] s_DeprecatedShaders;
private static readonly Dictionary<string, string> s_SampleNames = new Dictionary<string, string>(); private static readonly Dictionary<string, string> s_SampleNames = new Dictionary<string, string>();
private static readonly Dictionary<string, string> s_ShaderAliases = new Dictionary<string, string>(); private static readonly Dictionary<string, string> s_ShaderAliases = new Dictionary<string, string>();
public static void RegisterReadmeUrl(string url)
{
s_ReadmeUrl = url;
}
public static void RegisterShaderSamples((string shaderName, string sampleName, string version)[] samples) public static void RegisterShaderSamples((string shaderName, string sampleName, string version)[] samples)
{ {
if (IsBatchOrBuilding()) return; if (IsBatchOrBuilding()) return;
@@ -62,6 +68,10 @@ namespace Coffee.UIEffectInternal
if (s_SampleNames.TryGetValue(shaderName, out var sampleName)) if (s_SampleNames.TryGetValue(shaderName, out var sampleName))
{ {
var message = $"Import the sample '{sampleName}' to use the shader '{shaderName}'."; var message = $"Import the sample '{sampleName}' to use the shader '{shaderName}'.";
if (!string.IsNullOrWhiteSpace(s_ReadmeUrl))
{
message += "\n\nFor details, please see the readme.";
}
return ImportSampleIfSelected(sampleName, message); return ImportSampleIfSelected(sampleName, message);
} }
@@ -85,8 +95,21 @@ namespace Coffee.UIEffectInternal
// Import the sample if selected. // Import the sample if selected.
if (!string.IsNullOrEmpty(message)) if (!string.IsNullOrEmpty(message))
{ {
var selected = EditorUtility.DisplayDialog($"Import {sampleName}", message, "Import", "Cancel"); if (!string.IsNullOrWhiteSpace(s_ReadmeUrl))
if (!selected) return false; {
var selected = EditorUtility.DisplayDialogComplex(
$"Import {sampleName}", message, "Import", "Cancel", "Show Readme");
if (selected == 2)
{
Application.OpenURL(s_ReadmeUrl);
return false;
}
if (selected != 0) return false;
}
else if (!EditorUtility.DisplayDialog($"Import {sampleName}", message, "Import", "Cancel"))
{
return false;
}
} }
// Remove the imported sample name from the list. // Remove the imported sample name from the list.
@@ -106,6 +106,7 @@ namespace Coffee.UIEffects
const string tmpSupport = "TextMeshPro Support"; const string tmpSupport = "TextMeshPro Support";
const string version = "v5.11.0"; const string version = "v5.11.0";
#endif #endif
ShaderSampleImporter.RegisterReadmeUrl("https://github.com/mob-sakai/UIEffect#import-additional-resources");
ShaderSampleImporter.RegisterShaderSamples(new[] ShaderSampleImporter.RegisterShaderSamples(new[]
{ {
// TextMeshPro Support/TextMeshPro Support (Unity 6) // TextMeshPro Support/TextMeshPro Support (Unity 6)