> For the complete documentation index, see [llms.txt](https://docs.witchpot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.witchpot.com/english/basic-info/installation-for-unity.md).

# Installation for Unity

## Preparation

Create a unity URP project with Unity2020 or higher version

<figure><img src="https://1270527639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtVdP5UEfu2PNFw4I6asq%2Fuploads%2FHUpi3RZcDGPuI4sET49d%2Funityhub.png?alt=media&amp;token=ab135756-d1c5-493c-b8b3-ecff9fd36a99" alt=""><figcaption></figcaption></figure>

## Installation

Download the unitypackage for stable-diffusion-foar-unity from released page

{% embed url="<https://github.com/witchpot-studio/stable-diffusion-for-unity/releases/tag/v1.4.0>" %}

Import the downloaded unitypackage into the Unity project craeted above.

<figure><img src="https://1270527639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtVdP5UEfu2PNFw4I6asq%2Fuploads%2F9P2ElX1oQqYuODrdh3As%2Fimport.png?alt=media&amp;token=031b8bf9-83d7-4495-898a-2aeeb8df0bdd" alt=""><figcaption></figcaption></figure>

After importing, Preferences > StableDiffusion For Unity window will be shown. If not automatically shown, please open from Menu  Edit > Preferences > StableDiffusion For Unity.

<table><thead><tr><th width="121">Type</th><th>About</th></tr></thead><tbody><tr><td>Internal</td><td>Default WebUI. Use this if you are not familiar with StableDiffusion.<br><br>The Witchpot's custom StableDiffusionWebUI will be automatically installed in your C drive user folder.</td></tr><tr><td>External</td><td>If you want to use StableDiffusion WebUI installed and cutomized by yourself.<br><br>Please specify the path to the WebUI's webui-user.bat file in API mode.<br>For more information on installation, please see <a data-mention href="/english/basic-info/about-webui-install-uninstall.md">About WebUI install/uninstall</a></td></tr></tbody></table>

<figure><img src="https://1270527639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtVdP5UEfu2PNFw4I6asq%2Fuploads%2FXAfxyDeIJ22iQt0S5bsF%2Fpreferences_sd4u.png?alt=media&amp;token=9a1e635d-7d6d-4f95-a84d-e53c3cb6b1b1" alt=""><figcaption></figcaption></figure>

press the Witchpot > StartServer button on the menu bar.

<figure><img src="https://1270527639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtVdP5UEfu2PNFw4I6asq%2Fuploads%2FFLosa0y6zLgvCK61WEa6%2Fstartserver.png?alt=media&amp;token=2aef5178-4cc1-426d-8c05-6f59ed981301" alt=""><figcaption></figcaption></figure>

※If nothing starts after pressing StartServer (especially if you have updated stable-diffusion-for-unity), please restart UnityEditor once.

When you start the server, CommandPrompt will open. \
This initial startup will take some time as it is downloading necessary files.

<figure><img src="https://1270527639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtVdP5UEfu2PNFw4I6asq%2Fuploads%2FHaCEKiv4GUXbYAraMC7z%2Fsetup.png?alt=media&amp;token=e4fcd0ba-db76-4860-a72a-ce08d7f5bd41" alt=""><figcaption></figcaption></figure>

If CommandPrompt displays&#x20;

`Running on local URL:   http://127.0.0.1:7860`

and stops, the installation is complete and you are ready to  generate image.

Open \
Assets\Plugins\Witchpot\Packages\StableDiffusion\Runtime\Settings\StableDiffusionWebUISettings\
and confirm ModelNames and ModelNamesForLora is not empty.

<div align="left"><figure><img src="https://1270527639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtVdP5UEfu2PNFw4I6asq%2Fuploads%2F826wWvcoYyGEJfw4Xg7l%2Fmodelsettings.png?alt=media&amp;token=f512127b-a7b8-4cfa-b177-1fbdfa2b0332" alt=""><figcaption></figcaption></figure></div>

## Confirm Image Generation

Open2DStageDemo scene

Assets\Plugins\Witchpot\Packages\StableDiffusion\Example\Demo\Scenes\2DStageDemo

<figure><img src="https://1270527639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtVdP5UEfu2PNFw4I6asq%2Fuploads%2FoeBooT5wsPKYkEoTd7r6%2Fimage.png?alt=media&amp;token=393b5d4f-bc26-496b-898c-2dd9014756ab" alt=""><figcaption></figcaption></figure>

After Open the scene. Open Canvas > RawImage-Depth2Img and press Generate.

<figure><img src="https://1270527639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtVdP5UEfu2PNFw4I6asq%2Fuploads%2FzGsE7VUwDAOqEHwVukJQ%2Fimage.png?alt=media&amp;token=61077e5b-7716-4e22-b14a-428285b3368d" alt=""><figcaption></figcaption></figure>

Image generation progress bar will be shown on Command Prompt when you generating image.

<figure><img src="https://1270527639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtVdP5UEfu2PNFw4I6asq%2Fuploads%2FibUNLZcAjzL4NzTb1mil%2Fimage.png?alt=media&amp;token=5e513bac-cec5-472c-ab74-3d9d0e9a370a" alt=""><figcaption></figcaption></figure>

Texture will be assigned to the RawImage after image generation completed.

<figure><img src="https://1270527639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtVdP5UEfu2PNFw4I6asq%2Fuploads%2F2THHuwgopiCboOD8eOi7%2Fimage.png?alt=media&amp;token=70479076-d648-4211-823c-7c64973b51ba" alt=""><figcaption></figcaption></figure>

If an error occurs and you are unable to proceed the image generation, you may have insufficient VRAM. Please lower the resolution or try Text2Img.
