Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Errors if objects removed by some component is listed on exclusions of Trace and Optimize #1367

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 7 additions & 5 deletions Editor/Processors/TraceAndOptimize/FindUnusedObjectsProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void MarkRecursively()
internal readonly struct FindUnusedObjectsProcessor
{
private readonly BuildContext _context;
private readonly HashSet<GameObject> _exclusions;
private readonly HashSet<GameObject?> _exclusions;
private readonly bool _preserveEndBone;
private readonly bool _noConfigureMergeBone;
private readonly bool _noActivenessAnimation;
Expand Down Expand Up @@ -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<Component>())
markContext.MarkComponent(component, GCComponentInfo.DependencyType.Normal);
if (gameObject != null)
foreach (var component in gameObject.GetComponents<Component>())
markContext.MarkComponent(component, GCComponentInfo.DependencyType.Normal);

markContext.MarkRecursively();
}
Expand Down Expand Up @@ -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<Component>())
markContext.MarkComponent(component, GCComponentInfo.DependencyType.Normal);
if (gameObject != null)
foreach (var component in gameObject.GetComponents<Component>())
markContext.MarkComponent(component, GCComponentInfo.DependencyType.Normal);

markContext.MarkRecursively();
}
Expand Down
4 changes: 2 additions & 2 deletions Internal/TraceAndOptimizeBase/TraceAndOptimizeProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class TraceAndOptimizeState
public bool MmdWorldCompatibility = true;

public bool PreserveEndBone;
public HashSet<GameObject> Exclusions = new HashSet<GameObject>();
public HashSet<GameObject?> Exclusions = new();
public bool GCDebug;
public bool NoConfigureMergeBone;
public bool NoActivenessAnimation;
Expand Down Expand Up @@ -56,7 +56,7 @@ internal void Initialize(TraceAndOptimize config)

PreserveEndBone = config.preserveEndBone;

Exclusions = new HashSet<GameObject>(config.debugOptions.exclusions);
Exclusions = new HashSet<GameObject?>(config.debugOptions.exclusions);
GCDebug = config.debugOptions.gcDebug;
NoConfigureMergeBone = config.debugOptions.noConfigureMergeBone;
NoActivenessAnimation = config.debugOptions.noActivenessAnimation;
Expand Down
2 changes: 1 addition & 1 deletion Runtime/TraceAndOptimize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading