fix: changed not to use Instantiate when creating inverse root bone

This commit is contained in:
Rerigferl 2024-12-01 21:21:26 +09:00
parent d538551fad
commit ff04a3e4de
No known key found for this signature in database

View File

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