From d42f8376821a3e6095a5c8ded9fcaedfc05b40ec Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 29 Oct 2023 18:08:47 +0900 Subject: [PATCH 1/3] chore: split ComponentInfos for VRCSDK components --- Editor/APIInternal/ComponentInfos.VRCSDK.cs | 170 ++++++++++++++++++ .../APIInternal/ComponentInfos.VRCSDK.cs.meta | 3 + Editor/APIInternal/ComponentInfos.cs | 159 ---------------- 3 files changed, 173 insertions(+), 159 deletions(-) create mode 100644 Editor/APIInternal/ComponentInfos.VRCSDK.cs create mode 100644 Editor/APIInternal/ComponentInfos.VRCSDK.cs.meta diff --git a/Editor/APIInternal/ComponentInfos.VRCSDK.cs b/Editor/APIInternal/ComponentInfos.VRCSDK.cs new file mode 100644 index 000000000..27c6fb73d --- /dev/null +++ b/Editor/APIInternal/ComponentInfos.VRCSDK.cs @@ -0,0 +1,170 @@ +#if AAO_VRCSDK3_AVATARS +using System; +using System.Collections.Generic; +using Anatawa12.AvatarOptimizer.API; +using UnityEngine; +using VRC.SDK3; +using VRC.Core; +using VRC.Dynamics; +using VRC.SDK3.Avatars.Components; +using VRC.SDK3.Dynamics.Contact.Components; +using VRC.SDK3.Dynamics.PhysBone.Components; +using VRC.SDKBase; + +namespace Anatawa12.AvatarOptimizer.APIInternal.VRCSDK +{ + [ComponentInformation(typeof(VRCTestMarker))] +#pragma warning disable CS0618 + [ComponentInformation(typeof(PipelineSaver))] +#pragma warning restore CS0618 + [ComponentInformation(typeof(PipelineManager))] + [ComponentInformation(typeof(VRCSpatialAudioSource))] + [ComponentInformation(typeof(VRC_SpatialAudioSource))] + // nadena.dev.ndmf.VRChat.ContextHolder with reflection + internal class EntrypointComponentInformation : ComponentInformation + { + protected override void CollectDependency(Component component, ComponentDependencyCollector collector) + { + collector.MarkEntrypoint(); + } + } + + [ComponentInformation(typeof(VRC_AvatarDescriptor))] + internal class VRCAvatarDescriptorInformation : ComponentInformation where T : VRC_AvatarDescriptor + { + protected override void CollectDependency(T component, + ComponentDependencyCollector collector) + { + collector.MarkEntrypoint(); + collector.AddDependency(component.GetComponent()).EvenIfDependantDisabled(); + } + } + + [ComponentInformation(typeof(VRCAvatarDescriptor))] + internal class VRCAvatarDescriptorInformation : VRCAvatarDescriptorInformation + { + protected override void CollectDependency(VRCAvatarDescriptor component, + ComponentDependencyCollector collector) + { + base.CollectDependency(component, collector); + + AddCollider(component.collider_head); + AddCollider(component.collider_torso); + AddCollider(component.collider_footR); + AddCollider(component.collider_footL); + AddCollider(component.collider_handR); + AddCollider(component.collider_handL); + AddCollider(component.collider_fingerIndexL); + AddCollider(component.collider_fingerMiddleL); + AddCollider(component.collider_fingerRingL); + AddCollider(component.collider_fingerLittleL); + AddCollider(component.collider_fingerIndexR); + AddCollider(component.collider_fingerMiddleR); + AddCollider(component.collider_fingerRingR); + AddCollider(component.collider_fingerLittleR); + void AddCollider(VRCAvatarDescriptor.ColliderConfig collider) + { + switch (collider.state) + { + case VRCAvatarDescriptor.ColliderConfig.State.Automatic: + case VRCAvatarDescriptor.ColliderConfig.State.Custom: + collector.AddDependency(collider.transform).EvenIfDependantDisabled(); + break; + case VRCAvatarDescriptor.ColliderConfig.State.Disabled: + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + } + } + + [ComponentInformation(typeof(VRC.SDKBase.VRCStation))] + [ComponentInformation(typeof(VRC.SDK3.Avatars.Components.VRCStation))] + internal class VRCStationInformation : ComponentInformation + { + protected override void CollectDependency(VRC.SDKBase.VRCStation component, ComponentDependencyCollector collector) + { + // first, Transform <=> PhysBone + // Transform is used even if the bone is inactive so Transform => PB is always dependency + // PhysBone works only if enabled so PB => Transform is active dependency + collector.MarkEntrypoint(); + collector.AddDependency(component.stationEnterPlayerLocation); + collector.AddDependency(component.stationExitPlayerLocation); + collector.AddDependency(component.GetComponentInChildren()); + } + + protected override void CollectMutations(VRC.SDKBase.VRCStation component, ComponentMutationsCollector collector) + { + } + } + + [ComponentInformation(typeof(VRCPhysBoneBase))] + [ComponentInformation(typeof(VRCPhysBone))] + internal class VRCPhysBoneInformation : ComponentInformation + { + protected override void CollectDependency(VRCPhysBoneBase component, ComponentDependencyCollector collector) + { + // first, Transform <=> PhysBone + // Transform is used even if the bone is inactive so Transform => PB is always dependency + // PhysBone works only if enabled so PB => Transform is active dependency + var ignoreTransforms = new HashSet(component.ignoreTransforms); + CollectTransforms(component.GetTarget()); + + void CollectTransforms(Transform bone) + { + collector.AddDependency(bone, component).EvenIfDependantDisabled().OnlyIfTargetCanBeEnable(); + collector.AddDependency(bone); + foreach (var child in bone.DirectChildrenEnumerable()) + { + if (!ignoreTransforms.Contains(child)) + CollectTransforms(child); + } + } + + // then, PB => Collider + // in PB, PB Colliders work only if Colliders are enabled + foreach (var physBoneCollider in component.colliders) + collector.AddDependency(physBoneCollider).OnlyIfTargetCanBeEnable(); + + collector.MarkBehaviour(); + + // If parameter is not empty, the PB can be required for Animator Parameter so it's Entrypoint Component + // https://github.com/anatawa12/AvatarOptimizer/issues/450 + if (!string.IsNullOrEmpty(component.parameter)) + collector.MarkEntrypoint(); + } + + protected override void CollectMutations(VRCPhysBoneBase component, ComponentMutationsCollector collector) + { + foreach (var transform in component.GetAffectedTransforms()) + collector.TransformPositionAndRotation(transform); + } + } + + [ComponentInformation(typeof(VRCPhysBoneColliderBase))] + [ComponentInformation(typeof(VRCPhysBoneCollider))] + internal class VRCPhysBoneColliderInformation : ComponentInformation + { + protected override void CollectDependency(VRCPhysBoneColliderBase component, + ComponentDependencyCollector collector) + { + collector.AddDependency(component.rootTransform); + } + } + + [ComponentInformation(typeof(ContactBase))] + [ComponentInformation(typeof(ContactReceiver))] + [ComponentInformation(typeof(VRCContactReceiver))] + [ComponentInformation(typeof(ContactSender))] + [ComponentInformation(typeof(VRCContactSender))] + internal class ContactBaseInformation : ComponentInformation + { + protected override void CollectDependency(ContactBase component, ComponentDependencyCollector collector) + { + collector.MarkEntrypoint(); + collector.AddDependency(component.rootTransform); + } + } +} +#endif diff --git a/Editor/APIInternal/ComponentInfos.VRCSDK.cs.meta b/Editor/APIInternal/ComponentInfos.VRCSDK.cs.meta new file mode 100644 index 000000000..20a13e5bf --- /dev/null +++ b/Editor/APIInternal/ComponentInfos.VRCSDK.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 30f0ea96677e4ce9bfe472c482e0b4ac +timeCreated: 1698570184 \ No newline at end of file diff --git a/Editor/APIInternal/ComponentInfos.cs b/Editor/APIInternal/ComponentInfos.cs index 61bb23cd3..d2bb9e72f 100644 --- a/Editor/APIInternal/ComponentInfos.cs +++ b/Editor/APIInternal/ComponentInfos.cs @@ -6,31 +6,12 @@ using UnityEngine.Animations; using UnityEngine.Rendering; -#if AAO_VRCSDK3_AVATARS -using VRC.SDK3; -using VRC.Core; -using VRC.Dynamics; -using VRC.SDK3.Avatars.Components; -using VRC.SDK3.Dynamics.Contact.Components; -using VRC.SDK3.Dynamics.PhysBone.Components; -using VRC.SDKBase; -#endif - namespace Anatawa12.AvatarOptimizer.APIInternal { [ComponentInformation(typeof(Light))] [ComponentInformation(typeof(Camera))] [ComponentInformation(typeof(Animation))] [ComponentInformation(typeof(AudioSource))] -#if AAO_VRCSDK3_AVATARS - [ComponentInformation(typeof(VRCTestMarker))] -#pragma warning disable CS0618 - [ComponentInformation(typeof(PipelineSaver))] -#pragma warning restore CS0618 - [ComponentInformation(typeof(PipelineManager))] - [ComponentInformation(typeof(VRCSpatialAudioSource))] - [ComponentInformation(typeof(VRC_SpatialAudioSource))] -#endif [ComponentInformation(typeof(nadena.dev.ndmf.runtime.AvatarActivator))] // nadena.dev.ndmf.VRChat.ContextHolder with reflection internal class EntrypointComponentInformation : ComponentInformation @@ -392,146 +373,6 @@ protected override void CollectMutations(ScaleConstraint component, ComponentMut } } -#if AAO_VRCSDK3_AVATARS - [ComponentInformation(typeof(VRC_AvatarDescriptor))] - internal class VRCAvatarDescriptorInformation : ComponentInformation where T : VRC_AvatarDescriptor - { - protected override void CollectDependency(T component, - ComponentDependencyCollector collector) - { - collector.MarkEntrypoint(); - collector.AddDependency(component.GetComponent()).EvenIfDependantDisabled(); - } - } - - [ComponentInformation(typeof(VRCAvatarDescriptor))] - internal class VRCAvatarDescriptorInformation : VRCAvatarDescriptorInformation - { - protected override void CollectDependency(VRCAvatarDescriptor component, - ComponentDependencyCollector collector) - { - base.CollectDependency(component, collector); - - AddCollider(component.collider_head); - AddCollider(component.collider_torso); - AddCollider(component.collider_footR); - AddCollider(component.collider_footL); - AddCollider(component.collider_handR); - AddCollider(component.collider_handL); - AddCollider(component.collider_fingerIndexL); - AddCollider(component.collider_fingerMiddleL); - AddCollider(component.collider_fingerRingL); - AddCollider(component.collider_fingerLittleL); - AddCollider(component.collider_fingerIndexR); - AddCollider(component.collider_fingerMiddleR); - AddCollider(component.collider_fingerRingR); - AddCollider(component.collider_fingerLittleR); - void AddCollider(VRCAvatarDescriptor.ColliderConfig collider) - { - switch (collider.state) - { - case VRCAvatarDescriptor.ColliderConfig.State.Automatic: - case VRCAvatarDescriptor.ColliderConfig.State.Custom: - collector.AddDependency(collider.transform).EvenIfDependantDisabled(); - break; - case VRCAvatarDescriptor.ColliderConfig.State.Disabled: - break; - default: - throw new ArgumentOutOfRangeException(); - } - } - } - } - - [ComponentInformation(typeof(VRC.SDKBase.VRCStation))] - [ComponentInformation(typeof(VRC.SDK3.Avatars.Components.VRCStation))] - internal class VRCStationInformation : ComponentInformation - { - protected override void CollectDependency(VRC.SDKBase.VRCStation component, ComponentDependencyCollector collector) - { - // first, Transform <=> PhysBone - // Transform is used even if the bone is inactive so Transform => PB is always dependency - // PhysBone works only if enabled so PB => Transform is active dependency - collector.MarkEntrypoint(); - collector.AddDependency(component.stationEnterPlayerLocation); - collector.AddDependency(component.stationExitPlayerLocation); - collector.AddDependency(component.GetComponentInChildren()); - } - - protected override void CollectMutations(VRC.SDKBase.VRCStation component, ComponentMutationsCollector collector) - { - } - } - - [ComponentInformation(typeof(VRCPhysBoneBase))] - [ComponentInformation(typeof(VRCPhysBone))] - internal class VRCPhysBoneInformation : ComponentInformation - { - protected override void CollectDependency(VRCPhysBoneBase component, ComponentDependencyCollector collector) - { - // first, Transform <=> PhysBone - // Transform is used even if the bone is inactive so Transform => PB is always dependency - // PhysBone works only if enabled so PB => Transform is active dependency - var ignoreTransforms = new HashSet(component.ignoreTransforms); - CollectTransforms(component.GetTarget()); - - void CollectTransforms(Transform bone) - { - collector.AddDependency(bone, component).EvenIfDependantDisabled().OnlyIfTargetCanBeEnable(); - collector.AddDependency(bone); - foreach (var child in bone.DirectChildrenEnumerable()) - { - if (!ignoreTransforms.Contains(child)) - CollectTransforms(child); - } - } - - // then, PB => Collider - // in PB, PB Colliders work only if Colliders are enabled - foreach (var physBoneCollider in component.colliders) - collector.AddDependency(physBoneCollider).OnlyIfTargetCanBeEnable(); - - collector.MarkBehaviour(); - - // If parameter is not empty, the PB can be required for Animator Parameter so it's Entrypoint Component - // https://github.com/anatawa12/AvatarOptimizer/issues/450 - if (!string.IsNullOrEmpty(component.parameter)) - collector.MarkEntrypoint(); - } - - protected override void CollectMutations(VRCPhysBoneBase component, ComponentMutationsCollector collector) - { - foreach (var transform in component.GetAffectedTransforms()) - collector.TransformPositionAndRotation(transform); - } - } - - [ComponentInformation(typeof(VRCPhysBoneColliderBase))] - [ComponentInformation(typeof(VRCPhysBoneCollider))] - internal class VRCPhysBoneColliderInformation : ComponentInformation - { - protected override void CollectDependency(VRCPhysBoneColliderBase component, - ComponentDependencyCollector collector) - { - collector.AddDependency(component.rootTransform); - } - } - - [ComponentInformation(typeof(ContactBase))] - [ComponentInformation(typeof(ContactReceiver))] - [ComponentInformation(typeof(VRCContactReceiver))] - [ComponentInformation(typeof(ContactSender))] - [ComponentInformation(typeof(VRCContactSender))] - internal class ContactBaseInformation : ComponentInformation - { - protected override void CollectDependency(ContactBase component, ComponentDependencyCollector collector) - { - collector.MarkEntrypoint(); - collector.AddDependency(component.rootTransform); - } - } -#endif - [ComponentInformation(typeof(RemoveMeshByBlendShape))] internal class RemoveMeshByBlendShapeInformation : ComponentInformation { From 7c4c6b849f04e7603cf46fc4b7353a6cec33d9bb Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 29 Oct 2023 19:07:08 +0900 Subject: [PATCH 2/3] chore: separate ComponentInfos file for non-unity components --- .../APIInternal/ComponentInfos.Externals.cs | 92 +++++++++++++++++++ .../ComponentInfos.Externals.cs.meta | 3 + Editor/APIInternal/ComponentInfos.cs | 80 ---------------- 3 files changed, 95 insertions(+), 80 deletions(-) create mode 100644 Editor/APIInternal/ComponentInfos.Externals.cs create mode 100644 Editor/APIInternal/ComponentInfos.Externals.cs.meta diff --git a/Editor/APIInternal/ComponentInfos.Externals.cs b/Editor/APIInternal/ComponentInfos.Externals.cs new file mode 100644 index 000000000..694a9627d --- /dev/null +++ b/Editor/APIInternal/ComponentInfos.Externals.cs @@ -0,0 +1,92 @@ +using System.Collections.Generic; +using Anatawa12.AvatarOptimizer.API; +using UnityEngine; + +namespace Anatawa12.AvatarOptimizer.APIInternal.Externals +{ + #region Dynamic Bones + + [ComponentInformationWithGUID("f9ac8d30c6a0d9642a11e5be4c440740", 11500000)] + internal class DynamicBoneInformation : ComponentInformation + { + protected override void CollectDependency(Component component, ComponentDependencyCollector collector) + { + collector.MarkBehaviour(); + + foreach (var transform in GetAffectedTransforms(component)) + { + collector.AddDependency(transform, component) + .EvenIfDependantDisabled() + .OnlyIfTargetCanBeEnable(); + collector.AddDependency(transform); + } + + foreach (var collider in (IReadOnlyList)((dynamic)component).m_Colliders) + { + // DynamicBone ignores enabled/disabled of Collider Component AFAIK + collector.AddDependency(collider); + } + } + + protected override void CollectMutations(Component component, ComponentMutationsCollector collector) + { + foreach (var transform in GetAffectedTransforms(component)) + collector.TransformRotation(transform); + } + + private static IEnumerable GetAffectedTransforms(dynamic dynamicBone) + { + var ignores = new HashSet(dynamicBone.m_Exclusions); + var queue = new Queue(); + Transform root = dynamicBone.m_Root; + queue.Enqueue(root ? root : (Transform)dynamicBone.transform); + + while (queue.Count != 0) + { + var transform = queue.Dequeue(); + yield return transform; + + foreach (var child in transform.DirectChildrenEnumerable()) + if (!ignores.Contains(child)) + queue.Enqueue(child); + } + } + } + + [ComponentInformationWithGUID("baedd976e12657241bf7ff2d1c685342", 11500000)] + internal class DynamicBoneColliderInformation : ComponentInformation + { + protected override void CollectDependency(Component component, ComponentDependencyCollector collector) + { + } + } + + #endregion + + #region Satania's KiseteneEx Components + + [ComponentInformationWithGUID("e78466b6bcd24e5409dca557eb81d45b", 11500000)] // KiseteneComponent + [ComponentInformationWithGUID("7f9c3fe1cfb9d1843a9dc7da26352ce2", 11500000)] // FlyAvatarSetupTool + [ComponentInformationWithGUID("95f6e1368d803614f8a351322ab09bac", 11500000)] // BlendShapeOverrider + internal class SataniaKiseteneExComponents : ComponentInformation + { + protected override void CollectDependency(Component component, ComponentDependencyCollector collector) + { + } + } + + #endregion + + + #region VRCQuestTools + + [ComponentInformationWithGUID("f055e14e1beba894ea68aedffde8ada6", 11500000)] // VertexColorRemover + internal class VRCQuestToolsComponents : ComponentInformation + { + protected override void CollectDependency(Component component, ComponentDependencyCollector collector) + { + } + } + + #endregion +} \ No newline at end of file diff --git a/Editor/APIInternal/ComponentInfos.Externals.cs.meta b/Editor/APIInternal/ComponentInfos.Externals.cs.meta new file mode 100644 index 000000000..f34ddf5b5 --- /dev/null +++ b/Editor/APIInternal/ComponentInfos.Externals.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ef6f55cacb894179923d74a3a9e2b719 +timeCreated: 1698570642 \ No newline at end of file diff --git a/Editor/APIInternal/ComponentInfos.cs b/Editor/APIInternal/ComponentInfos.cs index d2bb9e72f..50437df22 100644 --- a/Editor/APIInternal/ComponentInfos.cs +++ b/Editor/APIInternal/ComponentInfos.cs @@ -418,86 +418,6 @@ protected override void CollectMutations(MergeBone component, ComponentMutations } } - [ComponentInformationWithGUID("f9ac8d30c6a0d9642a11e5be4c440740", 11500000)] - internal class DynamicBoneInformation : ComponentInformation - { - protected override void CollectDependency(Component component, ComponentDependencyCollector collector) - { - collector.MarkBehaviour(); - - foreach (var transform in GetAffectedTransforms(component)) - { - collector.AddDependency(transform, component) - .EvenIfDependantDisabled() - .OnlyIfTargetCanBeEnable(); - collector.AddDependency(transform); - } - - foreach (var collider in (IReadOnlyList)((dynamic)component).m_Colliders) - { - // DynamicBone ignores enabled/disabled of Collider Component AFAIK - collector.AddDependency(collider); - } - } - - protected override void CollectMutations(Component component, ComponentMutationsCollector collector) - { - foreach (var transform in GetAffectedTransforms(component)) - collector.TransformRotation(transform); - } - - private static IEnumerable GetAffectedTransforms(dynamic dynamicBone) - { - var ignores = new HashSet(dynamicBone.m_Exclusions); - var queue = new Queue(); - Transform root = dynamicBone.m_Root; - queue.Enqueue(root ? root : (Transform)dynamicBone.transform); - - while (queue.Count != 0) - { - var transform = queue.Dequeue(); - yield return transform; - - foreach (var child in transform.DirectChildrenEnumerable()) - if (!ignores.Contains(child)) - queue.Enqueue(child); - } - } - } - - [ComponentInformationWithGUID("baedd976e12657241bf7ff2d1c685342", 11500000)] - internal class DynamicBoneColliderInformation : ComponentInformation - { - protected override void CollectDependency(Component component, ComponentDependencyCollector collector) - { - } - } - - #region Satania's KiseteneEx Components - [ComponentInformationWithGUID("e78466b6bcd24e5409dca557eb81d45b", 11500000)] // KiseteneComponent - [ComponentInformationWithGUID("7f9c3fe1cfb9d1843a9dc7da26352ce2", 11500000)] // FlyAvatarSetupTool - [ComponentInformationWithGUID("95f6e1368d803614f8a351322ab09bac", 11500000)] // BlendShapeOverrider - internal class SataniaKiseteneExComponents : ComponentInformation - { - protected override void CollectDependency(Component component, ComponentDependencyCollector collector) - { - } - } - #endregion - - - #region VRCQuestTools - - [ComponentInformationWithGUID("f055e14e1beba894ea68aedffde8ada6", 11500000)] // VertexColorRemover - internal class VRCQuestToolsComponents : ComponentInformation - { - protected override void CollectDependency(Component component, ComponentDependencyCollector collector) - { - } - } - - #endregion - internal static class ComponentInformationExtensions { public static void TransformPositionAndRotation(this ComponentMutationsCollector collector, From fefaf8c378ce4616dc228f282c2370109a897b0d Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 29 Oct 2023 19:12:34 +0900 Subject: [PATCH 3/3] chore: mark component infos for externals as a fallback --- Editor/APIInternal/ComponentInfoRegistry.cs | 29 +++++++++++++++---- .../APIInternal/ComponentInfos.Externals.cs | 18 +++++++++--- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/Editor/APIInternal/ComponentInfoRegistry.cs b/Editor/APIInternal/ComponentInfoRegistry.cs index 7ce572638..eef843eb2 100644 --- a/Editor/APIInternal/ComponentInfoRegistry.cs +++ b/Editor/APIInternal/ComponentInfoRegistry.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Anatawa12.AvatarOptimizer.APIInternal.Externals; using UnityEditor; using UnityEngine; @@ -64,11 +65,29 @@ private static void LoadType(Type type, ComponentInformationAttributeBase attrib if (!informationType.IsAssignableFrom(type)) throw new Exception("Unsupported type : Not Extends from ComponentInformation"); - if (InformationByType.ContainsKey(targetType)) - throw new Exception($"Target Type duplicated: {targetType}"); - - var instance = (ComponentInformation)System.Activator.CreateInstance(type); - InformationByType.Add(targetType, instance); + if (InformationByType.TryGetValue(targetType, out var existing)) + { + if (existing is IExternalMarker) + { + // if existing is fallback, use new one + var instance = (ComponentInformation)System.Activator.CreateInstance(type); + InformationByType[targetType] = instance; + } + else if (typeof(IExternalMarker).IsAssignableFrom(targetType)) + { + // if adding is fallback, use existing one + } + else + { + // otherwise, in other words, If both are not fallback, throw exception + throw new Exception($"Target Type duplicated: {targetType}"); + } + } + else + { + var instance = (ComponentInformation)System.Activator.CreateInstance(type); + InformationByType.Add(targetType, instance); + } } internal static bool TryGetInformation(Type type, out ComponentInformation information) => diff --git a/Editor/APIInternal/ComponentInfos.Externals.cs b/Editor/APIInternal/ComponentInfos.Externals.cs index 694a9627d..57a6448e7 100644 --- a/Editor/APIInternal/ComponentInfos.Externals.cs +++ b/Editor/APIInternal/ComponentInfos.Externals.cs @@ -4,10 +4,20 @@ namespace Anatawa12.AvatarOptimizer.APIInternal.Externals { + /// + /// Marker interface for fallback ComponentInformation(s) for external library. + /// + /// Thanks to this interface, upstream author can register those component types without causing duplication error + /// and override information by Avatar Optimizer. + /// + internal interface IExternalMarker + { + } + #region Dynamic Bones [ComponentInformationWithGUID("f9ac8d30c6a0d9642a11e5be4c440740", 11500000)] - internal class DynamicBoneInformation : ComponentInformation + internal class DynamicBoneInformation : ComponentInformation, IExternalMarker { protected override void CollectDependency(Component component, ComponentDependencyCollector collector) { @@ -54,7 +64,7 @@ private static IEnumerable GetAffectedTransforms(dynamic dynamicBone) } [ComponentInformationWithGUID("baedd976e12657241bf7ff2d1c685342", 11500000)] - internal class DynamicBoneColliderInformation : ComponentInformation + internal class DynamicBoneColliderInformation : ComponentInformation, IExternalMarker { protected override void CollectDependency(Component component, ComponentDependencyCollector collector) { @@ -68,7 +78,7 @@ protected override void CollectDependency(Component component, ComponentDependen [ComponentInformationWithGUID("e78466b6bcd24e5409dca557eb81d45b", 11500000)] // KiseteneComponent [ComponentInformationWithGUID("7f9c3fe1cfb9d1843a9dc7da26352ce2", 11500000)] // FlyAvatarSetupTool [ComponentInformationWithGUID("95f6e1368d803614f8a351322ab09bac", 11500000)] // BlendShapeOverrider - internal class SataniaKiseteneExComponents : ComponentInformation + internal class SataniaKiseteneExComponents : ComponentInformation, IExternalMarker { protected override void CollectDependency(Component component, ComponentDependencyCollector collector) { @@ -81,7 +91,7 @@ protected override void CollectDependency(Component component, ComponentDependen #region VRCQuestTools [ComponentInformationWithGUID("f055e14e1beba894ea68aedffde8ada6", 11500000)] // VertexColorRemover - internal class VRCQuestToolsComponents : ComponentInformation + internal class VRCQuestToolsComponents : ComponentInformation, IExternalMarker { protected override void CollectDependency(Component component, ComponentDependencyCollector collector) {