An example repository that can be cloned and renamed to then become a unity plugin included as a submodule in a primary unity project.
Intended usage:
- Clone repository and provide a new name for it.
- Run a rename script to generate a new plugin file.
- Delete the rename scripts from your repository and update the readme.
- Commit changes.
I have provided two scripts to help in renaming a plugin once you have cloned this repository. The script edits and renames the files in place and thus does not leave the original file structure intact.
The scripts will update the name of the asmdef file and meta files as well as replace any references to UnityPluginTemplate within each file to your provided new plugin name.
RenamePlugin.ps1 [NewPluginName]
rename_plugin.sh [NewPluginName]
Traditionally when you add a plugin in Unity that contains code all of that code is all placed into the root of the plugin module when opening a visual studio solution for the parent project.
This is done regardless of the actual file structure of the files on the disk.
A plugin module that looked like the following
\ UnitySubmodule.Runtime
\ ScriptA.cs
\ Folder1
\ ScriptB.cs
\ Folder2
\ ScriptC.cs
Would appear as the following when in the consumer project's solution.
\ Parent Project
\ Assets
\ Scripts
\ SomeScriptFile.cs
\ UnitySubmodule.Runtime
\ ScriptA.cs
\ ScriptB.cs
\ ScriptC.cs
In this template I have included an asset post processor in the editor module that aughments the VSTU project generation to add path information to each script that is included in the project.
That script is located at Assets\Scripts\Editor\CodeGen\VSTUFolders.cs
You only need to include this file once so make sure to remove it from any subsequent projects if you have more than one plugin using this template. If you prefer the other method of script layout you can remove this file from any plugin you create from this template.