From c8f83603fd58882dae23672b10f167e0c37faa5e Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 10 Jul 2025 18:59:33 -0400 Subject: [PATCH] maint: hot reload automatic changes?? --- .../Editor/HotReloadAttributeProcessor.cs | 35 +++++++++++++++++++ .../HotReloadAttributeProcessor.cs.meta | 11 ++++++ 2 files changed, 46 insertions(+) create mode 100644 Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs create mode 100644 Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs.meta diff --git a/Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs b/Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs new file mode 100644 index 0000000..b99e2a6 --- /dev/null +++ b/Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs @@ -0,0 +1,35 @@ +#if ODIN_INSPECTOR +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using SingularityGroup.HotReload.EditorDependencies; +using Sirenix.OdinInspector; +using Sirenix.OdinInspector.Editor; + +namespace SingularityGroup.HotReload.Editor { + public class HotReloadAttributeProcessor : OdinAttributeProcessor { + public override bool CanProcessChildMemberAttributes(InspectorProperty parentProperty, MemberInfo member) { + return member is FieldInfo; + } + + static object nullObject = new object(); + public override void ProcessChildMemberAttributes(InspectorProperty property, MemberInfo member, List attributes) { + var field = member as FieldInfo; + if (field?.DeclaringType == null) { + return; + } + if (UnityFieldHelper.TryGetFieldAttributes(field, out var fieldAttributes)) { + attributes.Clear(); + attributes.AddRange(fieldAttributes); + } + if (UnityFieldHelper.IsFieldHidden(field.DeclaringType, field.Name)) { + attributes.Add(new HideIfAttribute("@true")); + } + // we assume this is always not null. Most of the times it will not be. If it is the side effect is some memory footprint which hopefully gets cleared when enough objects + var key = property.ParentValues.FirstOrDefault() ?? nullObject; + UnityFieldHelper.CacheFieldInvalidation(key, field, property.RefreshSetup); + } + } +} +#endif diff --git a/Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs.meta b/Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs.meta new file mode 100644 index 0000000..22b1b82 --- /dev/null +++ b/Packages/com.singularitygroup.hotreload/Editor/HotReloadAttributeProcessor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c63452dd912fe4c46909c1c5ce844e69 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: