Unity Rust



Rust Map Editor Unity by RustMapMaking - 2. Rust Map Making's open source map editor. Unity 2019.1.10f1 GNU Affero General Public License v3.0 Updated 1 year ago Created on January 26th, 2019. Rust Map Making Unity Editor. Installation and Editor Guide.

  1. Unity Game Development Fundamentals Unreal Engine C# 3D Game Development C 2D Game Development Unreal Engine. Rust is the proof that systems programmers can have.
  2. About Rust UI Tool - Unity Exporter This is a tool I made as I found CUI to be very difficult when beginning to make Rust Plugins. This tool allows you to make any type of UI in unity, and export it to Rust Format, using this tool allows you to go back and make any minor adjustments needed as everything is saved in the project file.

Rust has sold more than one million copies since its launch late last year and, like other Early Access games, the title isn’t even finished.

The open world exploration and survival title is the brainchild of Facepunch Studios, the indie developer set up by Garry Newman – better known as the creator of Garry’s Mod.

Unity

While this well-known physics sandbox ran on Valve’s Source engine, Newman opted for an alternative tool for developing Rust.

“There’s a bunch of obvious benefits to using Unity,” he explains. “The ease of making multiplatform games, for one; you press a button and it compiles for a platform of your choice. There’s no need to try three different PCs running different operating systems, no need for virtual machines – it just works.

“The pricing is really clear and simple. It’s not cheap, but for what you get it’s not expensive either. It has subscription options too.

“The engine is well used. If you have a problem and you type it into Google, about 50 other people have already had that problem and probably found a solution. Those two days waiting for the engine’s developer to respond to your email is condensed to 30 seconds searching Google.

“Unity is a different way to work – although this throws a lot of programmers off. But if you’re a game developer and you want to make a game, you’ll probably find that you can get a prototype done in a week in Unity.”

ADAPTIVE RUST TREATMENT

Unity also helped the Facepunch team when it came to iterating and updating elements of the game based on feedback from the Early Access users. Given the game is still in a very public beta form, being able to fix problems and add new features will be essential to continuing Rust’s success.

“Unity does allow us to evolve a lot faster than we would be able to in another engine,” Newman says. “If you’re doing things right, then adding things like new items or weapons to your game should generally be a case of copying a prefab, changing a couple of components, and changing the art.'

If you’re a game developer and you want to make a game, you’ll probably find that you can get a prototype done in a week in Unity.

Garry Newman, Facepunch

Rust encompasses a number of mechanics. As well as standard exploration and combat, it also revolves around construction and, as you would expect from Facepunch, physics-based interactions between objects.

Newman explains how Unity enables these mixed mechanics to come together: “Because this is a very general engine and isn’t strictly tied to one type of game, it doesn’t have any expectations of the developer. This allows us to defy genres in a lot of ways.

“The asset store has been a godsend. In the early prototype stages, it’s a lot of risk to add art to a game; you might decide to go a different way, or scrap the project completely – then the art is just thrown away. With the asset store you can pretty much type in anything you want and get a result. All of the animals models in Rust are from the asset store. We haven’t felt the need to change them yet, because th­­­ey’re serving their purpose.”

LOOKING FORWARD

Newman is understandably positive about Unity, but he’s also keen for the team behind the engine to continue developing it – if only to help developers like himself who are pushing the limits of what the tech can do.

“We’d love to see the physics system get an upgrade,” he says. “We’re limited in Rust right now by the 65k collider limit, so we’d love to see that limit broken.”

Newman adds that he “absolutely recommends” Unity to other developers, chipping some words of advice: “Make the game, not the engine. Don’t fight Unity – find a way to embrace and use it. For example, don’t go to huge lengths to try to control the garbage collection.”

Or setting up Continuous Delivery for Unity game with rust native plugin.

Contents:

Unity Rust Plugin

  • Unity and continuous delivery

