mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-19 17:22:37 +08:00
fix: added "Show Readme" to the auto-import menu
This commit is contained in:
@@ -11,11 +11,17 @@ namespace Coffee.UIEffectInternal
|
||||
{
|
||||
internal static class ShaderSampleImporter
|
||||
{
|
||||
private static string s_ReadmeUrl;
|
||||
private static (string shaderName, string sampleName, string version)[] s_Samples;
|
||||
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_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)
|
||||
{
|
||||
if (IsBatchOrBuilding()) return;
|
||||
@@ -62,6 +68,10 @@ namespace Coffee.UIEffectInternal
|
||||
if (s_SampleNames.TryGetValue(shaderName, out var sampleName))
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -85,8 +95,21 @@ namespace Coffee.UIEffectInternal
|
||||
// Import the sample if selected.
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
{
|
||||
var selected = EditorUtility.DisplayDialog($"Import {sampleName}", message, "Import", "Cancel");
|
||||
if (!selected) return false;
|
||||
if (!string.IsNullOrWhiteSpace(s_ReadmeUrl))
|
||||
{
|
||||
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.
|
||||
|
||||
@@ -106,6 +106,7 @@ namespace Coffee.UIEffects
|
||||
const string tmpSupport = "TextMeshPro Support";
|
||||
const string version = "v5.11.0";
|
||||
#endif
|
||||
ShaderSampleImporter.RegisterReadmeUrl("https://github.com/mob-sakai/UIEffect#import-additional-resources");
|
||||
ShaderSampleImporter.RegisterShaderSamples(new[]
|
||||
{
|
||||
// TextMeshPro Support/TextMeshPro Support (Unity 6)
|
||||
|
||||
Reference in New Issue
Block a user