同步
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using SLSUtilities.Narrative.UI;
|
||||
using UnityEditor;
|
||||
using Yarn.Unity.Editor;
|
||||
|
||||
namespace SLSUtilities.Narrative.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// AdvancedLinePresenter 的自定义 Inspector。
|
||||
/// 继承自 Yarn 的 YarnEditor,完整复现 LinePresenter 的
|
||||
/// [ShowIf]、[Group]、[MustNotBeNull] 等属性驱动的显示效果。
|
||||
/// </summary>
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(AdvancedLinePresenter))]
|
||||
public class AdvancedLinePresenterEditor : YarnEditor { }
|
||||
|
||||
/// <summary>
|
||||
/// AdvancedLineAdvancer 的自定义 Inspector。
|
||||
/// 继承自 Yarn 的 YarnEditor,完整复现 LineAdvancer 的
|
||||
/// InputMode 条件显示等效果。
|
||||
/// </summary>
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(AdvancedLineAdvancer))]
|
||||
public class AdvancedLineAdvancerEditor : YarnEditor { }
|
||||
|
||||
/// <summary>
|
||||
/// AdvancedOptionsPresenter 的自定义 Inspector。
|
||||
/// 完整复现 OptionsPresenter 的属性驱动效果。
|
||||
/// </summary>
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(AdvancedOptionsPresenter))]
|
||||
public class AdvancedOptionsPresenterEditor : YarnEditor { }
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a5fb6371856a1c4dad725a24657bb10
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "SLSUtilities.StorySystem.Editor",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:43bb4e992d9b32b4bbb25402b41e80a0",
|
||||
"GUID:22a86856172c06146a539eeb9c9c67f5",
|
||||
"GUID:34aa492b82754644eac2f903cd496268",
|
||||
"GUID:3a299c53e4c683b4eb4a04c9ad9e648f"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f17ca624957b754baae4c01af60c96e
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
92
Assets/Scripts/SLSUtilities/Narrative/Editor/YslsMerger.cs
Normal file
92
Assets/Scripts/SLSUtilities/Narrative/Editor/YslsMerger.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace SLSUtilities.Narrative.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// Yarn Spinner 自动 YSLS 合并器。
|
||||
/// 自动将来自不同程序集(Assembly-CSharp、SLSUtilities等)生成的多个 YSLS 声明文件
|
||||
/// 合并成一个单一的 combined.ysls.json 文件,输出到项目根目录下,
|
||||
/// 从而完美解决 VS Code 中 Yarn Spinner 插件只能同时加载一个 definitions 文件的限制!
|
||||
/// </summary>
|
||||
public static class YslsMerger
|
||||
{
|
||||
[MenuItem("Tools/Yarn Spinner/Merge YSLS Files")]
|
||||
public static void MergeYslsFiles()
|
||||
{
|
||||
string packagePath = Path.Combine(Directory.GetCurrentDirectory(), "ProjectSettings", "Packages", "dev.yarnspinner");
|
||||
if (!Directory.Exists(packagePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string combinedFileName = "combined.ysls.json";
|
||||
string outputRootPath = Path.Combine(packagePath, combinedFileName);
|
||||
|
||||
try
|
||||
{
|
||||
// 搜索所有以 -generated.ysls.json 结尾的声明文件
|
||||
string[] files = Directory.GetFiles(packagePath, "*-generated.ysls.json");
|
||||
if (files.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
JArray allCommands = new JArray();
|
||||
JArray allFunctions = new JArray();
|
||||
int version = 2;
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
if (Path.GetFileName(file) == combinedFileName) continue;
|
||||
|
||||
string json = File.ReadAllText(file);
|
||||
if (string.IsNullOrEmpty(json)) continue;
|
||||
|
||||
JObject root = JObject.Parse(json);
|
||||
|
||||
if (root.TryGetValue("version", out JToken vToken))
|
||||
{
|
||||
version = Mathf.Max(version, vToken.Value<int>());
|
||||
}
|
||||
|
||||
if (root.TryGetValue("commands", out JToken cToken) && cToken is JArray commandsArray)
|
||||
{
|
||||
foreach (var cmd in commandsArray)
|
||||
{
|
||||
allCommands.Add(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
if (root.TryGetValue("functions", out JToken fToken) && fToken is JArray functionsArray)
|
||||
{
|
||||
foreach (var func in functionsArray)
|
||||
{
|
||||
allFunctions.Add(func);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 组装合并后的 JObject
|
||||
JObject combined = new JObject
|
||||
{
|
||||
["version"] = version,
|
||||
["commands"] = allCommands,
|
||||
["functions"] = allFunctions
|
||||
};
|
||||
|
||||
// 写入项目根目录
|
||||
File.WriteAllText(outputRootPath, combined.ToString(Newtonsoft.Json.Formatting.Indented));
|
||||
Debug.Log($"[YSLS Merger] 成功将 {files.Length} 个 YSLS 声明文件合并至: '{outputRootPath}'。现在您可以在 VS Code 中一键加载此合并文件!");
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
// 自动合并失败通常发生在初始无缓存时,作警告处理,不中断编辑体验
|
||||
Debug.LogWarning($"[YSLS Merger] 自动合并 YSLS 文件失败(这通常是由于 Yarn Spinner 尚未生成初始的 ysls 缓存文件导致的,属于正常现象):{ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7178a694f7924194ea3b787839ddd162
|
||||
Reference in New Issue
Block a user