mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-29 02:35: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;
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user