From 409592f952b3e93a61b99b800623b6cef4bd6cbd Mon Sep 17 00:00:00 2001 From: bd_ Date: Wed, 2 Oct 2024 19:42:19 -0700 Subject: [PATCH] fix(rc): constant-off objects are not handled correctly (#1249) Closes: #1233 --- Editor/ReactiveObjects/AnimationGeneration/ReactionRule.cs | 4 +++- .../AnimationGeneration/ReactiveObjectAnalyzer.cs | 2 +- .../ShapeChanger/InitialStates/SCDefaultAnimation.prefab | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Editor/ReactiveObjects/AnimationGeneration/ReactionRule.cs b/Editor/ReactiveObjects/AnimationGeneration/ReactionRule.cs index 68ae3154..dcf040ea 100644 --- a/Editor/ReactiveObjects/AnimationGeneration/ReactionRule.cs +++ b/Editor/ReactiveObjects/AnimationGeneration/ReactionRule.cs @@ -35,7 +35,9 @@ namespace nadena.dev.modular_avatar.core.editor public bool Inverted; - public bool IsConstant => ControllingConditions.Count == 0 || ControllingConditions.All(c => c.IsConstant); + public bool IsConstant => ControllingConditions.Count == 0 + || ControllingConditions.All(c => c.IsConstant) + || ControllingConditions.Any(c => c.IsConstant && !c.InitiallyActive); public bool IsConstantOn => IsConstant && InitiallyActive; public override string ToString() diff --git a/Editor/ReactiveObjects/AnimationGeneration/ReactiveObjectAnalyzer.cs b/Editor/ReactiveObjects/AnimationGeneration/ReactiveObjectAnalyzer.cs index defcc3c1..745c5184 100644 --- a/Editor/ReactiveObjects/AnimationGeneration/ReactiveObjectAnalyzer.cs +++ b/Editor/ReactiveObjects/AnimationGeneration/ReactiveObjectAnalyzer.cs @@ -144,7 +144,7 @@ namespace nadena.dev.modular_avatar.core.editor HashSet toggledObjects = new(); if (asc == null) return; - + foreach (var targetProp in shapes.Keys) if (targetProp is { TargetObject: GameObject go, PropertyName: "m_IsActive" }) toggledObjects.Add(go); diff --git a/UnitTests~/ShapeChanger/InitialStates/SCDefaultAnimation.prefab b/UnitTests~/ShapeChanger/InitialStates/SCDefaultAnimation.prefab index 71de2608..6dbfb2b7 100644 --- a/UnitTests~/ShapeChanger/InitialStates/SCDefaultAnimation.prefab +++ b/UnitTests~/ShapeChanger/InitialStates/SCDefaultAnimation.prefab @@ -183,7 +183,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &569625391371299408 Transform: m_ObjectHideFlags: 0 @@ -250,6 +250,7 @@ MonoBehaviour: isSynced: 1 isSaved: 1 isDefault: 0 + automaticValue: 0 --- !u!114 &664065153831629983 MonoBehaviour: m_ObjectHideFlags: 0