From 9318efc8a6b3c160e9b472ad3d6a21b392fa14c9 Mon Sep 17 00:00:00 2001 From: bd_ Date: Wed, 23 Aug 2023 19:49:54 +0900 Subject: [PATCH] fixing bugs with plugin integration --- Assets/_ModularAvatar/EditModeTests/BoneProxyTest.cs | 6 +++--- .../MergeArmatureTests/MultiLevelMergeTest.cs | 3 +++ .../SerializationTests/SerializationTests.cs | 3 ++- Assets/_ModularAvatar/EditModeTests/Tests.asmdef | 3 ++- .../Runtime/ModularAvatarBoneProxy.cs | 10 +++++++++- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Assets/_ModularAvatar/EditModeTests/BoneProxyTest.cs b/Assets/_ModularAvatar/EditModeTests/BoneProxyTest.cs index 02c318142..cdc1c8767 100644 --- a/Assets/_ModularAvatar/EditModeTests/BoneProxyTest.cs +++ b/Assets/_ModularAvatar/EditModeTests/BoneProxyTest.cs @@ -30,15 +30,15 @@ public void TestNonHumanoidTarget() var boneProxy = reference.AddComponent(); boneProxy.target = root.transform; - boneProxy.ClearCache(); + boneProxy.ClearCache(true); Assert.AreEqual(root.transform, boneProxy.target); boneProxy.target = target.transform; - boneProxy.ClearCache(); + boneProxy.ClearCache(true); Assert.AreEqual(target.transform, boneProxy.target); target.name = "target2"; - boneProxy.ClearCache(); + boneProxy.ClearCache(true); Assert.IsNull(boneProxy.target); } diff --git a/Assets/_ModularAvatar/EditModeTests/MergeArmatureTests/MultiLevelMergeTest.cs b/Assets/_ModularAvatar/EditModeTests/MergeArmatureTests/MultiLevelMergeTest.cs index f08eed7bb..4338c6d84 100644 --- a/Assets/_ModularAvatar/EditModeTests/MergeArmatureTests/MultiLevelMergeTest.cs +++ b/Assets/_ModularAvatar/EditModeTests/MergeArmatureTests/MultiLevelMergeTest.cs @@ -56,6 +56,7 @@ public void mergeProcessesInTopoOrder() nadena.dev.build_framework.BuildContext context = new nadena.dev.build_framework.BuildContext(root.GetComponent(), null); + context.ActivateExtensionContext(); context.ActivateExtensionContext(typeof(TrackObjectRenamesContext)); new MergeArmatureHook().OnPreprocessAvatar(context, root); @@ -83,6 +84,7 @@ public void canDisableNameMangling() nadena.dev.build_framework.BuildContext context = new nadena.dev.build_framework.BuildContext(root.GetComponent(), null); + context.ActivateExtensionContext(); context.ActivateExtensionContext(typeof(TrackObjectRenamesContext)); new MergeArmatureHook().OnPreprocessAvatar(context, root); @@ -106,6 +108,7 @@ public void manglesByDefault() nadena.dev.build_framework.BuildContext context = new nadena.dev.build_framework.BuildContext(root.GetComponent(), null); + context.ActivateExtensionContext(); context.ActivateExtensionContext(typeof(TrackObjectRenamesContext)); new MergeArmatureHook().OnPreprocessAvatar(context, root); diff --git a/Assets/_ModularAvatar/EditModeTests/SerializationTests/SerializationTests.cs b/Assets/_ModularAvatar/EditModeTests/SerializationTests/SerializationTests.cs index 1948d449c..ce826b452 100644 --- a/Assets/_ModularAvatar/EditModeTests/SerializationTests/SerializationTests.cs +++ b/Assets/_ModularAvatar/EditModeTests/SerializationTests/SerializationTests.cs @@ -1,5 +1,6 @@ using System.Linq; using modular_avatar_tests; +using nadena.dev.build_framework.runtime; using nadena.dev.modular_avatar.core; using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; @@ -60,7 +61,7 @@ void AssertTempAsset(UnityEngine.Object obj) Assert.False(string.IsNullOrEmpty(path)); var mainAsset = AssetDatabase.LoadMainAssetAtPath(path); - Assert.IsInstanceOf(mainAsset); + Assert.IsInstanceOf(mainAsset); } } } \ No newline at end of file diff --git a/Assets/_ModularAvatar/EditModeTests/Tests.asmdef b/Assets/_ModularAvatar/EditModeTests/Tests.asmdef index f69971159..e5cd2b6ee 100644 --- a/Assets/_ModularAvatar/EditModeTests/Tests.asmdef +++ b/Assets/_ModularAvatar/EditModeTests/Tests.asmdef @@ -9,7 +9,8 @@ "GUID:b906909fcc54f634db50f2cad0f988d9", "GUID:3456780c4fb2d324ab9c633d6f1b0ddb", "GUID:e9745f6a32442194c8dc5a43e9ab86f9", - "GUID:62ced99b048af7f4d8dfe4bed8373d76" + "GUID:62ced99b048af7f4d8dfe4bed8373d76", + "GUID:fe747755f7b44e048820525b07f9b956" ], "includePlatforms": [ "Editor" diff --git a/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarBoneProxy.cs b/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarBoneProxy.cs index b8e0b014c..93686d9b9 100644 --- a/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarBoneProxy.cs +++ b/Packages/nadena.dev.modular-avatar/Runtime/ModularAvatarBoneProxy.cs @@ -108,7 +108,15 @@ protected override void OnValidate() internal void ClearCache() { - if (_targetCache != null) + ClearCache(false); + } + + internal void ClearCache(bool immediate) + { + if (immediate) + { + _targetCache = null; + } else if (_targetCache != null) { RuntimeUtil.delayCall(() => { _targetCache = null; }); }