Playbook’s Unity SDK integrates the editor with ComfyUI. It allows you to quickly create and refine textures for your scene using generative diffusion models.

Get the Unity SDK

Adding Playbook To Your Project

The Unity SDK only works on projects that are using the Universal Render Pipeline. If your project is not using URP, you can add it by following this guide: Installing URP into an existing Project

1

Open up the Package Manager

Once you have your Unity project open, go to Window -> Package Manager. In the package manager, click the plus icon on the top left and click “Add package from git URL…”.

2

Add the package through Github

Enter the link provided by our repository: Unity SDK

3

Add the dependency

Playbook is dependent on SocketIOUnity, so make sure to also add it to your project using the same steps as before: Socket IO Unity

How To Use Playbook

1

Attach the PlaybookSDK component

To begin using Playbook, simply attach the PlaybookSDK component to your main camera.

2

Add your API key

Add your Playbook API key in the Playbook Account API Key field. You can grab your API key from your Playbook account.

3

Select your team + workflow

Once you enter Play mode in Unity, the Teams and Workflows properties will be populated with your respective teams and workflows. Select the ones you want to work with.

Note that you will need to exit and re-enter Play mode to refresh teams and workflows.

4

Start capturing

You can now start capturing a single frame or an image sequence by clicking the buttons.

You can check if your workflow was received by our servers by opening up the workflow you selected in the Playbook Dashboard. Open up your browser’s console and you should receive a queued run:

5

Wait for the render

Once the render is complete, you’ll find the URL to your image in the PlaybookSDK component. Copy this link, paste it on your local internet browser, and your image will start downloading.

Adding to Mask Pass

You can further customize your renders by manipulating the mask pass. To add or remove GameObjects from mask groups, you can call the following methods:

GameObjects that do not have a Renderer component attached cannot be added to a mask group.


// To add
PlaybookSDK.AddObjectToMaskGroup(GameObject maskObject, MaskGroup maskGroup);
PlaybookSDK.AddObjectsToMaskGroup(List<GameObject> maskObjects, MaskGroup maskGroup);

// To remove
PlaybookSDK.RemoveObjectFromMaskGroup(GameObject maskObject);
PlaybookSDK.RemoveObjectsFromMaskGroup(List<GameObject> maskObjects);

Additionally, you can also change the mask group of the background through these methods:


// To add
PlaybookSDK.SetBackgroundMaskGroup(MaskGroup maskGroup);

// To remove
PlaybookSDK.RemoveBackgroundMaskGroup();

Playbook supports up to 7 mask groups which are specified by the MaskGroup property. MaskGroup also includes the “Catch-all” mask, which is the default group for objects that are not part of a mask group.

Listening to Results Received

To listen to workflow results when they are received, you can subscribe to ResultReceived() given in PlaybookSDK.cs, which returns the result as a url string.

    private void OnEnable()
    {
        PlaybookSDK.ResultReceived += EventToDoWhenReceived;
    }

    private void OnDisable()
    {
        PlaybookSDK.ResultReceived -= EventToDoWhenReceived;
    }

Overriding Node Inputs

If you would like to manually override node inputs, you can do so by using OverrideNodeInputs() given in PlaybookSDK.cs.

To call OverrideNodeInputs(), you must provide a dictionary on inputs to override the desired Playbook nodes in your selected workflow, where the key is the node ID and the value is the new value. For example:

Dictionary<string, object> inputs = new Dictionary<string, object> {
                ["11"] = "cats in outer space",
            };
PlaybookSDK.OverrideNodeInputs(inputs);

Dashboard display of node IDs per workflow is in progress. Currently, node IDs can be found by opening browser console in the Playbook Dashboard and searching for "Playbook Nodes:".