ropensci / unifir

A unifying interface for calling Unity from R
https://docs.ropensci.org/unifir/
Other
29 stars 0 forks source link

Example create_terrain() call fails on action() #6

Closed wjones127 closed 2 years ago

wjones127 commented 2 years ago

I attempted to create a terrain with the example, but it reported there was an exception. Is there a way to see that exception?

library(unifir)

raster <- tempfile(fileext = ".tiff")
r <- terra::rast(matrix(rnorm(1000^2, mean = 100, sd = 20), 1000),
                 extent = terra::ext(0, 1000, 0, 1000)
)
terra::writeRaster(r, raster)

script <- make_script(project = "projects/example_script") |>
  add_light(light_type = "Directional", light_name = "Sun",
            x_rotation = 35, y_rotation = 20) |>
  add_default_player() |>
  create_terrain(
    method_name = "MakeTerrain",
    heightmap_path = raster,
    x_pos = 0,
    z_pos = 0,
    width = 1000,
    height = terra::minmax(r)[[2]],
    length = 1000,
    heightmap_resolution = 1000
  ) |>
  save_scene(scene_name = "my_scene") |>
  set_active_scene(scene_name = "my_scene")

action(script)
# Aborting batchmode due to failure:
# executeMethod method MakeTerrain.MainFunc threw exception.
#> Error in action(script): 1
mikemahoney218 commented 2 years ago

Thanks! Fixed in bfbb306 -- I had been testing with local files and mistakenly assumed that I could swap the local path for a tempfile (for CRAN) with no problems.

Unfortunately, that's actually the entire error message provided by Unity when called on the command line. There might be a space for a vignette on how to debug these scripts (which is a bit more about the Unity engine and C# than anything to do with R) but Unity's CLI is notoriously unfriendly, so I don't believe there's any way to surface these issues within R itself.

wjones127 commented 2 years ago

Can confirm that this example now works in that fix branch.

Unity's CLI is notoriously unfriendly, so I don't believe there's any way to surface these issues within R itself.

That's a shame 😢

github-actions[bot] commented 10 months ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.