解决了node的问题(脚本编写错误并非代码错误)

This commit is contained in:
2025-10-06 17:43:21 +08:00
parent 334f55a250
commit 60a5347dde
4 changed files with 28 additions and 25 deletions

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(Demo.ScriptableObject), true)]
//[CustomEditor(typeof(Demo.ScriptableObject), true)]
public class SOEditor : Convention.AbstractCustomEditor
{

View File

@@ -8,6 +8,7 @@ using System.Text.RegularExpressions;
using Convention;
using Convention.WindowsUI.Variant;
using Demo.Game;
using Sirenix.OdinInspector;
using Unity.Profiling;
using UnityEngine;
@@ -296,22 +297,17 @@ namespace Demo
{
// 上下文系统
public readonly Dictionary<string, float> ScriptContextSpace = new();
public Dictionary<string, float> GetCompleteScriptContext()
[Content] public Dictionary<string, float> ScriptContextSpace = new();
public bool GetCompleteScriptContext(string key, out float value)
{
if (Parent != null)
if (ScriptContextSpace.TryGetValue(key, out value) == false)
{
Dictionary<string, float> context = Parent != null ? Parent.GetCompleteScriptContext() : new();
foreach (var (name, value) in ScriptContextSpace)
{
context[name] = value;
}
return context;
}
else
{
return new(ScriptContextSpace);
if (Parent == null)
return false;
return Parent.GetCompleteScriptContext(key, out value);
}
return true;
}
/// <summary>
@@ -353,7 +349,7 @@ namespace Demo
value = value.Trim();
if (TimePoints.TryGetValue(value, out var result))
return result;
if (GetCompleteScriptContext().TryGetValue(value, out result))
if (GetCompleteScriptContext(value, out result))
return result;
if(value.EndsWith(']'))
{
@@ -503,7 +499,7 @@ namespace Demo
/// <para>使用<see cref="ScriptableCallAttribute"/>标记可编辑脚本所能够调用的函数,并附加注释</para>
/// <para>使用<see cref="DefaultScriptAttribute"/>标记派生类,并附加默认模板</para>
/// </summary>
public partial class ScriptableObject : MonoBehaviour, IHierarchyItemClickEventListener
public partial class ScriptableObject : SerializedMonoBehaviour, IHierarchyItemClickEventListener
{
public static Dictionary<string, Type> FastScriptableObjectTypen = new();
@@ -569,11 +565,13 @@ namespace Demo
MyHierarchyItem.GetHierarchyItem().title = this.ScriptName + $"<{scriptType}>";
MyHierarchyItem.GetHierarchyItem().target = this;
MyHierarchyItem.GetHierarchyItem().ButtonGameObject.GetComponent<Editor.UI.RightClick>().ScriptObjectMenu = OnHierarchyItemRightClick;
var parentHierarchyItem = MyHierarchyItem.GetParent();
if (parentHierarchyItem != null)
parentHierarchyItem.GetPropertyListItem().RefreshChilds();
//var parentHierarchyItem = MyHierarchyItem.GetParent();
//if (parentHierarchyItem != null)
// parentHierarchyItem.GetPropertyListItem().RefreshChilds();
}
public const string RootObjectQuickPath = "project/";
public ScriptableObject FindWithPath(string path, bool isMustExist = true)
{
if (string.IsNullOrEmpty(path))
@@ -586,9 +584,10 @@ namespace Demo
// GetParent
ScriptableObject result = Parent;
if (path[0] == '/' || path[0]=='\\')
if (path.Replace('\\','/').ToLower().StartsWith(RootObjectQuickPath))
{
result = GetRoot();
path = path[RootObjectQuickPath.Length..];
}
if (Parent == null)
@@ -654,8 +653,8 @@ namespace Demo
// 生成对象
var child = creater();
// 路径预处理
if (path.Replace('\\', '/').ToLower().StartsWith("project/"))
path = $"{new ToolFile(GetRoot().SourcePath) | path[5..]}";
if (path.Replace('\\', '/').ToLower().StartsWith(RootObjectQuickPath))
path = $"{new ToolFile(GetRoot().SourcePath) | path[RootObjectQuickPath.Length..]}";
// 获取文件
ToolFile file;
if (File.Exists(path))

View File

@@ -129,7 +129,7 @@ namespace Demo.Game
MyMeshGenerator = this.GetOrAddComponent<TMeshGenerator>();
MyMeshGenerator.spline = MySplineCore.MySplineComputer;
SetupMeshGenerator(MyMeshGenerator);
MyMeshGenerator.Rebuild();
MyMeshGenerator.RebuildImmediate();
}
#region SetupMeshGenerator

View File

@@ -162,9 +162,13 @@ namespace Demo.Game
{
yield return LoadSubScriptAsync(nameof(SplineNode), path, node =>
{
if (node != null)
if (node is SplineNode _node)
{
MySplineNodes.Add(node as SplineNode);
MySplineNodes.Add(_node );
}
else
{
Debug.LogError($"{path} is not {nameof(SplineNode)}", this);
}
});
}