MaikKlein / unreal-rust

Rust integration for Unreal Engine 5
Apache License 2.0
2.11k stars 78 forks source link

Add docs on how to integrate with new & existing UE project #14

Open tqwewe opened 2 years ago

tqwewe commented 2 years ago

It would be nice to have some documentation on how to use this with an existing UE project, or even a brand new project.

So far, for adding to an existing project, I've copied over the RustPlugin to my Plugins directory, and the .dll into Binaries, but I'm not sure where to write my Rust code, and place my Cargo.toml... and how to link that project with my game.

ameaninglessname commented 2 years ago

See the readme, thinking replacing the "example\RustExample" project with your project.

What it basically does (on windows) is :

  1. build the rust project into DLL (unreal_rust_example.dll here, using cargo build --release )
  2. Add "RustPlugin" to your project
  3. Copy the DLL to your project's Binaries folder and name it "rustplugin.dll" (hard-coded for now)
  4. Compile and run your project.
MaikKlein commented 2 years ago

So far, for adding to an existing project, I've copied over the RustPlugin to my Plugins directory,

Correct

and the .dll into Binaries, but I'm not sure where to write my Rust code, and place my Cargo.toml... and how to link that project with my game.

The dll is your game. If you want to write your own game, you can have a look at unreal-rust-example and maybe remove the things you don't want. If you compile that, it will produce a dll that you can copy into the Binaries folder.

Additionally you need to set the GameMode to ARustGameModeBase for your level.

I should provide a minimal example, but haven't had the time yet.