diff --git a/CHANGELOG-PRERELEASE.md b/CHANGELOG-PRERELEASE.md index f25e8c8d..48ec60ef 100644 --- a/CHANGELOG-PRERELEASE.md +++ b/CHANGELOG-PRERELEASE.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog]. ### Fixed - Errors with models with UV at very edge `#1363` - Errors if exactly same AnimatorController is specified for multiple playable layers `#1366` +- Errors if objects removed by some component is listed on exclusions of Trace and Optimize `#1367` ### Security diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e4f947f..1db6943b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog]. ### Fixed - Errors with models with UV at very edge `#1363` - Errors if exactly same AnimatorController is specified for multiple playable layers `#1366` +- Errors if objects removed by some component is listed on exclusions of Trace and Optimize `#1367` ### Security diff --git a/Editor/Processors/TraceAndOptimize/FindUnusedObjectsProcessor.cs b/Editor/Processors/TraceAndOptimize/FindUnusedObjectsProcessor.cs index e19f64cc..336b89c7 100644 --- a/Editor/Processors/TraceAndOptimize/FindUnusedObjectsProcessor.cs +++ b/Editor/Processors/TraceAndOptimize/FindUnusedObjectsProcessor.cs @@ -70,7 +70,7 @@ public void MarkRecursively() internal readonly struct FindUnusedObjectsProcessor { private readonly BuildContext _context; - private readonly HashSet _exclusions; + private readonly HashSet _exclusions; private readonly bool _preserveEndBone; private readonly bool _noConfigureMergeBone; private readonly bool _noActivenessAnimation; @@ -248,8 +248,9 @@ private void Mark(GCComponentInfoHolder componentInfos) var markContext = new MarkObjectContext(componentInfos, _context.AvatarRootTransform, GetDependantMap); foreach (var gameObject in _exclusions) - foreach (var component in gameObject.GetComponents()) - markContext.MarkComponent(component, GCComponentInfo.DependencyType.Normal); + if (gameObject != null) + foreach (var component in gameObject.GetComponents()) + markContext.MarkComponent(component, GCComponentInfo.DependencyType.Normal); markContext.MarkRecursively(); } @@ -308,8 +309,9 @@ private void MarkDependant(GCComponentInfoHolder componentInfos) var markContext = new MarkObjectContext(componentInfos, _context.AvatarRootTransform, GetDependantMap); foreach (var gameObject in _exclusions) - foreach (var component in gameObject.GetComponents()) - markContext.MarkComponent(component, GCComponentInfo.DependencyType.Normal); + if (gameObject != null) + foreach (var component in gameObject.GetComponents()) + markContext.MarkComponent(component, GCComponentInfo.DependencyType.Normal); markContext.MarkRecursively(); } diff --git a/Internal/TraceAndOptimizeBase/TraceAndOptimizeProcessor.cs b/Internal/TraceAndOptimizeBase/TraceAndOptimizeProcessor.cs index b58e6050..a97bd2d3 100644 --- a/Internal/TraceAndOptimizeBase/TraceAndOptimizeProcessor.cs +++ b/Internal/TraceAndOptimizeBase/TraceAndOptimizeProcessor.cs @@ -18,7 +18,7 @@ public class TraceAndOptimizeState public bool MmdWorldCompatibility = true; public bool PreserveEndBone; - public HashSet Exclusions = new HashSet(); + public HashSet Exclusions = new(); public bool GCDebug; public bool NoConfigureMergeBone; public bool NoActivenessAnimation; @@ -56,7 +56,7 @@ internal void Initialize(TraceAndOptimize config) PreserveEndBone = config.preserveEndBone; - Exclusions = new HashSet(config.debugOptions.exclusions); + Exclusions = new HashSet(config.debugOptions.exclusions); GCDebug = config.debugOptions.gcDebug; NoConfigureMergeBone = config.debugOptions.noConfigureMergeBone; NoActivenessAnimation = config.debugOptions.noActivenessAnimation; diff --git a/Runtime/TraceAndOptimize.cs b/Runtime/TraceAndOptimize.cs index 4fb877a6..29832a48 100644 --- a/Runtime/TraceAndOptimize.cs +++ b/Runtime/TraceAndOptimize.cs @@ -102,7 +102,7 @@ internal TraceAndOptimize() internal struct DebugOptions { [Tooltip("Exclude some GameObjects from Trace and Optimize")] - public GameObject[] exclusions; + public GameObject?[] exclusions; [Tooltip("Add GC Debug Components instead of setting GC components")] [ToggleLeft] public bool gcDebug;