com.knot.projectmod
Version:
Unity Editor project modification automation tool
78 lines (51 loc) • 2.74 kB
Markdown



**[Changelog](https://github.com/V0odo0/KNOT-ProjectMod/blob/main/CHANGELOG.md)**
KnotProjectMod adds a set of tools for automating certain processes that require user intervention.
For example, if you need to modify a set of packages for different platforms, you can create a Preset that will sequentially add or remove multiple packages for you. The Mod chain will continue executing even after assembly reload.
> [!WARNING]
> Use this tool with caution, as certain actions may harm your project.
Add `com.knot` Scoped Registry from `https://registry.npmjs.com` in `Project/Package Manager`

Open `Window/Package Manager` and install package from `Packages: My Registries`

Create new ProjectMod Preset Asset

Setup Mod Chain and click Start

Create Additional Preset for reverting changes if required

Place your Project Mod script under /Editor folder. Deriving from IKnotModAction allows you to select it in Preset.
```C
[]
[]
public class MyCustomProjectMod : IKnotModAction
{
public bool DoSomething = true;
public string BuildDescription()
{
if (DoSomething)
return "My Custom Project Mod will do something";
return "My Custom Project Mod yet does nothing";
}
public IEnumerator Perform(EventHandler<IKnotModActionResult> onActionPerformed)
{
try
{
if (DoSomething)
onActionPerformed?.Invoke(this, KnotModActionResult.Completed("My Custom Project Mod did something"));
else onActionPerformed?.Invoke(this, KnotModActionResult.Failed("My Custom Project Mod did nothing"));
}
catch (Exception e)
{
//onActionPerformed should always be called even if it fails, otherwise the Mod chain will stall
onActionPerformed?.Invoke(this, KnotModActionResult.Failed(e.Message));
}
yield break;
}
}
```