From 60a5347ddebfd552cb13322ed99ccb9c01ffca84 Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Mon, 6 Oct 2025 17:43:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BA=86node=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98(=E8=84=9A=E6=9C=AC=E7=BC=96=E5=86=99?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=B9=B6=E9=9D=9E=E4=BB=A3=E7=A0=81=E9=94=99?= =?UTF-8?q?=E8=AF=AF)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Editor/SOEditor.cs | 2 +- Assets/Scripts/Framework/ScriptableObject.cs | 41 +++++++++---------- .../Scripts/MoreSpline/BasicSplineRenderer.cs | 2 +- Assets/Scripts/MoreSpline/SplineCore.cs | 8 +++- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/Assets/Scripts/Editor/SOEditor.cs b/Assets/Scripts/Editor/SOEditor.cs index cdc74d8..f9275a7 100644 --- a/Assets/Scripts/Editor/SOEditor.cs +++ b/Assets/Scripts/Editor/SOEditor.cs @@ -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 { diff --git a/Assets/Scripts/Framework/ScriptableObject.cs b/Assets/Scripts/Framework/ScriptableObject.cs index 657b7e1..65a48cb 100644 --- a/Assets/Scripts/Framework/ScriptableObject.cs +++ b/Assets/Scripts/Framework/ScriptableObject.cs @@ -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 ScriptContextSpace = new(); - public Dictionary GetCompleteScriptContext() + [Content] public Dictionary ScriptContextSpace = new(); + + public bool GetCompleteScriptContext(string key, out float value) { - if (Parent != null) + if (ScriptContextSpace.TryGetValue(key, out value) == false) { - Dictionary 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; } /// @@ -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 /// 使用标记可编辑脚本所能够调用的函数,并附加注释 /// 使用标记派生类,并附加默认模板 /// - public partial class ScriptableObject : MonoBehaviour, IHierarchyItemClickEventListener + public partial class ScriptableObject : SerializedMonoBehaviour, IHierarchyItemClickEventListener { public static Dictionary FastScriptableObjectTypen = new(); @@ -569,11 +565,13 @@ namespace Demo MyHierarchyItem.GetHierarchyItem().title = this.ScriptName + $"<{scriptType}>"; MyHierarchyItem.GetHierarchyItem().target = this; MyHierarchyItem.GetHierarchyItem().ButtonGameObject.GetComponent().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)) diff --git a/Assets/Scripts/MoreSpline/BasicSplineRenderer.cs b/Assets/Scripts/MoreSpline/BasicSplineRenderer.cs index 8ce1c58..3014886 100644 --- a/Assets/Scripts/MoreSpline/BasicSplineRenderer.cs +++ b/Assets/Scripts/MoreSpline/BasicSplineRenderer.cs @@ -129,7 +129,7 @@ namespace Demo.Game MyMeshGenerator = this.GetOrAddComponent(); MyMeshGenerator.spline = MySplineCore.MySplineComputer; SetupMeshGenerator(MyMeshGenerator); - MyMeshGenerator.Rebuild(); + MyMeshGenerator.RebuildImmediate(); } #region SetupMeshGenerator diff --git a/Assets/Scripts/MoreSpline/SplineCore.cs b/Assets/Scripts/MoreSpline/SplineCore.cs index 79cdec4..fd0cd5c 100644 --- a/Assets/Scripts/MoreSpline/SplineCore.cs +++ b/Assets/Scripts/MoreSpline/SplineCore.cs @@ -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); } }); }