コード例 #1
0
        public VRMSpringBone ToSpringBone(GameObject gameObject)
        {
            var targetObject = HierarchyPath.ToGameObject(AttachedTo, gameObject);
            var attachedBone = targetObject.AddComponent <VRMSpringBone>();

            // Copy values
            attachedBone.m_comment        = m_comment;
            attachedBone.m_stiffnessForce = m_stiffnessForce;
            attachedBone.m_gravityPower   = m_gravityPower;
            attachedBone.m_gravityDir     = m_gravityDir;
            attachedBone.m_dragForce      = m_dragForce;
            attachedBone.m_center         = HierarchyPath.ToTransform(m_center);
            attachedBone.RootBones        = HierarchyPath.ToTransforms(RootBones, gameObject);
            attachedBone.m_hitRadius      = m_hitRadius;
            attachedBone.ColliderGroups   = new VRMSpringBoneColliderGroup[ColliderGroups.Count];
            for (var i = 0; i < ColliderGroups.Count; i++)
            {
                var cgAttachedObject = HierarchyPath.ToGameObject(ColliderGroups[i], gameObject);
                if (cgAttachedObject != null)
                {
                    attachedBone.ColliderGroups[i] = cgAttachedObject.GetComponent <VRMSpringBoneColliderGroup>();
                }
            }
            return(attachedBone);
        }
コード例 #2
0
        public DynamicBone ToDynamicBone(GameObject gameObject)
        {
            var targetObject = HierarchyPath.ToGameObject(AttachedTo, gameObject);
            var attachedBone = targetObject.AddComponent <DynamicBone>();

            // Copy values
            attachedBone.m_Root              = HierarchyPath.ToTransform(m_Root, gameObject);
            attachedBone.m_UpdateRate        = m_UpdateRate;
            attachedBone.m_UpdateMode        = m_UpdateMode;
            attachedBone.m_Damping           = m_Damping;
            attachedBone.m_DampingDistrib    = m_DampingDistrib;
            attachedBone.m_Elasticity        = m_Elasticity;
            attachedBone.m_ElasticityDistrib = m_ElasticityDistrib;
            attachedBone.m_Stiffness         = m_Stiffness;
            attachedBone.m_StiffnessDistrib  = m_StiffnessDistrib;
            attachedBone.m_Inert             = m_Inert;
            attachedBone.m_InertDistrib      = m_InertDistrib;
            attachedBone.m_Radius            = m_Radius;
            attachedBone.m_RadiusDistrib     = m_RadiusDistrib;
            attachedBone.m_EndLength         = m_EndLength;
            attachedBone.m_EndOffset         = m_EndOffset;
            attachedBone.m_Gravity           = m_Gravity;
            attachedBone.m_Force             = m_Force;
            attachedBone.m_Colliders         = new List <DynamicBoneColliderBase>();
            foreach (var colliderAttachedObject in HierarchyPath.ToGameObjects(m_Colliders, gameObject))
            {
                var colliders = colliderAttachedObject.GetComponents <DynamicBoneCollider>();
                if (colliders != null)
                {
                    foreach (var collider in colliders)
                    {
                        attachedBone.m_Colliders.Add(collider);
                    }
                }
            }
            attachedBone.m_Exclusions       = HierarchyPath.ToTransforms(m_Exclusions, gameObject);
            attachedBone.m_FreezeAxis       = m_FreezeAxis;
            attachedBone.m_DistantDisable   = m_DistantDisable;
            attachedBone.m_ReferenceObject  = HierarchyPath.ToTransform(m_ReferenceObject, gameObject);
            attachedBone.m_DistanceToObject = m_DistanceToObject;

            return(attachedBone);
        }