Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Rust workflow improvements #1

Open
randomPoison opened this issue Feb 12, 2020 · 0 comments
Open

Rust workflow improvements #1

randomPoison opened this issue Feb 12, 2020 · 0 comments
Labels
client Changes that affect the client codebase workflow Pain points in the development workflow

Comments

@randomPoison
Copy link
Owner

The current workflow for modifying the Rust client code is extremely cumbersome:

  1. Close Unity.
  2. Make changes to the mahjong-shared crate.
  3. Run the build_shared script to build the DLL and update the C# bindings.
  4. Re-open Unity.

This process has to be repeated each time a change is made in the Rust client code. In particular, the following problems make this workflow painful:

  • Having to re-open Unity each time a change is made slows the iteration cycle down massively.
  • Having to manually invoke the build script is less of a major issue, but it makes the Rust workflow relatively slow as compared to the C# workflow.

Currently, reloading Unity every time is necessary because Unity will not unload an unmanaged library once it has been loaded. This means that once you run the game in the editor and the DLL has been loaded, Unity won't be able to load the updated version.

Currently the DLL is loaded automatically via the [DllImport] attribute, however we could potentially try loading the library ourselves. That would allow us to manually unload the library when not in play mode, making it possible to update the library without having to restart Unity. Other people have written about taking a similar approach, so it should be possible.

Once we can update the DLL without reloading Unity, it should be relatively simple to use something like cargo-watch to automatically rebuild the DLL and bindings as the user edits the Rust code. This can be started from an editor script in the Unity project, that way we automatically start watch the project when the editor opens.

@randomPoison randomPoison added enhancement workflow Pain points in the development workflow labels Feb 12, 2020
@randomPoison randomPoison added client Changes that affect the client codebase and removed enhancement labels May 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
client Changes that affect the client codebase workflow Pain points in the development workflow
Projects
None yet
Development

No branches or pull requests

1 participant