Development of games in Rust is in quite raw state. There are tools, eg. Amethyst or gfx-rs, however, there’s still plenty of work that needs to be done, before we’d be able to prototype something quickly or deliver a full fledged experience to a player.
I’ve started thinking, why not use existing solutions and just integrate Rust into them, for that sweet performance boost and great experience during development.
Game engine im most familiar with mould be Unity. I looked into whether can I easily make this chimera multi-platform and can it support continuous delivery? The answer was yes - it can.

There’s well known option for making in the cloud builds of unity apps: Unity’s Cloud Builds service. But theres a catch. Or two. It’s not free and it didn’t support custom steps last time I’ve checked. An alternative was needed. Here, to the rescue came github actions. They are fairly new, however, they have ever growing community of collaborators, that produce open source plugins, and what’s most important in my case: there was defined unity build template.

unity-actions allow to build and test projects on push. There are even actions responsible for requesting license server.

The yaml:

  • this part does not need any special explanation.
  • we must provide unity license - in my case it was Unity Personal one. I’ll go deeper into where to get it in next section.
  • first thing we checkout our repo and create cache for out Library folder, for the speedup of consecutive executions.
  • then we run - first tests using webbertakken/unity-test-runner action, followed by a build for desired targetPlatform using webbertakken/unity-builder. Simple, isn’t it?
Unity Rust

As of writing this article, I wasn’t able to setup those runs with 2020 beta, due to segmentation fault in license verifier. When setting up your own job, keep that in mind.

It is important that editors version that’s assigned to secrets.UNITY_LICENSE is matching with the version we are making build on. I’ve seen notes that license files should work between versions but, well, that wasn’t my case.

  • last thing, let’s upload our build somewhere. We don’t need to prepare release, so an artifact will be enough.

Pro users have it easier, cause all they have to do is fill UNITY_SERIAL, UNITY_EMAIL and UNITY_PASSWORD variables in repository secrets. For personal edition users, we need to request special .ulf file directly from Unity’s website.
First of all, we need license request file. It can be retrieved from Unity Hub in the settings, but it may be that It’ll output your first license from when you’ve created given account. For me that was edition 2017 - it didn’t work with my target editor.
In order to overcome such an issue, I’ve created a dummy action on my github using https://github.com/marketplace/actions/unity-request-activation-file. This generated me .alf license request file with desired version. Then I’ve gone to https://license.unity3d.com/manual and was able to retrieve correct .ulf license file. I’ve then pasted it’s contents to new secret in my repository under name UNITY_LICENSE. The build started working.

With game building nicely on Github’s cloud we can switch our attention to getting it running with our rust native plugin. We create new library with cargo new --lib, we open Cargo.toml and add

a crate type, so cargo will know how to build our lib when we run cargo build --release. We need a shared library, which is a dll on Windows, dylib on MacOS and so on Linux.

Our code may look whatever, but for the functions we’ll use outside must follow certain pattern:

extern keyword tells the compiler that this function will be used outside and #[no_mangle] disables name mangling (rust usually adds a lot of useful information about the function to it’s name, when it compiles a library, however, from outside, we’d have to guess what would be exact name we want to import).
Let’s place this code into lib.rs and setup a job, so github would compile it for us before adding as a Plugin to Unity.
For that, as a base, I used mean-bean-ci-template.

this required me to copy the folder ci from the XAMPPRocky’s repo into mine.

One last thing - this artifact must be placed in Assets/Plugins directory in Unity Project. For that, we must add a step to unity build job:

and we are almost done.

Now we must head back to Unity, in main scene of our example project create an object and attach a script to it. Let’s make it more fun - let our object be UI Text. In it’s script we must first import our rust library. We do so by writing:

when building for iOS we’d use library named __Internal instead. That’s double underscore.

after this operation, we can just call test() from our code as normal function. Eg.:

Unity rust support

(Old - Unity 5) Let's Make Rust! [Episode 01 - Introduction]

viola, when ran, our project should put 42 in that text field (taken we compile our lib and place it in Plugins folder on our local machine (we can always push to github and download artifact for testing)).

The following contains compilation for multiple platforms, without tests, but adding these would be quite easy.