public static GameObject CreateCollider(this Link.Geometry.Mesh mesh, GameObject parent) { GameObject prefabObject = LocateAssetHandler.FindUrdfAsset <GameObject>(mesh.filename); if (prefabObject == null) { return(null); } GameObject meshObject = Object.Instantiate(prefabObject); MeshFilter[] meshFilters = meshObject.GetComponentsInChildren <MeshFilter>(); foreach (MeshFilter meshFilter in meshFilters) { GameObject child = meshFilter.gameObject; MeshCollider meshCollider = child.AddComponent <MeshCollider>(); meshCollider.sharedMesh = meshFilter.sharedMesh; Object.DestroyImmediate(child.GetComponent <MeshRenderer>()); Object.DestroyImmediate(meshFilter); } mesh.setScale(meshObject); meshObject.transform.SetParentAndAlign(parent.transform); return(meshObject); }
private static Texture LoadTexture(string filename) { string path = Path.Combine(assetPath, filename).Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); if (path == null) { return(null); } return(LocateAssetHandler.FindUrdfAsset <Texture>(path)); }
public static GameObject CreateVisual(this Link.Geometry.Mesh mesh, GameObject parent) { GameObject meshObject = LocateAssetHandler.FindUrdfAsset <GameObject>(mesh.filename); if (meshObject != null) { GameObject gameObject = Object.Instantiate(meshObject); mesh.setScale(gameObject); gameObject.transform.SetParentAndAlign(parent.transform); return(gameObject); } return(null); }
private static Texture LoadTexture(string filename) { return(filename == "" ? null : LocateAssetHandler.FindUrdfAsset <Texture>(filename)); }