fix: changed not to use Instantiate when creating inverse root bone (#1376)

Co-authored-by: Rerigferl <70315656+AshleyScarlet@users.noreply.github.com>
This commit is contained in:
Rinna Koharu 2024-12-02 00:10:48 +09:00 committed by GitHub
parent d538551fad
commit f35283db51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
@ -187,16 +188,17 @@ namespace nadena.dev.modular_avatar.core.editor
{
if (invertedRootBoneCache.TryGetValue(rootBone, out var cache)) { return cache; }
var cloned = Object.Instantiate(rootBone.gameObject, rootBone, true);
cloned.name = rootBone.gameObject.name + "-InvertedRootBone";
var invertedRootBone = new GameObject($"{rootBone.gameObject.name}-InvertedRootBone");
EditorUtility.CopySerialized(rootBone, invertedRootBone.transform);
invertedRootBone.transform.parent = rootBone;
var invertedRootBone = cloned.transform;
var scale = invertedRootBone.localScale;
var transform = invertedRootBone.transform;
var scale = transform.localScale;
scale.x *= -1;
invertedRootBone.localScale = scale;
transform.localScale = scale;
invertedRootBoneCache[rootBone] = invertedRootBone;
return invertedRootBone;
invertedRootBoneCache[rootBone] = transform;
return transform;
}
}
}