com.knot.projectmod
v0.4.3
Published
Unity Editor project modification automation tool
Downloads
11
Readme
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.
Installation
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
Use Case #1
Create new ProjectMod Preset Asset
Setup Mod Chain and click Start
Create Additional Preset for reverting changes if required
Creating custom Mod
Place your Project Mod script under /Editor folder. Deriving from IKnotModAction allows you to select it in Preset.
[Serializable]
[KnotTypeInfo(displayName: "My Custom Project Mod", MenuCustomName = "Test/My Custom Project Mod")]
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;
}
}