mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-06 19:11:37 -05:00
remove unnecessary value of ControlRigGenerationOption
This commit is contained in:
@@ -5,9 +5,9 @@ namespace UniVRM10
|
||||
{
|
||||
/// <summary>
|
||||
/// VRM全体を制御するRoot
|
||||
///
|
||||
///
|
||||
/// Importer(scripted importer) -> Prefab(editor/asset) -> Instance(scene/MonoBehavior) -> Runtime(play時)
|
||||
///
|
||||
///
|
||||
/// * DefaultExecutionOrder(11000) means calculate springbone after FinalIK( VRIK )
|
||||
/// </summary>
|
||||
[AddComponentMenu("VRM10/VRMInstance")]
|
||||
@@ -54,6 +54,10 @@ namespace UniVRM10
|
||||
private Vrm10Runtime m_runtime;
|
||||
private ControlRigGenerationOption m_controlRigGenerationOption = ControlRigGenerationOption.None;
|
||||
|
||||
/// <summary>
|
||||
/// VRM ファイルに記録された Humanoid ボーンに対応します。
|
||||
/// これは、コントロールリグのボーンとは異なります。
|
||||
/// </summary>
|
||||
public UniHumanoid.Humanoid Humanoid
|
||||
{
|
||||
get
|
||||
|
||||
@@ -2,8 +2,15 @@
|
||||
{
|
||||
public enum ControlRigGenerationOption
|
||||
{
|
||||
/// <summary>
|
||||
/// コントロールリグを生成しません。
|
||||
/// </summary>
|
||||
None,
|
||||
Additive,
|
||||
Override,
|
||||
|
||||
/// <summary>
|
||||
/// 推奨されるオプションです。
|
||||
/// コントロールリグのボーン Transform を生成し、Root の Animator はコントロールリグのボーンを制御するようになります。
|
||||
/// </summary>
|
||||
Generate,
|
||||
}
|
||||
}
|
||||
@@ -35,30 +35,16 @@ namespace UniVRM10
|
||||
_controlRigRoot = new GameObject("Runtime Control Rig").transform;
|
||||
_controlRigRoot.SetParent(vrmRoot);
|
||||
|
||||
var avatarRoot = option switch
|
||||
{
|
||||
ControlRigGenerationOption.Additive => _controlRigRoot,
|
||||
ControlRigGenerationOption.Override => vrmRoot,
|
||||
ControlRigGenerationOption.None => null,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
|
||||
};
|
||||
|
||||
_hipBone = Vrm10ControlBone.Build(humanoid, out _bones);
|
||||
_hipBone.ControlBone.SetParent(_controlRigRoot);
|
||||
|
||||
InitialHipsHeight = _hipBone.ControlTarget.position.y;
|
||||
|
||||
var transformBonePairs = _bones.Select(kv => (kv.Value.ControlBone, kv.Key));
|
||||
_controlRigAvatar = HumanoidLoader.LoadHumanoidAvatar(avatarRoot, transformBonePairs);
|
||||
_controlRigAvatar = HumanoidLoader.LoadHumanoidAvatar(vrmRoot, transformBonePairs);
|
||||
_controlRigAvatar.name = "Runtime Control Rig";
|
||||
|
||||
ControlRigAnimator = option switch
|
||||
{
|
||||
ControlRigGenerationOption.Additive => _controlRigRoot.gameObject.AddComponent<Animator>(),
|
||||
ControlRigGenerationOption.Override => vrmRoot.GetComponent<Animator>(),
|
||||
ControlRigGenerationOption.None => null,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(option), option, null)
|
||||
};
|
||||
ControlRigAnimator = vrmRoot.GetComponent<Animator>();
|
||||
ControlRigAnimator.avatar = _controlRigAvatar;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace UniVRM10
|
||||
public static async Task<Vrm10Instance> LoadPathAsync(
|
||||
string path,
|
||||
bool canLoadVrm0X = true,
|
||||
ControlRigGenerationOption controlRigGenerationOption = ControlRigGenerationOption.Override,
|
||||
ControlRigGenerationOption controlRigGenerationOption = ControlRigGenerationOption.Generate,
|
||||
bool showMeshes = true,
|
||||
IAwaitCaller awaitCaller = null,
|
||||
IMaterialDescriptorGenerator materialGenerator = null,
|
||||
@@ -81,7 +81,7 @@ namespace UniVRM10
|
||||
public static async Task<Vrm10Instance> LoadBytesAsync(
|
||||
byte[] bytes,
|
||||
bool canLoadVrm0X = true,
|
||||
ControlRigGenerationOption controlRigGenerationOption = ControlRigGenerationOption.Override,
|
||||
ControlRigGenerationOption controlRigGenerationOption = ControlRigGenerationOption.Generate,
|
||||
bool showMeshes = true,
|
||||
IAwaitCaller awaitCaller = null,
|
||||
IMaterialDescriptorGenerator materialGenerator = null,
|
||||
|
||||
Reference in New Issue
Block a user