mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-28 10:15:06 +08:00
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:
parent
d538551fad
commit
f35283db51
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user