Skip to content

Commit

Permalink
Merge pull request #512 from anatawa12/avatar-activator-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 authored Sep 25, 2023
2 parents a64d970 + 4b84df7 commit 4031909
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ The format is based on [Keep a Changelog].
### Removed

### Fixed
- (legacy) Animation Component Disappears `#512`
- VRC_SpatialAudioSource Disappears `#512`
- Unknown component warning for AvatarActivator of NDMF `#512`

### Security

Expand Down
52 changes: 26 additions & 26 deletions Editor/Processors/TraceAndOptimize/ComponentDependencyCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ private static void AddNopParser<T>() where T : Component
_byTypeParser.Add(typeof(T), (collector, deps, component) => { });
}

private static void AddEntryPointParser<T>() where T : Component
{
_byTypeParser.Add(typeof(T), (collector, deps, component) => deps.EntrypointComponent = true);
}

private static void AddParserWithExtends<TParent, TChild>()
where TParent : Component
where TChild : TParent
Expand Down Expand Up @@ -263,7 +268,7 @@ private static void InitByTypeParsers()
}
}
});
AddNopParser<Animation>();
AddEntryPointParser<Animation>();
AddParser<Renderer>((collector, deps, renderer) =>
{
// GameObject => Renderer dependency ship
Expand Down Expand Up @@ -383,10 +388,7 @@ private static void InitByTypeParsers()
deps.AddActiveDependency(collider.second);
}
});
AddParser<Light>((collector, deps, component) =>
{
deps.EntrypointComponent = true;
});
AddEntryPointParser<Light>();
AddParser<Collider>((collector, deps, component) =>
{
deps.EntrypointComponent = true;
Expand Down Expand Up @@ -415,20 +417,14 @@ private static void InitByTypeParsers()
collector.GetDependencies(component.transform)
.AddAlwaysDependency(component, true);
});
AddParser<Camera>((collector, deps, component) =>
{
// affects RenderTexture
deps.EntrypointComponent = true;
});
// affects RenderTexture
AddEntryPointParser<Camera>();
AddParser<FlareLayer>((collector, deps, component) =>
{
collector.GetDependencies(component.GetComponent<Camera>()).AddActiveDependency(component);
});
AddParser<AudioSource>((collector, deps, component) =>
{
// plays sound
deps.EntrypointComponent = true;
});
// plays sound
AddEntryPointParser<AudioSource>();
AddParser<AimConstraint>((collector, deps, component) =>
{
ConstraintParser(collector, deps, component);
Expand Down Expand Up @@ -462,13 +458,9 @@ void ConstraintParser<TConstraint>(ComponentDependencyCollector collector, Compo
deps.AddAlwaysDependency(component.GetComponent<PipelineManager>());
});
AddParserWithExtends<VRC_AvatarDescriptor, VRCAvatarDescriptor>();
AddNopParser<PipelineManager>();
AddEntryPointParser<PipelineManager>();
#pragma warning disable CS0618
AddParser<PipelineSaver>((collector, deps, component) =>
{
// to avoid unexpected deletion
deps.EntrypointComponent = true;
});
AddEntryPointParser<PipelineSaver>();
#pragma warning restore CS0618
AddParser<VRC.SDKBase.VRCStation>((collector, deps, component) =>
{
Expand Down Expand Up @@ -525,7 +517,7 @@ void CollectTransforms(Transform bone)
AddParserWithExtends<ContactBase, ContactSender>();
AddParserWithExtends<ContactSender, VRCContactSender>();

AddNopParser<VRC_SpatialAudioSource>();
AddEntryPointParser<VRC_SpatialAudioSource>();
AddParserWithExtends<VRC_SpatialAudioSource, VRCSpatialAudioSource>();

// VRC_IKFollower is not available in SDK 3
Expand Down Expand Up @@ -557,13 +549,21 @@ void CollectTransforms(Transform bone)

// TODOL External Library: FinalIK

// Components Proceed after T&O later
AddParser<MergeBone>((collector, deps, component) =>
// NDMF
AddEntryPointParser<nadena.dev.ndmf.runtime.AvatarActivator>();
var contextHolder = typeof(nadena.dev.ndmf.BuildContext).Assembly
.GetType("nadena.dev.ndmf.VRChat.ContextHolder");
if (contextHolder != null)
{
deps.EntrypointComponent = true;
});
// nadena.dev.ndmf.VRChat.ContextHolder is internal so I use reflection
_byTypeParser.Add(contextHolder, (collector, deps, component) => deps.EntrypointComponent = true);
}

// Components Proceed after T&O later
AddEntryPointParser<MergeBone>();
}

#endregion
}
}

3 changes: 2 additions & 1 deletion Editor/com.anatawa12.avatar-optimizer.editor.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"GUID:b9880ca0b6584453a2627bd3c038759f",
"GUID:8542dbf824204440a818dbc2377cb4d6",
"GUID:2665a8d13d1b3f18800f46e256720795",
"GUID:62ced99b048af7f4d8dfe4bed8373d76"
"GUID:62ced99b048af7f4d8dfe4bed8373d76",
"GUID:fe747755f7b44e048820525b07f9b956"
],
"includePlatforms": [
"Editor"
Expand Down

0 comments on commit 4031909

Please sign in to comment.