7 releases
0.1.6 | Aug 27, 2023 |
---|---|
0.1.5 | Aug 27, 2023 |
#1124 in Game dev
45KB
1K
SLoC
Unrust - Rust + Bevy + Unity to make games!
You want to use Rust + Bevy to make your games. But you miss a good editor to go with it?
Well this is a zero level attempt to use Unity as the editor. You setup your scenes and prefabs using unity.
And then everything else is done in your rust codebase. GG EZ.
(only works on Unity 2022, LINUX . windows and mac soon)
Also requires entities + entities graphics packages. Maps unity entities to bevy entities. Does not work with gameobjects yet.
This is VERY VERY VERY experimental. There's a ton of work to add more component syncronization and improved devx.
I'll be adding docs soon, but if you do not mind wading into some undocumented rust + c# code, you're welcome to contribute!
Documentation
TODO!
Installation
Download the tarball from releases on the left, and it to a unity project.
It would/should create a game
folder besides the Asset folder with a basic project.
Hit unrust -> Compile in the unity project menu, and press play.
Requires rust nightly (to properly place the output library path and for codegen)
Usage/Examples
Defining a new struct with unity_authoring
attribute in the types.rs
file would also generate a corresponding Authoring component in the unity Assets/unrust folder. You can then attach this to an entity to have it be created in the bevy world too on play.
#[unity_authoring]
pub struct SampleComponent {
pub val: f32,
}
using System.Runtime.InteropServices;
using Unity.Entities;
using UnityEngine;
namespace unrust.userland
{
[StructLayout(LayoutKind.Sequential)]
public struct SampleComponent : IComponentData
{
public float speed;
}
public class SampleComponentAuthoring : MonoBehaviour
{
public float speed;
class Baker : Baker<SampleComponentAuthoring>
{
public override void Bake(SampleComponentAuthoring authoring)
{
var entity = GetEntity(TransformUsageFlags.Dynamic);
AddComponent(entity, new SampleComponent
{
speed = authoring.speed,
});
}
}
}
}
TODOS
-
Additional platform support
-
Add more built-in types. (Only transform and parents are synced right now)
-
Handle inputs
-
Handle camera / other non-ecs gameobjects.
-
Wasm?!
License
Dependencies
~37–71MB
~1M SLoC