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

chore: add NotKeyable to every components #551

Merged
merged 2 commits into from
Oct 10, 2023
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
2 changes: 2 additions & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ The format is based on [Keep a Changelog].
### Added

### Changed
- You now cannot key any of AvatarOptimizer Components `#551`
- Previously you can key AvatarOptimizer Coponent but it was meaningless.

### Deprecated

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ The format is based on [Keep a Changelog].
- Feature for debugging GC Objects `#543`

### Changed
- You now cannot key any of AvatarOptimizer Components `#551`
- Previously you can key AvatarOptimizer Coponent but it was meaningless.

### Deprecated

Expand Down
3 changes: 2 additions & 1 deletion Internal/PrefabSafeSet/Runtime/PrefabSafeSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Reflection;
using JetBrains.Annotations;
using UnityEngine;
using UnityEngine.Animations;
using Object = UnityEngine.Object;

namespace Anatawa12.AvatarOptimizer.PrefabSafeSet
Expand Down Expand Up @@ -58,7 +59,7 @@ public static MethodInfo GetOnBeforeSerializeCallbackMethod(Type tType, Type tLa
/// </summary>
/// <typeparam name="T">Element Type</typeparam>
/// <typeparam name="TLayer">Layer Type</typeparam>
[Serializable]
[NotKeyable, Serializable]
public class PrefabSafeSet<T, TLayer> : ISerializationCallbackReceiver where TLayer : PrefabLayer<T>, new()
{
[SerializeField] internal T[] mainSet = Array.Empty<T>();
Expand Down
1 change: 1 addition & 0 deletions Runtime/AvatarTagComponent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using Anatawa12.AvatarOptimizer.ErrorReporting;
using UnityEngine;
using UnityEngine.Animations;
using VRC.SDKBase;

namespace Anatawa12.AvatarOptimizer
Expand Down
2 changes: 2 additions & 0 deletions Runtime/ClearEndpointPosition.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using UnityEngine;
using UnityEngine.Animations;
using VRC.Dynamics;

namespace Anatawa12.AvatarOptimizer
{
[AddComponentMenu("Avatar Optimizer/AAO Clear Endpoint Position")]
[RequireComponent(typeof(VRCPhysBoneBase))]
[DisallowMultipleComponent]
[NotKeyable]
[HelpURL("https://vpm.anatawa12.com/avatar-optimizer/ja/docs/reference/clear-endpoint-position/")]
internal class ClearEndpointPosition : AvatarTagComponent
{
Expand Down
1 change: 1 addition & 0 deletions Runtime/FreezeBlendShape.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations;

namespace Anatawa12.AvatarOptimizer
{
Expand Down
2 changes: 2 additions & 0 deletions Runtime/InternalAutoFreezeMeaninglessBlendShape.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System.Collections.Generic;
using JetBrains.Annotations;
using UnityEngine;
using UnityEngine.Animations;

namespace Anatawa12.AvatarOptimizer
{
// TODO move to somewhere else? e.g. in editor module if possible
[AddComponentMenu("")]
[DisallowMultipleComponent]
[NotKeyable]
internal class InternalAutoFreezeMeaninglessBlendShape : EditSkinnedMeshComponent
{
[CanBeNull] internal HashSet<string> Preserve;
Expand Down
2 changes: 2 additions & 0 deletions Runtime/Legacy/Activator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.Animations;

namespace Anatawa12.AvatarOptimizer
{
Expand All @@ -13,6 +14,7 @@ namespace Anatawa12.AvatarOptimizer
[ExecuteAlways]
[DefaultExecutionOrder(-9989)]
[DisallowMultipleComponent]
[NotKeyable]
internal class Activator : MonoBehaviour
{
private void OnValidate()
Expand Down
2 changes: 2 additions & 0 deletions Runtime/Legacy/GlobalActivator.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using UnityEngine;
using UnityEngine.Animations;

namespace Anatawa12.ApplyOnPlay
{
[DefaultExecutionOrder(-100000)]
[ExecuteAlways]
[AddComponentMenu("")]
[DisallowMultipleComponent]
[NotKeyable]
internal class GlobalActivator : MonoBehaviour
{
#if UNITY_EDITOR
Expand Down
5 changes: 3 additions & 2 deletions Runtime/MakeChildren.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CustomLocalization4EditorExtension;
using UnityEngine;
using UnityEngine.Animations;

namespace Anatawa12.AvatarOptimizer
{
Expand All @@ -8,9 +9,9 @@ namespace Anatawa12.AvatarOptimizer
[HelpURL("https://vpm.anatawa12.com/avatar-optimizer/ja/docs/reference/make-children/")]
internal class MakeChildren : AvatarTagComponent
{
[CL4EELocalized("MakeChildren:prop:executeEarly", "MakeChildren:tooltip:executeEarly")]
[NotKeyable, CL4EELocalized("MakeChildren:prop:executeEarly", "MakeChildren:tooltip:executeEarly")]
public bool executeEarly;
[CL4EELocalized("MakeChildren:prop:children")]
[NotKeyable, CL4EELocalized("MakeChildren:prop:children")]
public PrefabSafeSet.TransformSet children;
}
}
3 changes: 2 additions & 1 deletion Runtime/MergeBone.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Anatawa12.AvatarOptimizer.ErrorReporting;
using CustomLocalization4EditorExtension;
using UnityEngine;
using UnityEngine.Animations;

namespace Anatawa12.AvatarOptimizer
{
Expand All @@ -9,7 +10,7 @@ namespace Anatawa12.AvatarOptimizer
[HelpURL("https://vpm.anatawa12.com/avatar-optimizer/ja/docs/reference/merge-bone/")]
internal class MergeBone : AvatarTagComponent, IStaticValidated
{
[CL4EELocalized("MergeBone:prop:avoidNameConflict", "MergeBone:tooltip:avoidNameConflict")]
[NotKeyable, CL4EELocalized("MergeBone:prop:avoidNameConflict", "MergeBone:tooltip:avoidNameConflict")]
[ToggleLeft]
public bool avoidNameConflict;

Expand Down
56 changes: 29 additions & 27 deletions Runtime/MergePhysBone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using CustomLocalization4EditorExtension;
using JetBrains.Annotations;
using UnityEngine;
using UnityEngine.Animations;
using VRC.Dynamics;

namespace Anatawa12.AvatarOptimizer
Expand All @@ -14,57 +15,58 @@ namespace Anatawa12.AvatarOptimizer
[HelpURL("https://vpm.anatawa12.com/avatar-optimizer/ja/docs/reference/merge-physbone/")]
internal class MergePhysBone : AvatarTagComponent, IStaticValidated
{
[NotKeyable]
[CL4EELocalized("MergePhysBone:prop:makeParent", "MergePhysBone:tooltip:makeParent")]
public bool makeParent;

#region OverrideAndValue

public VersionConfig versionConfig;
[NotKeyable] public VersionConfig versionConfig;

#region == Transform ==
// rootTransform
// ignoreTransforms
public EndPointPositionConfig endpointPositionConfig;
[NotKeyable] public EndPointPositionConfig endpointPositionConfig;
// multiChildType
#endregion

#region == Forces ==
public IntegrationTypeConfig integrationTypeConfig;
public Curve0To1Config pullConfig;
[NotKeyable] public IntegrationTypeConfig integrationTypeConfig;
[NotKeyable] public Curve0To1Config pullConfig;
// spring a.k.a. Momentum
public Curve0To1Config springConfig;
public Curve0To1Config stiffnessConfig;
public CurveM1To1Config gravityConfig;
public Curve0To1Config gravityFalloffConfig;
public ImmobileTypeConfig immobileTypeConfig;
public Curve0To1Config immobileConfig;
[NotKeyable] public Curve0To1Config springConfig;
[NotKeyable] public Curve0To1Config stiffnessConfig;
[NotKeyable] public CurveM1To1Config gravityConfig;
[NotKeyable] public Curve0To1Config gravityFalloffConfig;
[NotKeyable] public ImmobileTypeConfig immobileTypeConfig;
[NotKeyable] public Curve0To1Config immobileConfig;
#endregion
#region == Limits ==
public LimitTypeConfig limitTypeConfig;
public Curve0To180Config maxAngleXConfig = new Curve0To180Config(45f);
public Curve0To90Config maxAngleZConfig = new Curve0To90Config(45f);
public CurveVector3Config limitRotationConfig;
[NotKeyable] public LimitTypeConfig limitTypeConfig;
[NotKeyable] public Curve0To180Config maxAngleXConfig = new Curve0To180Config(45f);
[NotKeyable] public Curve0To90Config maxAngleZConfig = new Curve0To90Config(45f);
[NotKeyable] public CurveVector3Config limitRotationConfig;
#endregion
#region == Collision ==
public CurveNoLimitConfig radiusConfig;
public PermissionConfig allowCollisionConfig;
public CollidersConfig collidersConfig;
[NotKeyable] public CurveNoLimitConfig radiusConfig;
[NotKeyable] public PermissionConfig allowCollisionConfig;
[NotKeyable] public CollidersConfig collidersConfig;
#endregion
#region == Stretch & Squish ==
public Curve0To1Config stretchMotionConfig;
public CurveNoLimitConfig maxStretchConfig;
public Curve0To1Config maxSquishConfig;
[NotKeyable] public Curve0To1Config stretchMotionConfig;
[NotKeyable] public CurveNoLimitConfig maxStretchConfig;
[NotKeyable] public Curve0To1Config maxSquishConfig;
#endregion
#region == Grab & Pose ==
public PermissionConfig allowGrabbingConfig;
public PermissionConfig allowPosingConfig;
public Float0To1Config grabMovementConfig;
public BoolConfig snapToHandConfig;
[NotKeyable] public PermissionConfig allowGrabbingConfig;
[NotKeyable] public PermissionConfig allowPosingConfig;
[NotKeyable] public Float0To1Config grabMovementConfig;
[NotKeyable] public BoolConfig snapToHandConfig;
#endregion
#region == Options ==
public ParameterConfig parameterConfig;
public IsAnimatedConfig isAnimatedConfig;
public BoolConfig resetWhenDisabledConfig;
[NotKeyable] public ParameterConfig parameterConfig;
[NotKeyable] public IsAnimatedConfig isAnimatedConfig;
[NotKeyable] public BoolConfig resetWhenDisabledConfig;
#endregion

[Serializable]
Expand Down
3 changes: 2 additions & 1 deletion Runtime/MergeSkinnedMesh.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Anatawa12.AvatarOptimizer.ErrorReporting;
using CustomLocalization4EditorExtension;
using UnityEngine;
using UnityEngine.Animations;

namespace Anatawa12.AvatarOptimizer
{
Expand All @@ -17,7 +18,7 @@ internal class MergeSkinnedMesh : EditSkinnedMeshComponent, IStaticValidated
public PrefabSafeSet.MaterialSet doNotMergeMaterials;

// common between v0 and v1
[CL4EELocalized("MergeSkinnedMesh:prop:removeEmptyRendererObject")]
[NotKeyable, CL4EELocalized("MergeSkinnedMesh:prop:removeEmptyRendererObject")]
[ToggleLeft]
public bool removeEmptyRendererObject = true;

Expand Down
1 change: 1 addition & 0 deletions Runtime/MergeToonLitMaterial.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using UnityEngine;
using UnityEngine.Animations;

namespace Anatawa12.AvatarOptimizer
{
Expand Down
7 changes: 7 additions & 0 deletions Runtime/TraceAndOptimize.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using CustomLocalization4EditorExtension;
using UnityEngine;
using UnityEngine.Animations;

namespace Anatawa12.AvatarOptimizer
{
Expand All @@ -10,31 +11,37 @@ namespace Anatawa12.AvatarOptimizer
[HelpURL("https://vpm.anatawa12.com/avatar-optimizer/ja/docs/reference/trace-and-optimize/")]
internal class TraceAndOptimize : AvatarGlobalComponent
{
[NotKeyable]
[CL4EELocalized("TraceAndOptimize:prop:freezeBlendShape")]
[ToggleLeft]
public bool freezeBlendShape = true;
[NotKeyable]
[CL4EELocalized("TraceAndOptimize:prop:removeUnusedObjects")]
[ToggleLeft]
public bool removeUnusedObjects = true;

// Remove Unused Objects Options
[NotKeyable]
[CL4EELocalized("TraceAndOptimize:prop:preserveEndBone",
"TraceAndOptimize:tooltip:preserveEndBone")]
[ToggleLeft]
public bool preserveEndBone;

// common parsing configuration
[NotKeyable]
[CL4EELocalized("TraceAndOptimize:prop:mmdWorldCompatibility",
"TraceAndOptimize:tooltip:mmdWorldCompatibility")]
[ToggleLeft]
public bool mmdWorldCompatibility = true;

// for compatibility, this is not inside AdvancedSettings but this is part of Advanced Settings
[NotKeyable]
[InspectorName("Use Advanced Animator Parser")]
[Tooltip("Advanced Animator Parser will parse your AnimatorController, including layer structure.")]
[ToggleLeft]
public bool advancedAnimatorParser = true;

[NotKeyable]
public AdvancedSettings advancedSettings;

[Serializable]
Expand Down
3 changes: 3 additions & 0 deletions Runtime/UnusedBonesByReferencesTool.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using CustomLocalization4EditorExtension;
using UnityEngine;
using UnityEngine.Animations;

namespace Anatawa12.AvatarOptimizer
{
Expand All @@ -10,11 +11,13 @@ namespace Anatawa12.AvatarOptimizer
[Obsolete("Obsoleted by Trace and Optimize")]
internal class UnusedBonesByReferencesTool : AvatarGlobalComponent
{
[NotKeyable]
[CL4EELocalized("UnusedBonesByReferencesTool:prop:preserveEndBone",
"UnusedBonesByReferencesTool:tooltip:preserveEndBone")]
[ToggleLeft]
public bool preserveEndBone = true;

[NotKeyable]
[CL4EELocalized("UnusedBonesByReferencesTool:prop:detectExtraChild",
"UnusedBonesByReferencesTool:tooltip:detectExtraChild")]
[ToggleLeft]
Expand Down
15 changes: 15 additions & 0 deletions Test~/ComponentSettingsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
using System.Reflection;
using Anatawa12.ApplyOnPlay;
using NUnit.Framework;
using UnityEditor;
using UnityEngine;
using UnityEngine.Animations;

namespace Anatawa12.AvatarOptimizer.Test
{
Expand Down Expand Up @@ -40,6 +42,19 @@ public void CheckDisallowMultipleComponentIsSpecified(Type type)
Assert.That(addComponentMenu, Is.Not.Null);
}

[Test]
[TestCaseSource(nameof(ComponentTypes))]
public void CheckNotKeyable(Type type)
{
var gameObject = new GameObject();
gameObject.AddComponent(type);
var bindings = AnimationUtility.GetAnimatableBindings(gameObject, gameObject)
.Where(x => x.type == type)
.Where(x => x.propertyName != "m_Enabled")
.ToArray();
Assert.That(bindings, Is.Empty);
}

static IEnumerable<Type> ComponentTypes()
{
return
Expand Down