a-particular-project
February 7, 2022 ยท View on GitHub
Required programs:
- Unity ver 2020.3 LTS, download via Unity Hub: https://unity.com/download
- GitHub Desktop for easy version control (optional): https://desktop.github.com/
- Git for version control via console: https://git-scm.com/
- Git LFS for working with big files: https://git-lfs.github.com/
- A D compiler, needed to run the custom build script: https://dlang.org/download.html
- .NET Core 6 SDK, needed to compile and run the code generator: https://dotnet.microsoft.com/en-us/download/dotnet/6.0
- Install CMake: https://cmake.org/download/
- Install Meson: https://mesonbuild.com/Getting-meson.html
- To install Meson, you'll need to install Python 3.7 or newer: https://www.python.org/downloads/
Be sure not to have invalid characters in the path, as CMake considers e.g. "#" invalid.
Setup Instructions
-
Install all the aforementioned programs.
-
Clone this repo via github:
Add -> Clone repository -> URL -> https://github.com/PunkyIANG/a-particular-project.Alternatively, do
git clone https://github.com/PunkyIANG/a-particular-project --recursivevia the command line. The option--recursiveis needed to initialize the submodules. -
Initialize and run the batch script at the root of the repository, by calling
setupvia the command line. It will build and install Baton, the python CLI, build and run Kari, the code generator, on the Unity project and enable thepost-mergeandpre-commitgit hooks.The hooks will ensure meta files stay in sync and will alert you if you attempt to commit a >100mb file, which github will reject. It will reject the commit, allowing you to revise it to remove or reduce the size of the offending file(s). These scripts have to be enabled individually on each computer you clone the repo to. Please ensure your teammates have enabled these as well.
-
The script will ask you to provide the path to the folder with the Unity Editor. For me it is
C:\Program Files\Unity\Editor, for you it might be nested in a folder with the version name. You may do it viaUnity Hub -> Installs -> Three dots above the required version -> Show in Explorer. If the needed version is not showing up, you have either failed to install it or installed it separately, in which case you'd have toLocateit.
If running
piporpythonsays these commands are unrecognized, you'll have to add the paths to them to yourPATHenvironment variable. If you have istalled Python via Visual Studio, like I did, the path topythonis similar toC:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64, and the path topipshould be similar toC:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\Scripts. After you're done, reload the computer and proceed from step 3.
IDE setup
To get Unity to generate .csproj files for Intellisense in e.g. VS Code, open Unity Editor, hit Edit -> Preferences -> External Tools. Under Generate .csproj files for check the first 4 checkboxes. Hit Regenerate project files.
Since the actual project root is one directory level up, that is the folder that should open when you double-click a script via the Unity Editor. To make it work this way, in the same External Tools window in the editor, set External Script Editor Args to "$(ProjectPath)/.." -g "$(File)":$(Line):$(Column).
The above for sure applies to VSCode, I don't know about the workflow in other IDE's. Unity for some reason decided to duplicate solution and csproj file generation code and settings per each IDE.
It may be convenient to have a single master solution file that combined both the Unity-generated and the Kari solution files so that the Intellisense is repo-wide. For this, first generate it in Unity, then run baton master_sln in root.
This autogenerated file will not update automatically, as opposed to the Unity generated one, which means you'll have to regenerate it by rerunning the command every time a new project is added to Unity (asmdef/package) or Kari (csproj).
VSCode debugging
- Install
Debugger for Unityextension. - Open the project in the Unity Editor.
- In VSCode, run the
Unity Editorconfiguration in the debug menu. - Select one of the 'accept' options that have popped up in the Unity Editor.
Now, breakpoints should work.
Current TODOs:
- test to see if code generation works. +
- rewrite python cli in D.
- automate Kari building + installing packages from local feed. I know the local feed is a terrible way to iterate.
- For first, the plugin versions must match exactly, but they are incremented with every commit.
- For second, you need to rebuild everything which is slow as heck, then manually delete and restore the plugins in the plugin folder, then call Kari again. This should be smarter, but I think I also should look into different build systems, perhaps a standardized way to pass a list of files to my Kari.