#unity #bevy #game #type #unrust #editor #component

unrust-inbuilt

Inbuilt types common between unity and bevy used by unrust

7 releases

0.1.6 Aug 27, 2023
0.1.5 Aug 27, 2023

#1116 in Game dev

Download history 7/week @ 2024-02-19 9/week @ 2024-02-26 3/week @ 2024-03-04 20/week @ 2024-03-11 18/week @ 2024-04-01 59/week @ 2024-04-15

77 downloads per month
Used in 2 crates

MIT license

13KB
295 lines

Crates.io

Unrust - Rust + Bevy + Unity to make games!

Peek 2023-08-27 18-20

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

MIT

Dependencies

~38–76MB
~1M SLoC