Skip to content

V0odo0/KNOT-ProjectMod

Repository files navigation

Unity version Platforms

KnotProjectMod_icon

Changelog

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

image

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

image

Use Case #1

Create new ProjectMod Preset Asset

image

Setup Mod Chain and click Start

image

Create Additional Preset for reverting changes if required

image

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;
    }
}

About

Unity Editor project modification automation tool

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages