diff --git a/Assets/UdonSharp/Editor/UdonSharpProgramAsset.cs b/Assets/UdonSharp/Editor/UdonSharpProgramAsset.cs index 4a1a469d..f17ea1ad 100644 --- a/Assets/UdonSharp/Editor/UdonSharpProgramAsset.cs +++ b/Assets/UdonSharp/Editor/UdonSharpProgramAsset.cs @@ -253,9 +253,9 @@ public static UdonSharpProgramAsset[] GetAllUdonSharpPrograms() _programAssetCache[i] = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(udonSharpDataAssets[i])); bool neededFallback = false; - UdonSharpProgramAsset[] fallbackAssets = Resources.FindObjectsOfTypeAll(); + var fallbackAssets1 = Resources.FindObjectsOfTypeAll().OfType(); - foreach (UdonSharpProgramAsset fallbackAsset in fallbackAssets) + foreach (UdonSharpProgramAsset fallbackAsset in fallbackAssets1) { if (!_programAssetCache.Contains(fallbackAsset)) { @@ -266,6 +266,22 @@ public static UdonSharpProgramAsset[] GetAllUdonSharpPrograms() } } + if (!neededFallback) + { + var fallbackAssets2 = AssetDatabase.FindAssets($"t:{nameof(UdonProgramAsset)}").Select(e => AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(e))).OfType(); + foreach (UdonSharpProgramAsset fallbackAsset in fallbackAssets2) + { + if (!_programAssetCache.Contains(fallbackAsset)) + { + Debug.LogWarning($"Repairing program asset {fallbackAsset} which Unity has broken pass 2"); + neededFallback = true; + + AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(fallbackAsset), + ImportAssetOptions.ForceUpdate); + } + } + } + if (neededFallback) { udonSharpDataAssets = AssetDatabase.FindAssets($"t:{nameof(UdonSharpProgramAsset)}");