toolness / pathfinder-unity-fun

Attempting to build a Unity native plugin for Pathfinder's Canvas API.
5 stars 1 forks source link

This is an experiment in building a native Unity plugin for the Canvas API portion of Pathfinder.

For more details on the context behind this, see Pathfinder issue #147.

Right now all we have is a plugin that displays a Pathfinder-rendered overlay/HUD, along with a rotating cube that has a Pathfinder-generated render texture on it:

Quick start

The project currently only works on Windows, and it only supports Unity projects that use the OpenGL backend. It has been tested with Unity 2019.1.

First, initialize the repository's git submodules:

git submodule init
git submodule update

Then build the plugin and install it into the sample Unity project:

cargo run

You will need to open the Unity project in the unity-project folder; specifically, the scene unity-project\Assets\Scenes\SampleScene.unity.

To iterate on development and get decent debugger support, you can do the following:

  1. Build the Unity project in the dist directory. Then exit Unity so it doesn't have a lock on the plugin's DLL (either that or exclude the plugin from running in the editor, and restart Unity).
  2. Open the Visual Studio solution in dist/VSDebugHarness. This solution doesn't have any code, it's just set up to launch the Unity project and attach a debugger to it.
  3. Make sure you are targeting the Debug configuration for the x64 platform in Visual Studio and press F5.

Note that pressing F5 automatically re-runs cargo run, so you don't need to worry about re-running it manually.

Alternatively, you can also have the debugger launch the Unity Editor with the sample Unity project. To do this, target the DebugUnityEditor configuration, visit the "Debugging" section of the properties page of the project and set the "Command" to the path of your Unity Editor executable. Then press F5.

Logging produced by the plugin will be available in dist/pathfinder-plugin.log.

You can press Esc to exit the demo.