mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-29 18:55:06 +08:00
fix: name collisions with Bone Proxies break animation mappings (#542)
Closes: #540
This commit is contained in:
parent
7b309f391b
commit
1dacdc4b37
@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using nadena.dev.modular_avatar.editor.ErrorReporting;
|
using nadena.dev.modular_avatar.editor.ErrorReporting;
|
||||||
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace nadena.dev.modular_avatar.core.editor
|
namespace nadena.dev.modular_avatar.core.editor
|
||||||
@ -50,7 +51,15 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
{
|
{
|
||||||
if (proxy.target != null && ValidateTarget(avatarGameObject, proxy.target) == ValidationResult.OK)
|
if (proxy.target != null && ValidateTarget(avatarGameObject, proxy.target) == ValidationResult.OK)
|
||||||
{
|
{
|
||||||
var oldPath = RuntimeUtil.AvatarRootPath(proxy.gameObject);
|
string suffix = "";
|
||||||
|
int i = 1;
|
||||||
|
while (proxy.target.Find(proxy.gameObject.name + suffix) != null)
|
||||||
|
{
|
||||||
|
suffix = $" ({i++})";
|
||||||
|
}
|
||||||
|
|
||||||
|
proxy.gameObject.name += suffix;
|
||||||
|
|
||||||
Transform transform = proxy.transform;
|
Transform transform = proxy.transform;
|
||||||
transform.SetParent(proxy.target, true);
|
transform.SetParent(proxy.target, true);
|
||||||
|
|
||||||
|
@ -41,6 +41,30 @@ namespace modular_avatar_tests
|
|||||||
Assert.IsNull(boneProxy.target);
|
Assert.IsNull(boneProxy.target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNameCollision()
|
||||||
|
{
|
||||||
|
var root = CreateRoot("root");
|
||||||
|
var target = CreateChild(root, "target");
|
||||||
|
var src1 = CreateChild(root, "src1");
|
||||||
|
var src_child1 = CreateChild(src1, "child");
|
||||||
|
var src2 = CreateChild(root, "src2");
|
||||||
|
var src_child2 = CreateChild(src2, "child");
|
||||||
|
|
||||||
|
var bp1 = src_child1.AddComponent<ModularAvatarBoneProxy>();
|
||||||
|
bp1.target = target.transform;
|
||||||
|
|
||||||
|
var bp2 = src_child2.AddComponent<ModularAvatarBoneProxy>();
|
||||||
|
bp2.target = target.transform;
|
||||||
|
|
||||||
|
bp1.ClearCache(true);
|
||||||
|
bp2.ClearCache(true);
|
||||||
|
|
||||||
|
new BoneProxyProcessor().OnPreprocessAvatar(root);
|
||||||
|
|
||||||
|
Assert.AreNotEqual(src_child1.name, src_child2.name);
|
||||||
|
}
|
||||||
|
|
||||||
private void AssertAttachmentMode(BoneProxyAttachmentMode attachmentMode, bool expectSnapPos,
|
private void AssertAttachmentMode(BoneProxyAttachmentMode attachmentMode, bool expectSnapPos,
|
||||||
bool expectSnapRot)
|
bool expectSnapRot)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user