/// <summary> /// Called upon event ColladaImporter.Instance.OnModelImported, when DAE file is imported. /// </summary> /// <param name="sender"></param> /// <param name="args">Contains imported GameObject.</param> private void OnColladaModelImported(object sender, ImportedColladaEventArgs args) { Debug.Log("URDF: Collada model imported"); Transform importedModel = args.Data.transform; UrdfRobot[] urdfRobots = importedModel.GetComponentsInParent <UrdfRobot>(true); if (urdfRobots != null) { UrdfRobot urdfRobot = urdfRobots[0]; // TODO: make sure that this robotModel check really works // check if imported model corresponds to this robot RobotModel robotModel = GetRobotModel(urdfRobot.gameObject); if (robotModel != null) { // get rid of the placeholder object (New Game Object) Transform placeholderGameObject = importedModel.parent; importedModel.SetParent(placeholderGameObject.parent, worldPositionStays: false); //TODO: Temporarily, colliders are added directly to Visuals AddColliders(importedModel.gameObject, setConvex: true); Destroy(placeholderGameObject.gameObject); robotModel.SetLinkVisualLoaded(importedModel.parent.parent.parent.name, importedModel.parent.gameObject.GetComponent <UrdfVisual>()); Debug.Log("URDF: dae model of the link: " + importedModel.parent.parent.parent.name + " imported"); } } }
private void OnColladaModelImported(object sender, ImportedColladaEventArgs args) { Transform importedModel = args.Data.transform; Base.RobotActionObject robot = importedModel.GetComponentInParent <Base.RobotActionObject>(); if (robot != null) { // check if imported model corresponds to this robot if (ReferenceEquals(robot, this)) { // get rid of the placeholder object (New Game Object) Transform placeholderGameObject = importedModel.parent; importedModel.SetParent(placeholderGameObject.parent, worldPositionStays: false); //TODO: Temporarily, colliders are added directly to Visuals AddColliders(importedModel.gameObject, setConvex: true); Destroy(placeholderGameObject.gameObject); SetLinkVisualLoaded(importedModel.parent.parent.parent.name, importedModel.parent.gameObject.GetComponent <UrdfVisual>()); Debug.Log("URDF: dae model of the link: " + importedModel.parent.parent.parent.name + " imported"); } } }