public static void SetBonesToDescription(BoneMapping mapping, AvatarDescription description) { var map = mapping.Bones .Select((x, i) => new { i, x }) .Where(x => x.x != null) .ToDictionary(x => (HumanBodyBones)x.i, x => x.x.transform) ; description.SetHumanBones(map); }
/// <summary> /// /// </summary> /// <returns></returns> public Avatar CreateAvatar() { var map = Bones .Select((x, i) => new { i, x }) .Where(x => x.x != null) .ToDictionary(x => (HumanBodyBones)x.i, x => x.x.transform) ; if (Description == null) { Description = AvatarDescription.Create(); } Description.SetHumanBones(map); Description.name = name + ".description"; var avatar = Description.CreateAvatar(transform); avatar.name = name; var animator = GetComponent <Animator>(); if (animator != null) { var positionMap = transform.Traverse().ToDictionary(x => x, x => x.position); animator.avatar = avatar; foreach (var x in transform.Traverse()) { x.position = positionMap[x]; } } var transfer = GetComponent <HumanPoseTransfer>(); if (transfer != null) { transfer.Avatar = avatar; } return(avatar); }