private void ImportLinkData(Link link, Joint joint) { if (link.inertial == null && joint == null) { isBaseLink = true; } gameObject.name = link.name; if (joint?.origin != null) { UrdfOrigin.ImportOriginData(transform, joint.origin); } if (link.inertial != null) { UrdfInertial.Create(gameObject, link.inertial); if (joint != null) { UrdfJoint.Create(gameObject, UrdfJoint.GetJointType(joint.type), joint); } } else if (joint != null) { Debug.LogWarning("No Joint Component will be created in GameObject \"" + gameObject.name + "\" as it has no Rigidbody Component.\n" + "Please define an Inertial for Link \"" + link.name + "\" in the URDF file to create a Rigidbody Component.\n", gameObject); } foreach (Joint childJoint in link.joints) { Link child = childJoint.ChildLink; UrdfLink.Create(transform, child, childJoint); } }
public static UrdfLink Create(Transform parent, Link link = null, Joint joint = null) { GameObject linkObject = new GameObject("link"); linkObject.transform.SetParentAndAlign(parent); UrdfLink urdfLink = linkObject.AddComponent <UrdfLink>(); UrdfVisuals.Create(linkObject.transform, link?.visuals); UrdfCollisions.Create(linkObject.transform, link?.collisions); if (link != null) { urdfLink.ImportLinkData(link, joint); } else { UrdfInertial.Create(linkObject); EditorGUIUtility.PingObject(linkObject); } return(urdfLink); }