Ejemplo n.º 1
0
        private void LoadHumanoid()
        {
            AvatarDescription      = GLTF.extensions.VRM.humanoid.ToDescription(Nodes);
            AvatarDescription.name = "AvatarDescription";
            HumanoidAvatar         = AvatarDescription.CreateAvatar(Root.transform);
            if (!HumanoidAvatar.isValid || !HumanoidAvatar.isHuman)
            {
                throw new Exception("fail to create avatar");
            }

            HumanoidAvatar.name = "VrmAvatar";

            var humanoid = Root.AddComponent <VRMHumanoidDescription>();

            humanoid.Avatar      = HumanoidAvatar;
            humanoid.Description = AvatarDescription;

            var animator = Root.GetComponent <Animator>();

            if (animator == null)
            {
                animator = Root.AddComponent <Animator>();
            }
            animator.avatar = HumanoidAvatar;
        }
Ejemplo n.º 2
0
        private void LoadHumanoid()
        {
            AvatarDescription      = VRM.humanoid.ToDescription(Nodes);
            AvatarDescription.name = "AvatarDescription";
            HumanoidAvatar         = AvatarDescription.CreateAvatar(Root.transform);
            if (!HumanoidAvatar.isValid || !HumanoidAvatar.isHuman)
            {
                throw new Exception("fail to create avatar");
            }

            HumanoidAvatar.name = "VrmAvatar";

            var humanoid = Root.AddComponent <VRMHumanoidDescription>();

            humanoid.Avatar      = HumanoidAvatar;
            humanoid.Description = AvatarDescription;

            var animator = Root.GetComponent <Animator>();

            if (animator == null)
            {
                animator = Root.AddComponent <Animator>();
            }
            animator.avatar = HumanoidAvatar;

            // default としてとりあえず設定する
            // https://docs.unity3d.com/ScriptReference/Renderer-probeAnchor.html
            var head = animator.GetBoneTransform(HumanBodyBones.Head);

            foreach (var smr in animator.GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                smr.probeAnchor = head;
            }
        }