Переглянути джерело

Catch programs reimported uncompiled (1.1.1)

An update while the editor is open leaves reimported programs half compiled: no compiled program, but the
old field definitions in memory. A program now counts as compiled only when it has both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ArtyomV2X 1 місяць тому
батько
коміт
16d11ff8c1
2 змінених файлів з 11 додано та 2 видалено
  1. 10 1
      Editor/AUMSSProgramCheck.cs
  2. 1 1
      package.json

+ 10 - 1
Editor/AUMSSProgramCheck.cs

@@ -57,9 +57,18 @@ namespace AUMSS.EditorTools
             {
                 if (program == null || program.sourceCsScript == null) continue;
                 if (!AssetDatabase.GetAssetPath(program).StartsWith(PackagePath)) continue;
-                if (program.fieldDefinitions == null) return true;
+                if (!IsCompiled(program)) return true;
             }
             return false;
         }
+
+        static bool IsCompiled(UdonSharpProgramAsset program)
+        {
+            // The field definitions alone aren't enough: reimporting an uncompiled program (an update while the editor is
+            // open) clears its compiled program but leaves the field definitions from before in memory
+            if (program.fieldDefinitions == null) return false;
+            using (var serialized = new SerializedObject(program))
+                return serialized.FindProperty("serializedUdonProgramAsset")?.objectReferenceValue != null;
+        }
     }
 }

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
     "name": "dev.av2x.aumss",
     "displayName": "AUMSS - Artyom's Udon Modular Scripting System",
-    "version": "1.1.0",
+    "version": "1.1.1",
     "unity": "2022.3",
     "description": "UdonSharp utility scripts for VRChat worlds: jump pads, checkpoints, lasers, pickup helpers, timed teleports and the Linked Object System.",
     "author": {