mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-30 18:22:52 +08:00
fix: constant reactive objects are incorrectly animated to original scene state (#1017)
Closes: #1014
This commit is contained in:
parent
6f95800e41
commit
3f02a1127f
@ -41,8 +41,8 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
);
|
||||
|
||||
GenerateActiveSelfProxies(shapes);
|
||||
|
||||
ProcessInitialStates(initialStates);
|
||||
|
||||
ProcessInitialStates(initialStates, shapes);
|
||||
ProcessInitialAnimatorVariables(shapes);
|
||||
|
||||
foreach (var groups in shapes.Values)
|
||||
@ -81,7 +81,8 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessInitialStates(Dictionary<TargetProp, object> initialStates)
|
||||
private void ProcessInitialStates(Dictionary<TargetProp, object> initialStates,
|
||||
Dictionary<TargetProp, AnimatedProperty> shapes)
|
||||
{
|
||||
var asc = context.Extension<AnimationServicesContext>();
|
||||
|
||||
@ -161,6 +162,10 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
}
|
||||
}
|
||||
|
||||
if (!shapes.ContainsKey(key))
|
||||
// Do not generate any animation base state if the property is set to a constant value,
|
||||
// because we won't generate any override layers.
|
||||
continue;
|
||||
|
||||
if (animBaseState is float f)
|
||||
{
|
||||
@ -476,7 +481,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
var clip = new AnimationClip();
|
||||
clip.name = $"Set {path}:{key.PropertyName}={value}";
|
||||
|
||||
if (value is UnityEngine.Object obj)
|
||||
if (value is Object obj)
|
||||
{
|
||||
var binding = EditorCurveBinding.PPtrCurve(path, componentType, key.PropertyName);
|
||||
AnimationUtility.SetObjectReferenceCurve(clip, binding, new []
|
||||
|
@ -52,8 +52,8 @@ namespace ShapeChangerTests
|
||||
typeof(SkinnedMeshRenderer),
|
||||
"blendShape.key3"
|
||||
));
|
||||
Assert.AreEqual(6.0f, curve.keys[0].value, 0.1f);
|
||||
Assert.AreEqual(6.0f, curve.keys[1].value, 0.1f);
|
||||
// Always-on set, no curve should be generated
|
||||
Assert.IsNull(curve);
|
||||
|
||||
// Check actual blendshape states
|
||||
Assert.AreEqual(10.0f, smr.GetBlendShapeWeight(sharedMesh.GetBlendShapeIndex("key1")), 0.1f);
|
||||
|
@ -44,8 +44,10 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 2db441f589c3407bb6fb5f02ff8ab541, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_inverted: 0
|
||||
m_targetRenderer:
|
||||
referencePath: test mesh
|
||||
targetObject: {fileID: 0}
|
||||
m_shapes:
|
||||
- ShapeName: key2
|
||||
ChangeType: 0
|
||||
@ -94,8 +96,10 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 2db441f589c3407bb6fb5f02ff8ab541, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_inverted: 0
|
||||
m_targetRenderer:
|
||||
referencePath: test mesh
|
||||
targetObject: {fileID: 0}
|
||||
m_shapes:
|
||||
- ShapeName: key1
|
||||
ChangeType: 1
|
||||
@ -144,8 +148,10 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 2db441f589c3407bb6fb5f02ff8ab541, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_inverted: 0
|
||||
m_targetRenderer:
|
||||
referencePath: test mesh
|
||||
targetObject: {fileID: 0}
|
||||
m_shapes:
|
||||
- ShapeName: key3
|
||||
ChangeType: 1
|
||||
@ -160,6 +166,8 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 569625391371299408}
|
||||
- component: {fileID: 3841502665919975468}
|
||||
- component: {fileID: 2918390808850211981}
|
||||
- component: {fileID: 664065153831629983}
|
||||
m_Layer: 0
|
||||
m_Name: InitialOffToggled
|
||||
m_TagString: Untagged
|
||||
@ -194,12 +202,56 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 2db441f589c3407bb6fb5f02ff8ab541, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_inverted: 0
|
||||
m_targetRenderer:
|
||||
referencePath: test mesh
|
||||
targetObject: {fileID: 0}
|
||||
m_shapes:
|
||||
- ShapeName: key1
|
||||
ChangeType: 1
|
||||
Value: 20
|
||||
--- !u!114 &2918390808850211981
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6385483934583485188}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3b29d45007c5493d926d2cd45a489529, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Control:
|
||||
name:
|
||||
icon: {fileID: 0}
|
||||
type: 102
|
||||
parameter:
|
||||
name:
|
||||
value: 1
|
||||
style: 0
|
||||
subMenu: {fileID: 0}
|
||||
subParameters: []
|
||||
labels: []
|
||||
MenuSource: 1
|
||||
menuSource_otherObjectChildren: {fileID: 0}
|
||||
isSynced: 1
|
||||
isSaved: 1
|
||||
isDefault: 0
|
||||
--- !u!114 &664065153831629983
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6385483934583485188}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7ef83cb0c23d4d7c9d41021e544a1978, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
menuToAppend: {fileID: 0}
|
||||
installTargetMenu: {fileID: 0}
|
||||
--- !u!1 &6855505756433160176
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
Loading…
Reference in New Issue
Block a user