mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-04-05 12:09:01 +08:00
46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using nadena.dev.modular_avatar.editor.ErrorReporting;
|
|
using nadena.dev.ndmf;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
#if VRC_SDK_VRCSDK3
|
|
using VRC.Dynamics;
|
|
using VRC.SDK3.Dynamics.Constraint.Components;
|
|
|
|
#else
|
|
using UnityEngine.Animations;
|
|
#endif
|
|
|
|
namespace nadena.dev.modular_avatar.core.editor
|
|
{
|
|
internal class WorldScaleObjectPass : Pass<WorldScaleObjectPass>
|
|
{
|
|
protected override void Execute(ndmf.BuildContext context)
|
|
{
|
|
var fixedPrefab =
|
|
AssetDatabase.LoadAssetAtPath<GameObject>(
|
|
"Packages/nadena.dev.modular-avatar/Assets/FixedPrefab.prefab"
|
|
);
|
|
var targets = context.AvatarRootTransform.GetComponentsInChildren<ModularAvatarWorldScaleObject>(true);
|
|
|
|
foreach (var target in targets)
|
|
{
|
|
BuildReport.ReportingObject(target, () =>
|
|
{
|
|
#if MA_VRCSDK3_AVATARS
|
|
var c = target.gameObject.AddComponent<VRCScaleConstraint>();
|
|
c.Sources.Add(new VRCConstraintSource(fixedPrefab.transform, 1));
|
|
c.Locked = true;
|
|
c.IsActive = true;
|
|
#else
|
|
var c = target.gameObject.AddComponent<ScaleConstraint>();
|
|
c.AddSource(new ConstraintSource() {sourceTransform = fixedPrefab.transform, weight = 1});
|
|
c.locked = true;
|
|
c.constraintActive = true;
|
|
#endif
|
|
|
|
Object.DestroyImmediate(target);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
} |