|
| 1 | +# unity.el |
| 2 | + |
| 3 | +This package provides some Emacs integration with the Unity game engine. Most |
| 4 | +notably, it provides the ability to open source files from Unity in Emacs or |
| 5 | +Emacsclient while still generating the solution and project files for use with |
| 6 | +`lsp-mode`. |
| 7 | + |
| 8 | +Additionally, this package can install hooks/advice for smoother interop with |
| 9 | +certain Unity quirks. |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +Currently, this package is not on M?ELPA. In the meantime, please clone and |
| 14 | +extend your load path. For example: |
| 15 | + |
| 16 | +```elisp |
| 17 | +(use-package 'unity |
| 18 | + :load-path "site-lisp/unity.el" |
| 19 | + :config |
| 20 | + (unity-build-code-shim) |
| 21 | + (unity-setup)) |
| 22 | +``` |
| 23 | + |
| 24 | +## Configuration |
| 25 | + |
| 26 | +`unity.el` exposes two functions, `unity-build-code-shim` and `unity-setup`. |
| 27 | + |
| 28 | +### `unity-build-code-shim` |
| 29 | + |
| 30 | +Unity does not generate project or solution files unless the external text |
| 31 | +editor is recognized as Visual Studio, Visual Studio Code, or MonoDevelop. |
| 32 | +Unfortunately, this means that other editors which wish to leverage the power of |
| 33 | +the OmniSharp language server are obtuse to use with Unity. `unity.el` provides |
| 34 | +a workaround for this issue: it compiles a very simple binary named |
| 35 | +`code`/`code.exe` which can be set as Unity's external editor to trick it into |
| 36 | +generating the solution/project files as normal. |
| 37 | + |
| 38 | +The shim simply invokes the remaining command line arguments as a command line. |
| 39 | +For example, the following command runs `emacsclient Foo.cs`. |
| 40 | + |
| 41 | +```sh |
| 42 | +code emacsclient Foo.cs |
| 43 | +``` |
| 44 | + |
| 45 | +`unity-build-code-shim` will compile the shim, placing the resulting |
| 46 | +`code`/`code.exe` file in `[emacs-user-directory]/var/unity/`. |
| 47 | + |
| 48 | +You can then change the "External Script Editor" setting to point to `code` and |
| 49 | +adjust the "External Script Editor Args" arguments as such to run `emacsclient` |
| 50 | +(or any program of your choosing, for that matter). |
| 51 | + |
| 52 | +```sh |
| 53 | +emacsclient -n +$(Line):$(Column) $(File) |
| 54 | +``` |
| 55 | + |
| 56 | +### `unity-setup` |
| 57 | + |
| 58 | +This function installs any hooks, advice, etc. necessary for smoother |
| 59 | +Emacs/Unity interop. Currently this is limited to advising `rename-file` so that |
| 60 | +`.meta` files are automatically moved alongside their associated files. |
0 commit comments