private static void CopyDaeTextureToExportDestination(string prefabPath, string newFolderLocation) { //Get material from Collada prefab Material material = RuntimeUrdf.AssetDatabase_LoadAssetAtPath <Material>(prefabPath); if (material == null || material.mainTexture == null) { return; } //Get relative subfolder where texture is, compared to the DAE file. string commonFolder = Path.GetDirectoryName(prefabPath).SetSeparatorChar(); string texturePath = RuntimeUrdf.AssetDatabase_GetAssetPath(material.mainTexture).SetSeparatorChar(); string relativeLocation = ""; if (texturePath.Contains(commonFolder)) { relativeLocation = texturePath.Substring(commonFolder.Length + 1); } string newTexturePath = Path.Combine(newFolderLocation, relativeLocation); Directory.CreateDirectory(Path.GetDirectoryName(newTexturePath)); CopyFileToNewLocation(UrdfAssetPathHandler.GetFullAssetPath(texturePath), newTexturePath); }
private static Link.Visual.Material.Texture ExportTextureData(Texture texture) { string oldTexturePath = UrdfAssetPathHandler.GetFullAssetPath(RuntimeUrdf.AssetDatabase_GetAssetPath(texture)); string newTexturePath = UrdfExportPathHandler.GetNewResourcePath(Path.GetFileName(oldTexturePath)); if (oldTexturePath != newTexturePath) { File.Copy(oldTexturePath, newTexturePath, true); } string packagePath = UrdfExportPathHandler.GetPackagePathForResource(newTexturePath); return(new Link.Visual.Material.Texture(packagePath)); }
private static string GetPrefabPath(GameObject gameObject) { return(RuntimeUrdf.AssetDatabase_GetAssetPath(RuntimeUrdf.PrefabUtility_GetCorrespondingObjectFromSource(gameObject))); }
public void AssetDatabase_GetAssetPath_AssetAsRoot() { RuntimeUrdf.runtimeModeEnabled = false; Assert.AreEqual($"{createAssetPath}/TestAsset.prefab", RuntimeUrdf.AssetDatabase_GetAssetPath(testObject)); }