【m】10. StoryEditor [1.1.0] - 2026-01-08
### Added - 新增剧本设置窗口,在窗口中打开和导出剧本 ### Fixed - 修改Graph创建时的默认位置,防止热更分包导致脚本丢失报错 - 修改Graph导出时对加载器的加载逻辑,解决跨包无法加载的问题
This commit is contained in:
@@ -124,38 +124,17 @@ namespace Stary.Evo.StoryEditor
|
||||
#endregion
|
||||
|
||||
#region 导出设置
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
[BoxGroup("Export")]
|
||||
[SerializeField, ValueDropdown(nameof(GetAllAssemblyNames))]
|
||||
private string assembly;
|
||||
private IEnumerable<string> GetAllAssemblyNames() =>
|
||||
AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName().Name).OrderBy(n => n);
|
||||
|
||||
/// <summary>
|
||||
/// 获取继承 IResource 的所有类
|
||||
/// </summary>
|
||||
private HashSet<string> IResourceTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(assembly))
|
||||
return new();
|
||||
var asm = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetName().Name == assembly);
|
||||
return asm == null ? new() : asm.GetTypes().Where(t => t.IsClass && !t.IsAbstract && t.GetInterfaces().Any(i => i.Name == nameof(IResource))).Select(t => t.Name).ToHashSet();
|
||||
}
|
||||
}
|
||||
#else
|
||||
private HashSet<string> _iResourceTypes = new();
|
||||
#endif
|
||||
|
||||
[BoxGroup("Export", centerLabel:true)]
|
||||
[LabelText("程序集")]
|
||||
public string assembly;
|
||||
|
||||
/// <summary>
|
||||
/// 资源加载方式
|
||||
/// </summary>
|
||||
[BoxGroup("Export", centerLabel:true)]
|
||||
[LabelText("资源加载方式"), ValueDropdown(nameof(IResourceTypes)),SerializeField]
|
||||
private string loaderType;
|
||||
[BoxGroup("Export")]
|
||||
[LabelText("资源加载方式")]
|
||||
public string loaderType;
|
||||
|
||||
private IResource _loader;
|
||||
/// <summary>
|
||||
@@ -165,10 +144,14 @@ namespace Stary.Evo.StoryEditor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_loader == null)
|
||||
if (_loader == null && !string.IsNullOrEmpty(loaderType))
|
||||
{
|
||||
var type = Type.GetType(loaderType);
|
||||
_loader = type == null ? null : (IResource)Activator.CreateInstance(type);
|
||||
var asm = AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetType(loaderType)).FirstOrDefault(t => t != null) ?? AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetType(loaderType, false, false)).FirstOrDefault(t => t != null);
|
||||
|
||||
if (asm != null)
|
||||
{
|
||||
_loader = (IResource)Activator.CreateInstance(asm);
|
||||
}
|
||||
}
|
||||
|
||||
return _loader;
|
||||
@@ -269,7 +252,7 @@ namespace Stary.Evo.StoryEditor
|
||||
// 将转录完成的图表数据序列化为json
|
||||
var json = JsonConvert.SerializeObject(graph, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All });
|
||||
// 文件目录排空
|
||||
var graphFilePath = Path.Combine(Application.dataPath, graphPath.Replace(".asset", ".sg.json"));
|
||||
var graphFilePath = Path.Combine(Application.dataPath, graphPath);
|
||||
if (!Directory.Exists(Path.GetDirectoryName(graphFilePath)))
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(graphFilePath) ?? string.Empty);
|
||||
// 写入json
|
||||
|
||||
Reference in New Issue
Block a user