public void AssetDatabase_GUIDToAssetPath_AssetAsRoot() { RuntimeUrdf.runtimeModeEnabled = false; string createdGUID = RuntimeUrdf.AssetDatabase_CreateFolder(createAssetPath, "RuntimeUrdf"); Assert.AreEqual(createFolderPath, RuntimeUrdf.AssetDatabase_GUIDToAssetPath(AssetDatabase.AssetPathToGUID(createFolderPath))); }
public static bool AssetExists(string assetPath, bool ignoreCase = false) { #if UNITY_EDITOR string[] foldersToSearch = { Path.GetDirectoryName(assetPath) }; var assetName = Path.GetFileNameWithoutExtension(assetPath); foreach (var guid2 in AssetDatabase_FindAssets(assetName, foldersToSearch)) { var possiblePath = RuntimeUrdf.AssetDatabase_GUIDToAssetPath(guid2); if (string.Equals(possiblePath, assetPath, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal)) { return(true); } } #endif return(false); }
private static void ConvertCylinderToCollider(MeshFilter filter) { GameObject go = filter.gameObject; var collider = filter.sharedMesh; // Only create an asset if not runtime import if (!RuntimeUrdf.IsRuntimeMode()) { var packageRoot = UrdfAssetPathHandler.GetPackageRoot(); var filePath = RuntimeUrdf.AssetDatabase_GUIDToAssetPath(RuntimeUrdf.AssetDatabase_CreateFolder($"{packageRoot}", "meshes")); var name = $"{filePath}/Cylinder.asset"; Debug.Log($"Creating new cylinder file: {name}"); RuntimeUrdf.AssetDatabase_CreateAsset(collider, name, uniquePath: true); RuntimeUrdf.AssetDatabase_SaveAssets(); } MeshCollider current = go.AddComponent <MeshCollider>(); current.sharedMesh = collider; current.convex = true; Object.DestroyImmediate(go.GetComponent <MeshRenderer>()); Object.DestroyImmediate(filter); }
public static string CopyOrCreateMesh(GameObject geometryObject, bool isCollisionGeometry) { string prefabPath = GetPrefabPath(geometryObject); bool foundExistingColladaOrStl = false; if (prefabPath != null && prefabPath != "") { if (Path.GetExtension(prefabPath).ToLower() == ".dae") { foundExistingColladaOrStl = true; } else //Find STL file that corresponds to the prefab, if it already exists { string[] foldersToSearch = { Path.GetDirectoryName(prefabPath) }; string prefabName = Path.GetFileNameWithoutExtension(prefabPath); foreach (string guid2 in RuntimeUrdf.AssetDatabase_FindAssets(prefabName, foldersToSearch)) { string possiblePath = RuntimeUrdf.AssetDatabase_GUIDToAssetPath(guid2); if (possiblePath.ToLower().Contains(".stl")) { prefabPath = possiblePath; foundExistingColladaOrStl = true; break; } } } } if (foundExistingColladaOrStl) { return(CopyMeshToExportDestination(prefabPath)); } return(CreateNewStlFile(geometryObject, isCollisionGeometry)); }