├── .gitignore
├── Assets
├── Plugins.meta
├── Plugins
│ ├── Newtonsoft.Json.dll
│ └── Newtonsoft.Json.dll.meta
├── Stable-Diffusion-Unity-Integration.meta
├── Stable-Diffusion-Unity-Integration
│ ├── Input Image.meta
│ ├── Input Image
│ │ ├── horse_input.png
│ │ └── horse_input.png.meta
│ ├── Scenes.meta
│ ├── Scenes
│ │ ├── DemoScene-NoPostProcessing.unity
│ │ ├── DemoScene-NoPostProcessing.unity.meta
│ │ ├── DemoScene.unity
│ │ ├── DemoScene.unity.meta
│ │ ├── PostProcessingVolume Profile.asset
│ │ └── PostProcessingVolume Profile.asset.meta
│ ├── Scripts.meta
│ ├── Scripts
│ │ ├── Editor.meta
│ │ ├── Editor
│ │ │ ├── InspectorRefresh.cs
│ │ │ ├── InspectorRefresh.cs.meta
│ │ │ ├── ReadOnlyDrawer.cs
│ │ │ ├── ReadOnlyDrawer.cs.meta
│ │ │ ├── SDSettingsEditor.cs
│ │ │ ├── SDSettingsEditor.cs.meta
│ │ │ ├── StableDiffusionConfigurationEditor.cs
│ │ │ ├── StableDiffusionConfigurationEditor.cs.meta
│ │ │ ├── StableDiffusionImage2ImageEditor.cs
│ │ │ ├── StableDiffusionImage2ImageEditor.cs.meta
│ │ │ ├── StableDiffusionText2ImageEditor.cs
│ │ │ ├── StableDiffusionText2ImageEditor.cs.meta
│ │ │ ├── StableDiffusionText2MaterialEditor.cs
│ │ │ └── StableDiffusionText2MaterialEditor.cs.meta
│ │ ├── ReadOnlyAttribute.cs
│ │ ├── ReadOnlyAttribute.cs.meta
│ │ ├── SDSettings.cs
│ │ ├── SDSettings.cs.meta
│ │ ├── StableDiffusionConfiguration.cs
│ │ ├── StableDiffusionConfiguration.cs.meta
│ │ ├── StableDiffusionGenerator.cs
│ │ ├── StableDiffusionGenerator.cs.meta
│ │ ├── StableDiffusionImage2Image.cs
│ │ ├── StableDiffusionImage2Image.cs.meta
│ │ ├── StableDiffusionImage2Material.cs
│ │ ├── StableDiffusionImage2Material.cs.meta
│ │ ├── StableDiffusionText2Image.cs
│ │ ├── StableDiffusionText2Image.cs.meta
│ │ ├── StableDiffusionText2Material.cs
│ │ └── StableDiffusionText2Material.cs.meta
│ ├── Settings.meta
│ └── Settings
│ │ ├── DefaultLocalSDSettings.asset
│ │ └── DefaultLocalSDSettings.asset.meta
├── StreamingAssets.meta
└── StreamingAssets
│ ├── SDImages.meta
│ ├── SDImages
│ ├── 01d99a33-4deb-4b8f-9c08-cca38e407c38.png
│ ├── 01d99a33-4deb-4b8f-9c08-cca38e407c38.png.meta
│ ├── 33e5b251-804a-4709-9f03-1e576a697cf1.png
│ ├── 33e5b251-804a-4709-9f03-1e576a697cf1.png.meta
│ ├── 79cec67c-d8e3-4981-a0ba-a03a2f777dda.png
│ ├── 79cec67c-d8e3-4981-a0ba-a03a2f777dda.png.meta
│ ├── b6b07faf-594d-40f0-b312-75d3ce491fff.png
│ ├── b6b07faf-594d-40f0-b312-75d3ce491fff.png.meta
│ ├── d3f9a183-0a41-4c42-ac65-effd3210f227.png
│ └── d3f9a183-0a41-4c42-ac65-effd3210f227.png.meta
│ ├── SDMaterials.meta
│ └── SDMaterials
│ ├── 062703f4-a2d9-4878-9575-2ce8377ec229.png
│ ├── 062703f4-a2d9-4878-9575-2ce8377ec229.png.meta
│ ├── 083f586c-1d94-4167-8897-8d8302c19854.png
│ ├── 083f586c-1d94-4167-8897-8d8302c19854.png.meta
│ ├── 2acafddf-b5ab-417e-a354-dfd13a58e5ec.png
│ ├── 2acafddf-b5ab-417e-a354-dfd13a58e5ec.png.meta
│ ├── 57a93795-9aad-43d2-b9dc-14ac2a5b81b0.png
│ ├── 57a93795-9aad-43d2-b9dc-14ac2a5b81b0.png.meta
│ ├── 7089f6a1-e9e0-4189-9e4f-e0ff8875c1cc.png
│ ├── 7089f6a1-e9e0-4189-9e4f-e0ff8875c1cc.png.meta
│ ├── 85de5d56-067f-48b9-83c6-0ee678aba943.png
│ ├── 85de5d56-067f-48b9-83c6-0ee678aba943.png.meta
│ ├── 8712a93a-6704-4650-9044-939f722c8a46.png
│ ├── 8712a93a-6704-4650-9044-939f722c8a46.png.meta
│ ├── 90156104-f1a9-4a17-954a-d19e44d73332.png
│ ├── 90156104-f1a9-4a17-954a-d19e44d73332.png.meta
│ ├── c0835069-7d5c-4e75-923e-52424e2b4d44.png
│ ├── c0835069-7d5c-4e75-923e-52424e2b4d44.png.meta
│ ├── ef15cac4-851e-461e-ad33-e6176170ee69.png
│ └── ef15cac4-851e-461e-ad33-e6176170ee69.png.meta
├── LICENSE
├── Packages
├── manifest.json
└── packages-lock.json
├── ProjectSettings
├── AudioManager.asset
├── ClusterInputManager.asset
├── DynamicsManager.asset
├── EditorBuildSettings.asset
├── EditorSettings.asset
├── GraphicsSettings.asset
├── InputManager.asset
├── MemorySettings.asset
├── MultiplayerManager.asset
├── NavMeshAreas.asset
├── PackageManagerSettings.asset
├── Packages
│ └── com.unity.testtools.codecoverage
│ │ └── Settings.json
├── Physics2DSettings.asset
├── PresetManager.asset
├── ProjectSettings.asset
├── ProjectVersion.txt
├── QualitySettings.asset
├── SceneTemplateSettings.json
├── TagManager.asset
├── TimeManager.asset
├── TimelineSettings.asset
├── UnityConnectSettings.asset
├── VFXManager.asset
├── VersionControlSettings.asset
├── XRSettings.asset
└── boot.config
├── README.md
├── SDConfiguration.png
├── SDImage.png
├── SDListModels.png
├── SDLogo.jpg
├── SDMaterial.png
├── SDSettings.png
├── Stable-Diffusion-Unity-Integration.unitypackage
└── screenshot.png
/.gitignore:
--------------------------------------------------------------------------------
1 | # This .gitignore file should be placed at the root of your Unity project directory
2 | #
3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
4 | #
5 | /[Ll]ibrary/
6 | /[Tt]emp/
7 | /[Oo]bj/
8 | /[Bb]uild/
9 | /[Bb]uilds/
10 | /[Ll]ogs/
11 | /[Mm]emoryCaptures/
12 | /[Uu]serSettings/
13 | /[Aa]ssets/StreamingAssets*
14 |
15 | # Asset meta data should only be ignored when the corresponding asset is also ignored
16 | !/[Aa]ssets/**/*.meta
17 |
18 | # Uncomment this line if you wish to ignore the asset store tools plugin
19 | # /[Aa]ssets/AssetStoreTools*
20 |
21 |
22 | # Autogenerated Jetbrains Rider plugin
23 | [Aa]ssets/Plugins/Editor/JetBrains*
24 |
25 | # Visual Studio cache directory
26 | .vs/
27 |
28 | # Gradle cache directory
29 | .gradle/
30 |
31 | # Autogenerated VS/MD/Consulo solution and project files
32 | ExportedObj/
33 | .consulo/
34 | *.csproj
35 | *.unityproj
36 | *.sln
37 | *.suo
38 | *.tmp
39 | *.user
40 | *.userprefs
41 | *.pidb
42 | *.booproj
43 | *.svd
44 | *.pdb
45 | *.mdb
46 | *.opendb
47 | *.VC.db
48 | *.vsconfig
49 |
50 | # Unity3D generated meta files
51 | *.pidb.meta
52 | *.pdb.meta
53 | *.mdb.meta
54 |
55 | # Unity3D generated file on crash reports
56 | sysinfo.txt
57 |
58 | # Builds
59 | *.apk
60 |
61 | # Crashlytics generated file
62 | crashlytics-build.properties
63 |
--------------------------------------------------------------------------------
/Assets/Plugins.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6fe660a1788802146aa1f95b6b44ee90
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Plugins/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/Plugins/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/Assets/Plugins/Newtonsoft.Json.dll.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5c3dbe4d22a212545948d326764eebc7
3 | PluginImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | iconMap: {}
7 | executionOrder: {}
8 | defineConstraints: []
9 | isPreloaded: 0
10 | isOverridable: 0
11 | isExplicitlyReferenced: 0
12 | validateReferences: 1
13 | platformData:
14 | - first:
15 | Any:
16 | second:
17 | enabled: 1
18 | settings: {}
19 | - first:
20 | Editor: Editor
21 | second:
22 | enabled: 0
23 | settings:
24 | DefaultValueInitialized: true
25 | - first:
26 | Windows Store Apps: WindowsStoreApps
27 | second:
28 | enabled: 0
29 | settings:
30 | CPU: AnyCPU
31 | userData:
32 | assetBundleName:
33 | assetBundleVariant:
34 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 25558563ff723d148911d80e098aa9f0
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Input Image.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 31317b8dcb4d62045ad8e7c81001fad8
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Input Image/horse_input.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/Stable-Diffusion-Unity-Integration/Input Image/horse_input.png
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Input Image/horse_input.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ed309daa36c8f274488a29b3c95faa39
3 | TextureImporter:
4 | internalIDToNameTable: []
5 | externalObjects: {}
6 | serializedVersion: 12
7 | mipmaps:
8 | mipMapMode: 0
9 | enableMipMap: 1
10 | sRGBTexture: 1
11 | linearTexture: 0
12 | fadeOut: 0
13 | borderMipMap: 0
14 | mipMapsPreserveCoverage: 0
15 | alphaTestReferenceValue: 0.5
16 | mipMapFadeDistanceStart: 1
17 | mipMapFadeDistanceEnd: 3
18 | bumpmap:
19 | convertToNormalMap: 0
20 | externalNormalMap: 0
21 | heightScale: 0.25
22 | normalMapFilter: 0
23 | isReadable: 1
24 | streamingMipmaps: 0
25 | streamingMipmapsPriority: 0
26 | vTOnly: 0
27 | ignoreMasterTextureLimit: 0
28 | grayScaleToAlpha: 0
29 | generateCubemap: 6
30 | cubemapConvolution: 0
31 | seamlessCubemap: 0
32 | textureFormat: 1
33 | maxTextureSize: 2048
34 | textureSettings:
35 | serializedVersion: 2
36 | filterMode: 1
37 | aniso: 1
38 | mipBias: 0
39 | wrapU: 0
40 | wrapV: 0
41 | wrapW: 0
42 | nPOTScale: 1
43 | lightmap: 0
44 | compressionQuality: 50
45 | spriteMode: 0
46 | spriteExtrude: 1
47 | spriteMeshType: 1
48 | alignment: 0
49 | spritePivot: {x: 0.5, y: 0.5}
50 | spritePixelsToUnits: 100
51 | spriteBorder: {x: 0, y: 0, z: 0, w: 0}
52 | spriteGenerateFallbackPhysicsShape: 1
53 | alphaUsage: 1
54 | alphaIsTransparency: 0
55 | spriteTessellationDetail: -1
56 | textureType: 0
57 | textureShape: 1
58 | singleChannelComponent: 0
59 | flipbookRows: 1
60 | flipbookColumns: 1
61 | maxTextureSizeSet: 0
62 | compressionQualitySet: 0
63 | textureFormatSet: 0
64 | ignorePngGamma: 0
65 | applyGammaDecoding: 0
66 | cookieLightType: 0
67 | platformSettings:
68 | - serializedVersion: 3
69 | buildTarget: DefaultTexturePlatform
70 | maxTextureSize: 2048
71 | resizeAlgorithm: 0
72 | textureFormat: -1
73 | textureCompression: 0
74 | compressionQuality: 50
75 | crunchedCompression: 0
76 | allowsAlphaSplitting: 0
77 | overridden: 0
78 | androidETC2FallbackOverride: 0
79 | forceMaximumCompressionQuality_BC6H_BC7: 0
80 | - serializedVersion: 3
81 | buildTarget: Standalone
82 | maxTextureSize: 2048
83 | resizeAlgorithm: 0
84 | textureFormat: -1
85 | textureCompression: 1
86 | compressionQuality: 50
87 | crunchedCompression: 0
88 | allowsAlphaSplitting: 0
89 | overridden: 0
90 | androidETC2FallbackOverride: 0
91 | forceMaximumCompressionQuality_BC6H_BC7: 0
92 | - serializedVersion: 3
93 | buildTarget: Server
94 | maxTextureSize: 2048
95 | resizeAlgorithm: 0
96 | textureFormat: -1
97 | textureCompression: 1
98 | compressionQuality: 50
99 | crunchedCompression: 0
100 | allowsAlphaSplitting: 0
101 | overridden: 0
102 | androidETC2FallbackOverride: 0
103 | forceMaximumCompressionQuality_BC6H_BC7: 0
104 | spriteSheet:
105 | serializedVersion: 2
106 | sprites: []
107 | outline: []
108 | physicsShape: []
109 | bones: []
110 | spriteID:
111 | internalID: 0
112 | vertices: []
113 | indices:
114 | edges: []
115 | weights: []
116 | secondaryTextures: []
117 | nameFileIdTable: {}
118 | spritePackingTag:
119 | pSDRemoveMatte: 0
120 | pSDShowRemoveMatteOption: 0
121 | userData:
122 | assetBundleName:
123 | assetBundleVariant:
124 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scenes.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b7389b5d986f4284cafe842d9f59839b
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scenes/DemoScene-NoPostProcessing.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 43e4c76e7de0515469b623edcd5baa47
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scenes/DemoScene.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0d6ccaa67bd7f7446abbd1d5fbd9c6d6
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scenes/PostProcessingVolume Profile.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 45ed0ce96d2961245a23e347424e5389
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 11400000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3aedc44124318444dbc8a55d616f031c
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/Editor.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 03024a8d4e0cb3a44be89b34779e4dae
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/Editor/InspectorRefresh.cs:
--------------------------------------------------------------------------------
1 | using UnityEditor;
2 | using System;
3 | using UnityEditor.SceneManagement;
4 |
5 | ///
6 | /// Component that forces editor to refresh when returning to edit mode
7 | ///
8 | [InitializeOnLoad]
9 | public static class InspectorRefresh
10 | {
11 | public static event Action OnEnterEditMode;
12 | static InspectorRefresh()
13 | {
14 | EditorApplication.playModeStateChanged += PlaymodeStateChanged;
15 | }
16 |
17 | private static void PlaymodeStateChanged(PlayModeStateChange stateChange)
18 | {
19 | if (stateChange == PlayModeStateChange.EnteredEditMode)
20 | {
21 | OnEnterEditMode?.Invoke();
22 | }
23 | }
24 |
25 | public static void ForceInspectorToRefresh()
26 | {
27 | AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
28 | EditorApplication.QueuePlayerLoopUpdate();
29 | EditorSceneManager.MarkAllScenesDirty();
30 | EditorUtility.RequestScriptReload();
31 | }
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/Editor/InspectorRefresh.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1ef8bc46b3d6cd54088fbc3d6c015408
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/Editor/ReadOnlyDrawer.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEditor;
4 | using UnityEngine;
5 |
6 |
7 | [CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
8 | public class ReadOnlyDrawer : PropertyDrawer
9 | {
10 | public override float GetPropertyHeight(SerializedProperty property,
11 | GUIContent label)
12 | {
13 | return EditorGUI.GetPropertyHeight(property, label, true);
14 | }
15 |
16 | public override void OnGUI(Rect position,
17 | SerializedProperty property,
18 | GUIContent label)
19 | {
20 | GUI.enabled = false;
21 | EditorGUI.PropertyField(position, property, label, true);
22 | GUI.enabled = true;
23 | }
24 | }
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/Editor/ReadOnlyDrawer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 036baf726418c9e4b8ce1f8f7b444c50
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/Editor/SDSettingsEditor.cs:
--------------------------------------------------------------------------------
1 |
2 | using UnityEditor;
3 | using UnityEngine;
4 |
5 | ///
6 | /// Custom Inspector to add a menu in the Assets/Create drop-down for a SDSettings.
7 | ///
8 | [CustomEditor(typeof(SDSettings))]
9 | public class SDSettingsEditor : Editor
10 | {
11 | [MenuItem("Assets/Create/SDSettings")]
12 | public static void CreateMyScriptableObject()
13 | {
14 | SDSettings asset = ScriptableObject.CreateInstance();
15 | AssetDatabase.CreateAsset(asset, "Assets/NewSDSettings.asset");
16 | AssetDatabase.SaveAssets();
17 | EditorUtility.FocusProjectWindow();
18 | Selection.activeObject = asset;
19 | }
20 | }
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/Editor/SDSettingsEditor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4b85004bb80891d43b4c0ccc8ade0d19
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/Editor/StableDiffusionConfigurationEditor.cs:
--------------------------------------------------------------------------------
1 | using UnityEditor;
2 | using UnityEngine;
3 |
4 | ///
5 | /// Custom Inspector to add a button to seek the models list
6 | /// from a StableDiffusionConfiguration.
7 | ///
8 | [CustomEditor(typeof(StableDiffusionConfiguration))]
9 | public class StableDiffusionConfigurationEditor : Editor
10 | {
11 | public override void OnInspectorGUI()
12 | {
13 | base.OnInspectorGUI();
14 |
15 | StableDiffusionConfiguration myComponent = (StableDiffusionConfiguration)target;
16 |
17 | if (GUILayout.Button("List Models"))
18 | myComponent.ListModels();
19 | }
20 | }
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/Editor/StableDiffusionConfigurationEditor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 63365701a3687434cb760d726063bd7a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/Editor/StableDiffusionImage2ImageEditor.cs:
--------------------------------------------------------------------------------
1 | using UnityEditor;
2 | using UnityEngine;
3 |
4 | ///
5 | /// Custom Inspector to add a models list as a drop-down selection UI
6 | /// and add a "Generate" button for the StableDiffusionImage.
7 | ///
8 | [CustomEditor(typeof(StableDiffusionImage2Image))]
9 | public class StableDiffusionImage2ImageEditor : Editor
10 | {
11 | public override void OnInspectorGUI()
12 | {
13 | EditorGUILayout.HelpBox("Input textures should be uncompressed and readable", MessageType.Info);
14 |
15 | base.OnInspectorGUI();
16 |
17 | StableDiffusionImage2Image myComponent = (StableDiffusionImage2Image)target;
18 |
19 | // Draw the drop-down list for the Samplers list
20 | myComponent.selectedSampler = EditorGUILayout.Popup("Sampler", myComponent.selectedSampler, myComponent.samplersList);
21 |
22 | // Draw the drop-down list for the Models list
23 | myComponent.selectedModel = EditorGUILayout.Popup("Model", myComponent.selectedModel, myComponent.modelsList);
24 |
25 | // Apply the changes to the serialized object
26 | serializedObject.ApplyModifiedProperties();
27 |
28 | if (GUILayout.Button("Generate"))
29 | myComponent.Generate();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/Editor/StableDiffusionImage2ImageEditor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1ef2486aabc75eb48a62c0d4bb8051bf
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/Editor/StableDiffusionText2ImageEditor.cs:
--------------------------------------------------------------------------------
1 | using UnityEditor;
2 | using UnityEngine;
3 |
4 | ///
5 | /// Custom Inspector to add a models list as a drop-down selection UI
6 | /// and add a "Generate" button for the StableDiffusionImage.
7 | ///
8 | [CustomEditor(typeof(StableDiffusionText2Image))]
9 | public class StableDiffusionText2ImageEditor : Editor
10 | {
11 | public override void OnInspectorGUI()
12 | {
13 | base.OnInspectorGUI();
14 |
15 | StableDiffusionText2Image myComponent = (StableDiffusionText2Image)target;
16 |
17 | // Draw the drop-down list for the Samplers list
18 | myComponent.selectedSampler = EditorGUILayout.Popup("Sampler", myComponent.selectedSampler, myComponent.samplersList);
19 |
20 | // Draw the drop-down list for the Models list
21 | myComponent.selectedModel = EditorGUILayout.Popup("Model", myComponent.selectedModel, myComponent.modelsList);
22 |
23 | // Apply the changes to the serialized object
24 | serializedObject.ApplyModifiedProperties();
25 |
26 | if (GUILayout.Button("Generate"))
27 | myComponent.Generate();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/Editor/StableDiffusionText2ImageEditor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 98177daecf2a6ae4e973eb5975e11ecc
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/Editor/StableDiffusionText2MaterialEditor.cs:
--------------------------------------------------------------------------------
1 | using UnityEditor;
2 | using UnityEngine;
3 |
4 | ///
5 | /// Custom Inspector to add a models list as a drop-down selection UI
6 | /// and add a "Generate" button for the StableDiffusionMaterial.
7 | ///
8 | [CustomEditor(typeof(StableDiffusionText2Material))]
9 | public class StableDiffusionText2MaterialEditor : Editor
10 | {
11 | public override void OnInspectorGUI()
12 | {
13 | base.OnInspectorGUI();
14 |
15 | StableDiffusionText2Material myComponent = (StableDiffusionText2Material)target;
16 |
17 | // Draw the drop-down list for the Samplers list
18 | myComponent.selectedSampler = EditorGUILayout.Popup("Sampler", myComponent.selectedSampler, myComponent.samplersList);
19 |
20 | // Draw the drop-down list for the Models list
21 | myComponent.selectedModel = EditorGUILayout.Popup("Model", myComponent.selectedModel, myComponent.modelsList);
22 |
23 | // Apply the changes to the serialized object
24 | serializedObject.ApplyModifiedProperties();
25 |
26 | if (GUILayout.Button("Generate"))
27 | myComponent.Generate();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/Editor/StableDiffusionText2MaterialEditor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 285b9067714414e499dbdff9a234b312
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/ReadOnlyAttribute.cs:
--------------------------------------------------------------------------------
1 | using UnityEditor;
2 | using UnityEngine;
3 |
4 | public class ReadOnlyAttribute : PropertyAttribute
5 | {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/ReadOnlyAttribute.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fa463f26a4763ce4c8ad82b390461dc9
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/SDSettings.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | ///
4 | /// Data structure for specifying settings of Stable Diffusion server API or
5 | /// default settings to use when adding new StableDiffusionMaterial or StableDIffusionImage
6 | /// to a Unity GameObject.
7 | ///
8 | public class SDSettings : ScriptableObject
9 | {
10 | [Header("AUTOMATIC1111 Settings")]
11 | public string StableDiffusionServerURL = "http://127.0.0.1:7860";
12 | public string ModelsAPI = "/sdapi/v1/sd-models";
13 | public string TextToImageAPI = "/sdapi/v1/txt2img";
14 | public string ImageToImageAPI = "/sdapi/v1/img2img";
15 | public string OptionAPI = "/sdapi/v1/options";
16 | public string ProgressAPI = "/sdapi/v1/progress";
17 | public string OutputFolder = "/streamingAssets";
18 | public string sampler = "Euler a";
19 | public int width = 512;
20 | public int height = 512;
21 | public int steps = 35;
22 | public float cfgScale = 7;
23 | public long seed = -1;
24 |
25 | [Header("API Settings")]
26 | public bool useAuth = false;
27 | public string user = "";
28 | public string pass = "";
29 |
30 | [Header("URP Settings")]
31 | public bool useUniversalRenderPipeline = false;
32 | }
33 |
34 | ///
35 | /// Data structure to easily serialize the parameters to send
36 | /// to the Stable Diffusion server when generating an image via Txt2Img.
37 | ///
38 | class SDParamsInTxt2Img
39 | {
40 | public bool enable_hr = false;
41 | public float denoising_strength = 0;
42 | public int firstphase_width = 0;
43 | public int firstphase_height = 0;
44 | public float hr_scale = 2;
45 | public string hr_upscaler = "";
46 | public int hr_second_pass_steps = 0;
47 | public int hr_resize_x = 0;
48 | public int hr_resize_y = 0;
49 | public string prompt = "";
50 | public string[] styles = { "" };
51 | public long seed = -1;
52 | public long subseed = -1;
53 | public float subseed_strength = 0;
54 | public int seed_resize_from_h = -1;
55 | public int seed_resize_from_w = -1;
56 | public string sampler_name = "Euler a";
57 | public int batch_size = 1;
58 | public int n_iter = 1;
59 | public int steps = 50;
60 | public float cfg_scale = 7;
61 | public int width = 512;
62 | public int height = 512;
63 | public bool restore_faces = false;
64 | public bool tiling = false;
65 | public string negative_prompt = "";
66 | public float eta = 0;
67 | public float s_churn = 0;
68 | public float s_tmax = 0;
69 | public float s_tmin = 0;
70 | public float s_noise = 1;
71 | public bool override_settings_restore_afterwards = true;
72 | public string sampler_index = "Euler";
73 | }
74 |
75 | ///
76 | /// Data structure to easily deserialize the data returned
77 | /// by the Stable Diffusion server after generating an image via Txt2Img.
78 | ///
79 | class SDParamsOutTxt2Img
80 | {
81 | public bool enable_hr = false;
82 | public float denoising_strength = 0;
83 | public int firstphase_width = 0;
84 | public int firstphase_height = 0;
85 | public float hr_scale = 2;
86 | public string hr_upscaler = "";
87 | public int hr_second_pass_steps = 0;
88 | public int hr_resize_x = 0;
89 | public int hr_resize_y = 0;
90 | public string prompt = "";
91 | public string[] styles = { "" };
92 | public long seed = -1;
93 | public long subseed = -1;
94 | public float subseed_strength = 0;
95 | public int seed_resize_from_h = -1;
96 | public int seed_resize_from_w = -1;
97 | public string sampler_name = "Euler a";
98 | public int batch_size = 1;
99 | public int n_iter = 1;
100 | public int steps = 50;
101 | public float cfg_scale = 7;
102 | public int width = 512;
103 | public int height = 512;
104 | public bool restore_faces = false;
105 | public bool tiling = false;
106 | public string negative_prompt = "";
107 | public float eta = 0;
108 | public float s_churn = 0;
109 | public float s_tmax = 0;
110 | public float s_tmin = 0;
111 | public float s_noise = 1;
112 | public SettingsOveride override_settings;
113 | public bool override_settings_restore_afterwards = true;
114 | public string[] script_args = { };
115 | public string sampler_index = "Euler";
116 | public string script_name = "";
117 |
118 | public class SettingsOveride
119 | {
120 |
121 | }
122 | }
123 |
124 | ///
125 | /// Data structure to easily serialize the parameters to send
126 | /// to the Stable Diffusion server when generating an image via Img2Img.
127 | ///
128 | class SDParamsInImg2Img
129 | {
130 | public string[] init_images = { "" };
131 | public int resize_mode = 0;
132 | public float denoising_strength = 0.75f;
133 | // public string mask = ""; // including this throws a 500 Internal Server error
134 | public int mask_blur = 4;
135 | public int inpainting_fill = 0;
136 | public bool inpaint_full_res = true;
137 | public int inpaint_full_res_padding = 0;
138 | public int inpainting_mask_invert = 0;
139 | public int initial_noise_multiplier = 1; // if 0, output image looks more blurry
140 | public string prompt = "";
141 | public string[] styles = { "" };
142 | public long seed = -1;
143 | public long subseed = -1;
144 | public int subseed_strength = 0;
145 | public int seed_resize_from_h = -1;
146 | public int seed_resize_from_w = -1;
147 | public string sampler_name = "Euler a";
148 | public int batch_size = 1;
149 | public int n_iter = 1;
150 | public int steps = 50;
151 | public float cfg_scale = 7;
152 | public int width = 512;
153 | public int height = 512;
154 | public bool restore_faces = false;
155 | public bool tiling = false;
156 | public string negative_prompt = "";
157 | public float eta = 0;
158 | public float s_churn = 0;
159 | public float s_tmax = 0;
160 | public float s_tmin = 0;
161 | public float s_noise = 1;
162 | public SettingsOveride override_settings;
163 | public bool override_settings_restore_afterwards = true;
164 | public string[] script_args = { };
165 | public string sampler_index = "Euler";
166 | public bool include_init_images = false;
167 | // public string script_name = ""; // including this throws a 422 Unprocessable Entity error
168 |
169 | public class SettingsOveride
170 | {
171 |
172 | }
173 | }
174 |
175 | ///
176 | /// Data structure to easily deserialize the data returned
177 | /// by the Stable Diffusion server after generating an image via Img2Img.
178 | ///
179 | class SDParamsOutImg2Img
180 | {
181 | public string[] init_images = { "" };
182 | public float resize_mode = 0;
183 | public float denoising_strength = 0.75f;
184 | public string mask = "";
185 | public float mask_blur = 4;
186 | public float inpainting_fill = 0;
187 | public bool inpaint_full_res = true;
188 | public float inpaint_full_res_padding = 0;
189 | public float inpainting_mask_invert = 0;
190 | public float initial_noise_multiplier = 0;
191 | public string prompt = "";
192 | public string[] styles = { "" };
193 | public long seed = -1;
194 | public long subseed = -1;
195 | public float subseed_strength = 0;
196 | public float seed_resize_from_h = -1;
197 | public float seed_resize_from_w = -1;
198 | public string sampler_name = "";
199 | public float batch_size = 1;
200 | public float n_iter = 1;
201 | public int steps = 50;
202 | public float cfg_scale = 7;
203 | public int width = 512;
204 | public int height = 512;
205 | public bool restore_faces = false;
206 | public bool tiling = false;
207 | public string negative_prompt = "";
208 | public float eta = 0;
209 | public float s_churn = 0;
210 | public float s_tmax = 0;
211 | public float s_tmin = 0;
212 | public float s_noise = 1;
213 | public SettingsOveride override_settings;
214 | public bool override_settings_restore_afterwards = true;
215 | public string[] script_args = { };
216 | public string sampler_index = "Euler";
217 | public bool include_init_images = false;
218 | public string script_name = "";
219 |
220 | public class SettingsOveride
221 | {
222 |
223 | }
224 | }
225 |
226 | ///
227 | /// Data structure to easily deserialize the JSON response returned
228 | /// by the Stable Diffusion server after generating an image via Txt2Img.
229 | ///
230 | /// It will contain the generated images (in Ascii Byte64 format) and
231 | /// the parameters used by Stable Diffusion.
232 | ///
233 | /// Note that the out parameters returned should be almost identical to the in
234 | /// parameters that you have submitted to the server for image generation,
235 | /// to the exception of the seed which will contain the value of the seed used
236 | /// for the generation if you have used -1 for value (random).
237 | ///
238 | class SDResponseTxt2Img
239 | {
240 | public string[] images;
241 | public SDParamsOutTxt2Img parameters;
242 | public string info;
243 | }
244 |
245 | ///
246 | /// Data structure to easily deserialize the JSON response returned
247 | /// by the Stable Diffusion server after generating an image via Img2Img.
248 | ///
249 | /// It will contain the generated images (in Ascii Byte64 format) and
250 | /// the parameters used by Stable Diffusion.
251 | ///
252 | /// Note that the out parameters returned should be almost identical to the in
253 | /// parameters that you have submitted to the server for image generation,
254 | /// to the exception of the seed which will contain the value of the seed used
255 | /// for the generation if you have used -1 for value (random).
256 | ///
257 | class SDResponseImg2Img
258 | {
259 | public string[] images;
260 | public SDParamsOutImg2Img parameters;
261 | public string info;
262 | }
263 |
264 |
265 | ///
266 | /// Data structure to help serialize into a JSON the model to be used by Stable Diffusion.
267 | /// This is to send along a Set Option API request to the server.
268 | ///
269 | class SDOption
270 | {
271 | public string sd_model_checkpoint = "";
272 | }
273 |
274 | ///
275 | /// Data structure to help deserialize from a JSON the state of the progress of an image generation.
276 | ///
277 | class SDProgressState
278 | {
279 | public bool skipped;
280 | public bool interrupted;
281 | public string job;
282 | public int job_count;
283 | public string job_timestamp;
284 | public int job_no;
285 | public int sampling_step;
286 | public int sampling_steps;
287 | }
288 |
289 | ///
290 | /// Data structure to help deserialize from a JSON the progress status of an image generation.
291 | ///
292 | class SDProgress
293 | {
294 | public float progress;
295 | public float eta_relative;
296 | public SDProgressState state;
297 | public string current_image;
298 | public string textinfo;
299 | }
300 |
301 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/SDSettings.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2624b883c65a4284ba2d9c328a8fe674
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/StableDiffusionConfiguration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Newtonsoft.Json;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net;
7 | using System.Text;
8 | using UnityEngine;
9 | using UnityEngine.Networking;
10 | using Math = System.Math;
11 |
12 | ///
13 | /// Global Stable Diffusion parameters configuration.
14 | ///
15 | [ExecuteInEditMode]
16 | public class StableDiffusionConfiguration : MonoBehaviour
17 | {
18 | [SerializeField]
19 | public SDSettings settings;
20 |
21 | [SerializeField]
22 | public string[] samplers = new string[]{
23 | "Euler a", "Euler", "LMS", "Heun", "DPM2", "DPM2 a", "DPM++ 2S a", "DPM++ 2M", "DPM++ SDE", "DPM fast", "DPM adaptive",
24 | "LMS Karras", "DPM2 Karras", "DPM2 a Karras", "DPM++ 2S a Karras", "DPM++ 2M Karras", "DPM++ SDE Karras", "DDIM", "PLMS"
25 | };
26 |
27 | [SerializeField]
28 | public string[] modelNames;
29 |
30 | ///
31 | /// Data structure that represents a Stable Diffusion model to help deserialize from JSON string.
32 | ///
33 | class Model
34 | {
35 | public string title;
36 | public string model_name;
37 | public string hash;
38 | public string sha256;
39 | public string filename;
40 | public string config;
41 | }
42 |
43 | ///
44 | /// Method called when the user click on List Model from the inspector.
45 | ///
46 | public void ListModels()
47 | {
48 | StartCoroutine(ListModelsAsync());
49 | }
50 |
51 | ///
52 | /// Get the list of available Stable Diffusion models.
53 | ///
54 | ///
55 | IEnumerator ListModelsAsync()
56 | {
57 | // Stable diffusion API url for getting the models list
58 | string url = settings.StableDiffusionServerURL + settings.ModelsAPI;
59 | Debug.Log("Requesting models from: " + url);
60 |
61 | UnityWebRequest request = new UnityWebRequest(url, "GET");
62 | request.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer();
63 | request.SetRequestHeader("Content-Type", "application/json");
64 |
65 | if (settings.useAuth && !settings.user.Equals("") && !settings.pass.Equals(""))
66 | {
67 | Debug.Log("Using API key to authenticate");
68 | byte[] bytesToEncode = Encoding.UTF8.GetBytes(settings.user + ":" + settings.pass);
69 | string encodedCredentials = Convert.ToBase64String(bytesToEncode);
70 | request.SetRequestHeader("Authorization", "Basic " + encodedCredentials);
71 | }
72 |
73 | yield return request.SendWebRequest();
74 |
75 | // Check for connection errors first
76 | if (request.result == UnityWebRequest.Result.ConnectionError ||
77 | request.result == UnityWebRequest.Result.ProtocolError)
78 | {
79 | Debug.LogError("Connection error: " + request.error);
80 | Debug.LogError("Response code: " + request.responseCode);
81 | Debug.LogError("Response: " + request.downloadHandler.text);
82 |
83 | if (request.responseCode == 404)
84 | {
85 | Debug.LogError("API endpoint not found. Trying alternate API endpoint...");
86 | // Try with '/api/v1/sd-models' as an alternative
87 | yield return TryAlternateModelAPI();
88 | yield break;
89 | }
90 | else if (request.responseCode == 401 || request.responseCode == 403)
91 | {
92 | Debug.LogError("Authentication error: Server requires an API key. Please enable useAuth and set user/pass fields in your SDSettings.");
93 | yield break;
94 | }
95 | else
96 | {
97 | Debug.LogError("Make sure Stable Diffusion is running locally on port 7860, or update the URL in your settings.");
98 | yield break;
99 | }
100 | }
101 |
102 | try
103 | {
104 | Debug.Log("Response received: " + request.downloadHandler.text.Substring(0, Math.Min(100, request.downloadHandler.text.Length)) + "...");
105 |
106 | // Check if response is empty or not JSON
107 | if (string.IsNullOrEmpty(request.downloadHandler.text) ||
108 | (!request.downloadHandler.text.StartsWith("[") && !request.downloadHandler.text.StartsWith("{")))
109 | {
110 | Debug.LogError("Invalid response format. Expected JSON array but got: " + request.downloadHandler.text);
111 | yield break;
112 | }
113 |
114 | // Deserialize the response to a class
115 | Model[] ms = JsonConvert.DeserializeObject(request.downloadHandler.text);
116 |
117 | // Keep only the names of the models
118 | List modelsNames = new List();
119 |
120 | foreach (Model m in ms)
121 | modelsNames.Add(m.model_name);
122 |
123 | // Convert the list into an array and store it for futur use
124 | modelNames = modelsNames.ToArray();
125 | Debug.Log("Successfully loaded " + modelNames.Length + " models");
126 | }
127 | catch (Exception e)
128 | {
129 | Debug.LogError("Error parsing models response: " + e.Message);
130 | Debug.LogError("Response was: " + request.downloadHandler.text);
131 |
132 | // Try with alternate endpoint
133 | StartCoroutine(TryAlternateModelAPI());
134 | }
135 | }
136 |
137 | ///
138 | /// Try an alternate API endpoint to get models list
139 | ///
140 | private IEnumerator TryAlternateModelAPI()
141 | {
142 | string alternateUrl = settings.StableDiffusionServerURL + "/api/sd-models";
143 | Debug.Log("Trying alternate models API: " + alternateUrl);
144 |
145 | UnityWebRequest request = new UnityWebRequest(alternateUrl, "GET");
146 | request.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer();
147 | request.SetRequestHeader("Content-Type", "application/json");
148 |
149 | if (settings.useAuth && !settings.user.Equals("") && !settings.pass.Equals(""))
150 | {
151 | byte[] bytesToEncode = Encoding.UTF8.GetBytes(settings.user + ":" + settings.pass);
152 | string encodedCredentials = Convert.ToBase64String(bytesToEncode);
153 | request.SetRequestHeader("Authorization", "Basic " + encodedCredentials);
154 | }
155 |
156 | yield return request.SendWebRequest();
157 |
158 | if (request.result != UnityWebRequest.Result.Success)
159 | {
160 | Debug.LogError("Alternate API also failed: " + request.error);
161 | Debug.LogError("Please check if your Stable Diffusion WebUI is running at " + settings.StableDiffusionServerURL);
162 | Debug.LogError("If you're using AUTOMATIC1111's WebUI, make sure you launched it with the '--api' flag");
163 | yield break;
164 | }
165 |
166 | try
167 | {
168 | // Deserialize the response to a class
169 | Model[] ms = JsonConvert.DeserializeObject(request.downloadHandler.text);
170 |
171 | // Keep only the names of the models
172 | List modelsNames = new List();
173 |
174 | foreach (Model m in ms)
175 | modelsNames.Add(m.model_name);
176 |
177 | // Convert the list into an array and store it for future use
178 | modelNames = modelsNames.ToArray();
179 | Debug.Log("Successfully loaded " + modelNames.Length + " models using alternate API");
180 | }
181 | catch (Exception e)
182 | {
183 | Debug.LogError("Failed to parse models from alternate API: " + e.Message);
184 | Debug.LogError("Make sure your Stable Diffusion WebUI was launched with the '--api' flag");
185 | Debug.LogError("Example launch command: './webui.sh --api'");
186 | }
187 | }
188 |
189 | ///
190 | /// Set a model to use by Stable Diffusion.
191 | ///
192 | /// Model to set
193 | ///
194 | public IEnumerator SetModelAsync(string modelName)
195 | {
196 | // Stable diffusion API url for setting a model
197 | string url = settings.StableDiffusionServerURL + settings.OptionAPI;
198 | Debug.Log("Setting model to: " + modelName + " using URL: " + url);
199 |
200 | // Load the list of models if not filled already
201 | if (modelNames == null || modelNames.Length == 0)
202 | yield return ListModelsAsync();
203 |
204 | // If models still not loaded, can't continue
205 | if (modelNames == null || modelNames.Length == 0)
206 | {
207 | Debug.LogError("Failed to load model list. Cannot set model.");
208 | yield break;
209 | }
210 |
211 | // First try with UnityWebRequest
212 | UnityWebRequest request = new UnityWebRequest(url, "POST");
213 | request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
214 | request.uploadHandler = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(
215 | JsonConvert.SerializeObject(new SDOption { sd_model_checkpoint = modelName })));
216 | request.SetRequestHeader("Content-Type", "application/json");
217 |
218 | if (settings.useAuth && !settings.user.Equals("") && !settings.pass.Equals(""))
219 | {
220 | byte[] bytesToEncode = Encoding.UTF8.GetBytes(settings.user + ":" + settings.pass);
221 | string encodedCredentials = Convert.ToBase64String(bytesToEncode);
222 | request.SetRequestHeader("Authorization", "Basic " + encodedCredentials);
223 | }
224 |
225 | yield return request.SendWebRequest();
226 |
227 | if (request.result == UnityWebRequest.Result.Success)
228 | {
229 | Debug.Log("Model successfully set to: " + modelName);
230 | yield break;
231 | }
232 |
233 | // If unity web request failed, try the alternate method with HttpWebRequest
234 | Debug.LogWarning("Failed to set model using UnityWebRequest: " + request.error);
235 | Debug.LogWarning("Trying with HttpWebRequest as fallback...");
236 |
237 | try
238 | {
239 | // Tell Stable Diffusion to use the specified model using an HTTP POST request
240 | HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
241 | httpWebRequest.ContentType = "application/json";
242 | httpWebRequest.Method = "POST";
243 |
244 | // add auth-header to request
245 | if (settings.useAuth && !settings.user.Equals("") && !settings.pass.Equals(""))
246 | {
247 | httpWebRequest.PreAuthenticate = true;
248 | byte[] bytesToEncode = Encoding.UTF8.GetBytes(settings.user + ":" + settings.pass);
249 | string encodedCredentials = Convert.ToBase64String(bytesToEncode);
250 | httpWebRequest.Headers.Add("Authorization", "Basic " + encodedCredentials);
251 | }
252 |
253 | // Write to the stream the JSON parameters to set a model
254 | using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
255 | {
256 | // Model to use
257 | SDOption sd = new SDOption();
258 | sd.sd_model_checkpoint = modelName;
259 |
260 | // Serialize into a JSON string
261 | string json = JsonConvert.SerializeObject(sd);
262 |
263 | // Send the POST request to the server
264 | streamWriter.Write(json);
265 | Debug.Log("Sent JSON: " + json);
266 | }
267 |
268 | // Get the response of the server
269 | var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
270 | using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
271 | {
272 | string result = streamReader.ReadToEnd();
273 | Debug.Log("Model set successfully. Response: " + result);
274 | }
275 | }
276 | catch (WebException e)
277 | {
278 | Debug.LogError("Error setting model: " + e.Message);
279 |
280 | // Try one more time with alternate endpoint
281 | if (url.Contains("/sdapi/v1/options"))
282 | {
283 | string alternateUrl = settings.StableDiffusionServerURL + "/api/options";
284 | Debug.LogWarning("Trying alternate options API: " + alternateUrl);
285 |
286 | // We can't yield inside a catch block, so let's use a flag
287 | Debug.LogWarning("Please try again if this fails - we can't properly retry in a catch block");
288 |
289 | // Try launching the alternate method
290 | StartCoroutine(TrySetModelWithAlternateAPI(modelName, alternateUrl));
291 | }
292 | }
293 | }
294 |
295 | ///
296 | /// Helper method to try setting a model with an alternate API endpoint
297 | ///
298 | private IEnumerator TrySetModelWithAlternateAPI(string modelName, string alternateUrl)
299 | {
300 | UnityWebRequest altRequest = new UnityWebRequest(alternateUrl, "POST");
301 | altRequest.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
302 | altRequest.uploadHandler = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(
303 | JsonConvert.SerializeObject(new SDOption { sd_model_checkpoint = modelName })));
304 | altRequest.SetRequestHeader("Content-Type", "application/json");
305 |
306 | if (settings.useAuth && !settings.user.Equals("") && !settings.pass.Equals(""))
307 | {
308 | byte[] bytesToEncode = Encoding.UTF8.GetBytes(settings.user + ":" + settings.pass);
309 | string encodedCredentials = Convert.ToBase64String(bytesToEncode);
310 | altRequest.SetRequestHeader("Authorization", "Basic " + encodedCredentials);
311 | }
312 |
313 | yield return altRequest.SendWebRequest();
314 |
315 | if (altRequest.result == UnityWebRequest.Result.Success)
316 | {
317 | Debug.Log("Model successfully set to: " + modelName + " using alternate API");
318 | }
319 | else
320 | {
321 | Debug.LogError("All attempts to set model failed. Make sure Stable Diffusion WebUI is running with '--api' flag.");
322 | }
323 | }
324 |
325 | }
326 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/StableDiffusionConfiguration.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1c93d797f0c71fa4ebd6ac191e533b14
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/StableDiffusionGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Newtonsoft.Json;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 | using System.Net;
6 | using System.Text;
7 | using UnityEditor;
8 | using UnityEngine;
9 | using UnityEngine.Networking;
10 |
11 | public class StableDiffusionGenerator : MonoBehaviour
12 | {
13 | static protected StableDiffusionConfiguration sdc = null;
14 | private Coroutine _updateProgressRunning = null;
15 |
16 | ///
17 | /// Update a generation progress bar
18 | ///
19 | protected void UpdateGenerationProgress()
20 | {
21 | #if UNITY_EDITOR
22 | if (_updateProgressRunning != null) return;
23 | _updateProgressRunning = StartCoroutine(UpdateGenerationProgressCor());
24 | #endif
25 | }
26 |
27 | private IEnumerator UpdateGenerationProgressCor()
28 | {
29 | #if UNITY_EDITOR
30 | // Stable diffusion API url for getting progress
31 | string url = sdc.settings.StableDiffusionServerURL + sdc.settings.ProgressAPI;
32 | float progress = 0;
33 |
34 | using (UnityWebRequest request = UnityWebRequest.Get(url))
35 | {
36 | request.SetRequestHeader("Content-Type", "application/json");
37 |
38 | yield return request.SendWebRequest();
39 |
40 | if (request.result != UnityWebRequest.Result.Success)
41 | {
42 | Debug.LogWarning("Failed to get progress: " + request.error);
43 | EditorUtility.DisplayProgressBar("Generation in progress", "Progress unknown...", 0.5f);
44 | }
45 | else
46 | {
47 | try
48 | {
49 | // Deserialize the response to a class
50 | SDProgress sdp = JsonConvert.DeserializeObject(request.downloadHandler.text);
51 | progress = sdp.progress;
52 |
53 | EditorUtility.DisplayProgressBar("Generation in progress", (progress*100).ToString("F1") + "%", progress);
54 | }
55 | catch (Exception e)
56 | {
57 | Debug.LogWarning("Error parsing progress: " + e.Message);
58 | EditorUtility.DisplayProgressBar("Generation in progress", "Progress unknown...", 0.5f);
59 | }
60 | }
61 | }
62 |
63 | _updateProgressRunning = null;
64 | #endif
65 | yield return null;
66 | }
67 |
68 | ///
69 | /// Update a generation progress bar with auth
70 | ///
71 | protected void UpdateGenerationProgressWithAuth()
72 | {
73 | #if UNITY_EDITOR
74 | if (_updateProgressRunning != null) return;
75 | _updateProgressRunning = StartCoroutine(UpdateGenerationProgressWithAuthCor());
76 | #endif
77 | }
78 |
79 | private IEnumerator UpdateGenerationProgressWithAuthCor()
80 | {
81 | // Stable diffusion API url for setting a model
82 | string url = sdc.settings.StableDiffusionServerURL + sdc.settings.ProgressAPI;
83 | float progress = 0;
84 |
85 | using (UnityWebRequest modelInfoRequest = UnityWebRequest.Get(url))
86 | {
87 | byte[] bytesToEncode = Encoding.UTF8.GetBytes(sdc.settings.user + ":" + sdc.settings.pass);
88 | string encodedText = Convert.ToBase64String(bytesToEncode);
89 |
90 | modelInfoRequest.SetRequestHeader("Authorization", "Basic " + encodedText);
91 | yield return modelInfoRequest.SendWebRequest();
92 |
93 | // Deserialize the response to a class
94 | SDProgress sdp = JsonConvert.DeserializeObject(modelInfoRequest.downloadHandler.text);
95 | progress = sdp.progress;
96 |
97 | EditorUtility.DisplayProgressBar("Generation in progress", progress * 100 + "%", progress);
98 | }
99 |
100 | _updateProgressRunning = null;
101 | yield return null;
102 | }
103 |
104 | ///
105 | /// Find all the game objects that contains a certain component type.
106 | ///
107 | /// Type of component to search for
108 | /// Game object for which to search it's children
109 | /// The game object must be active (true) or can also be not active (false)
110 | /// Array of game object found, all of which containing a component of the specified type
111 | public static T[] FindInChildrenAll(GameObject g, bool active = true) where T : class
112 | {
113 | List list = new List();
114 |
115 | // Search in all the children of the specified game object
116 | foreach (Transform t in g.transform)
117 | {
118 | // GameObject has no children, skip it
119 | if (t == null)
120 | continue;
121 |
122 | if (active && !t.gameObject.activeSelf)
123 | continue;
124 |
125 | // Found one, check component
126 | T comp = t.GetComponent();
127 | if (comp != null && comp.ToString() != "null")
128 | list.Add(comp);
129 |
130 | // Recursively search into the children of this game object
131 | T[] compo = FindInChildrenAll(t.gameObject);
132 | if (compo != null && compo.Length > 0)
133 | {
134 | foreach (T tt in compo)
135 | list.Add(tt);
136 | }
137 | }
138 |
139 | // Not found, return null
140 | return list.ToArray();
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/StableDiffusionGenerator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7caf765866d952142b01773800178250
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/StableDiffusionImage2Image.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net;
7 | using UnityEngine;
8 | using System.Linq;
9 | using System.Text;
10 | using UnityEngine.UI;
11 | using UnityEngine.Networking;
12 | using System.Threading.Tasks;
13 | using Math = System.Math;
14 |
15 | #if UNITY_EDITOR
16 | using UnityEditor;
17 | using UnityEditor.SceneManagement;
18 | #endif
19 |
20 | ///
21 | /// Component to help generate a UI Image or RawImage using Stable Diffusion via Img2Img.
22 | ///
23 | [ExecuteAlways]
24 | public class StableDiffusionImage2Image: StableDiffusionGenerator
25 | {
26 | [ReadOnly]
27 | public string guid = "";
28 |
29 | public Texture2D inputTexture;
30 | public string prompt;
31 | public string negativePrompt;
32 |
33 | ///
34 | /// List of samplers to display as Drop-Down in the inspector
35 | ///
36 | [SerializeField]
37 | public string[] samplersList
38 | {
39 | get
40 | {
41 | if (sdc == null)
42 | sdc = GameObject.FindAnyObjectByType();
43 | return sdc.samplers;
44 | }
45 | }
46 | ///
47 | /// Actual sampler selected in the drop-down list
48 | ///
49 | [HideInInspector]
50 | public int selectedSampler = 0;
51 |
52 | public int width = 512;
53 | public int height = 512;
54 | public int steps = 50;
55 | public float cfgScale = 7;
56 | public long seed = -1;
57 |
58 | public long generatedSeed = -1;
59 |
60 | string filename = "";
61 |
62 |
63 |
64 | ///
65 | /// List of models to display as Drop-Down in the inspector
66 | ///
67 | [SerializeField]
68 | public string[] modelsList
69 | {
70 | get
71 | {
72 | if (sdc == null)
73 | sdc = GameObject.FindAnyObjectByType();
74 | return sdc.modelNames;
75 | }
76 | }
77 | ///
78 | /// Actual model selected in the drop-down list
79 | ///
80 | [HideInInspector]
81 | public int selectedModel = 0;
82 |
83 |
84 | ///
85 | /// On Awake, fill the properties with default values from the selected settings.
86 | ///
87 | void Awake()
88 | {
89 | #if UNITY_EDITOR
90 | if (width < 0 || height < 0)
91 | {
92 | StableDiffusionConfiguration sdc = GameObject.FindAnyObjectByType();
93 | if (sdc != null)
94 | {
95 | SDSettings settings = sdc.settings;
96 | if (settings != null)
97 | {
98 |
99 | width = settings.width;
100 | height = settings.height;
101 | steps = settings.steps;
102 | cfgScale = settings.cfgScale;
103 | seed = settings.seed;
104 | return;
105 | }
106 | }
107 |
108 | width = 512;
109 | height = 512;
110 | steps = 50;
111 | cfgScale = 7;
112 | seed = -1;
113 | }
114 | #endif
115 | }
116 |
117 |
118 | void Update()
119 | {
120 | #if UNITY_EDITOR
121 | // Clamp image dimensions values between 128 and 2048 pixels
122 | if (width < 128) width = 128;
123 | if (height < 128) height = 128;
124 | if (width > 2048) width = 2048;
125 | if (height > 2048) height = 2048;
126 |
127 | // If not setup already, generate a GUID (Global Unique Identifier)
128 | if (guid == "")
129 | guid = Guid.NewGuid().ToString();
130 | #endif
131 | }
132 |
133 | // Internally keep tracking if we are currently generating (prevent re-entry)
134 | bool generating = false;
135 |
136 | ///
137 | /// Callback function for the inspector Generate button.
138 | ///
139 | public void Generate()
140 | {
141 | // Start generation asynchronously
142 | if (!generating && !string.IsNullOrEmpty(prompt) && inputTexture)
143 | {
144 | if (!inputTexture.isReadable)
145 | {
146 | Debug.LogError($"Input Image {inputTexture.name} isn't readable. Go to texture import settings and tick the Read/Write box", this);
147 | return;
148 | }
149 | StartCoroutine(GenerateAsync());
150 | }
151 | }
152 |
153 | ///
154 | /// Setup the output path and filename for image generation
155 | ///
156 | void SetupFolders()
157 | {
158 | // Get the configuration settings
159 | if (sdc == null)
160 | sdc = GameObject.FindAnyObjectByType();
161 |
162 | try
163 | {
164 | // Determine output path
165 | string root = Application.dataPath + sdc.settings.OutputFolder;
166 | if (root == "" || !Directory.Exists(root))
167 | root = Application.streamingAssetsPath;
168 | string mat = Path.Combine(root, "SDImages");
169 | filename = Path.Combine(mat, guid + ".png");
170 |
171 | // If folders not already exists, create them
172 | if (!Directory.Exists(root))
173 | Directory.CreateDirectory(root);
174 | if (!Directory.Exists(mat))
175 | Directory.CreateDirectory(mat);
176 |
177 | // If the file already exists, delete it
178 | if (File.Exists(filename))
179 | File.Delete(filename);
180 | }
181 | catch (Exception e)
182 | {
183 | Debug.LogError(e.Message + "\n\n" + e.StackTrace);
184 | }
185 | }
186 |
187 | IEnumerator GenerateAsync()
188 | {
189 | generating = true;
190 |
191 | SetupFolders();
192 |
193 | // Set the model parameters
194 | yield return sdc.SetModelAsync(modelsList[selectedModel]);
195 |
196 | // Generate the image using UnityWebRequest for better compatibility with cloud-hosted services
197 | string url = sdc.settings.StableDiffusionServerURL + sdc.settings.ImageToImageAPI;
198 | Debug.Log("Sending request to: " + url);
199 |
200 | // Prepare the request data
201 | byte[] inputImgBytes = inputTexture.EncodeToPNG();
202 | string inputImgString = Convert.ToBase64String(inputImgBytes);
203 |
204 | SDParamsInImg2Img sd = new SDParamsInImg2Img();
205 | sd.init_images = new string[] { inputImgString };
206 | sd.prompt = prompt;
207 | sd.negative_prompt = negativePrompt;
208 | sd.steps = steps;
209 | sd.cfg_scale = cfgScale;
210 | sd.width = width;
211 | sd.height = height;
212 | sd.seed = seed;
213 | sd.tiling = false;
214 |
215 | if (selectedSampler >= 0 && selectedSampler < samplersList.Length)
216 | sd.sampler_name = samplersList[selectedSampler];
217 |
218 | // Serialize the input parameters
219 | string jsonData = JsonConvert.SerializeObject(sd);
220 | Debug.Log("Sending JSON data (truncated): " + jsonData.Substring(0, Math.Min(100, jsonData.Length)) + "...");
221 |
222 | // Create the request
223 | UnityWebRequest request = new UnityWebRequest(url, "POST");
224 | request.downloadHandler = new DownloadHandlerBuffer();
225 | request.uploadHandler = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(jsonData));
226 | request.SetRequestHeader("Content-Type", "application/json");
227 |
228 | // Add authentication if needed
229 | if (sdc.settings.useAuth && !sdc.settings.user.Equals("") && !sdc.settings.pass.Equals(""))
230 | {
231 | byte[] bytesToEncode = Encoding.UTF8.GetBytes(sdc.settings.user + ":" + sdc.settings.pass);
232 | string encodedCredentials = Convert.ToBase64String(bytesToEncode);
233 | request.SetRequestHeader("Authorization", "Basic " + encodedCredentials);
234 | }
235 |
236 | // Send the request
237 | request.SendWebRequest();
238 |
239 | // Wait for the request to complete while showing progress
240 | while (!request.isDone)
241 | {
242 | if (sdc.settings.useAuth && !sdc.settings.user.Equals("") && !sdc.settings.pass.Equals(""))
243 | UpdateGenerationProgressWithAuth();
244 | else
245 | UpdateGenerationProgress();
246 |
247 | yield return new WaitForSeconds(0.5f);
248 | }
249 |
250 | // Check if the request was successful
251 | if (request.result != UnityWebRequest.Result.Success)
252 | {
253 | Debug.LogError("Request error: " + request.error);
254 | Debug.LogError("Response code: " + request.responseCode);
255 | Debug.LogError("Response: " + request.downloadHandler.text);
256 |
257 | if (request.responseCode == 405)
258 | {
259 | Debug.LogError("405 Method Not Allowed - This is common with RunPod. Make sure you launched with --api flag and check your firewall/proxy settings.");
260 | Debug.LogError("For RunPod, you might need to configure CORS settings or use their API proxy.");
261 | }
262 |
263 | generating = false;
264 | #if UNITY_EDITOR
265 | EditorUtility.ClearProgressBar();
266 | #endif
267 | yield break;
268 | }
269 |
270 | string responseText = request.downloadHandler.text;
271 | Debug.Log("Response received: " + responseText.Substring(0, Math.Min(100, responseText.Length)) + "...");
272 |
273 | try {
274 | // Deserialize the JSON string into a data structure
275 | SDResponseImg2Img json = JsonConvert.DeserializeObject(responseText);
276 |
277 | // If no image, there was probably an error so abort
278 | if (json.images == null || json.images.Length == 0)
279 | {
280 | Debug.LogError("No image was returned by the server. Verify that the server is correctly setup.");
281 | Debug.LogError("Full response: " + responseText);
282 |
283 | generating = false;
284 | #if UNITY_EDITOR
285 | EditorUtility.ClearProgressBar();
286 | #endif
287 | yield break;
288 | }
289 |
290 | // Decode the image from Base64 string into an array of bytes
291 | byte[] imageData = Convert.FromBase64String(json.images[0]);
292 |
293 | // Write it in the specified project output folder
294 | WriteImageFile(imageData, filename);
295 |
296 | // Read back the image into a texture
297 | if (File.Exists(filename))
298 | {
299 | Texture2D texture = new Texture2D(2, 2);
300 | texture.LoadImage(imageData);
301 | texture.Apply();
302 |
303 | LoadIntoImage(texture);
304 | }
305 |
306 | // Read the generation info back (only seed should have changed, as the generation picked a particular seed)
307 | if (json.info != "")
308 | {
309 | SDParamsOutTxt2Img info = JsonConvert.DeserializeObject(json.info);
310 |
311 | // Read the seed that was used by Stable Diffusion to generate this result
312 | generatedSeed = info.seed;
313 | }
314 | }
315 | catch (Exception e)
316 | {
317 | Debug.LogError("Error processing response: " + e.Message);
318 | Debug.LogError("Stack trace: " + e.StackTrace);
319 | Debug.LogError("Response was: " + responseText);
320 | }
321 |
322 | #if UNITY_EDITOR
323 | EditorUtility.ClearProgressBar();
324 | #endif
325 | generating = false;
326 | yield return null;
327 | }
328 |
329 | ///
330 | /// Helper method to write image data to file without using yield within a try block
331 | ///
332 | /// Image data as byte array
333 | /// Path to write the file
334 | private void WriteImageFile(byte[] imageData, string filepath)
335 | {
336 | try
337 | {
338 | using (FileStream imageFile = new FileStream(filepath, FileMode.Create))
339 | {
340 | #if UNITY_EDITOR
341 | AssetDatabase.StartAssetEditing();
342 | #endif
343 | imageFile.Write(imageData, 0, imageData.Length);
344 | imageFile.Flush();
345 | #if UNITY_EDITOR
346 | AssetDatabase.StopAssetEditing();
347 | AssetDatabase.SaveAssets();
348 | #endif
349 | }
350 | }
351 | catch (Exception e)
352 | {
353 | Debug.LogError("Error writing image file: " + e.Message);
354 | }
355 | }
356 |
357 | ///
358 | /// Load the texture into an Image or RawImage.
359 | ///
360 | /// Texture to setup
361 | void LoadIntoImage(Texture2D texture)
362 | {
363 | try
364 | {
365 | // Find the image component
366 | Image im = GetComponent();
367 | if (im != null)
368 | {
369 | // Create a new Sprite from the loaded image
370 | Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
371 |
372 | // Set the sprite as the source for the UI Image
373 | im.sprite = sprite;
374 | }
375 | // If no image found, try to find a RawImage component
376 | else
377 | {
378 | RawImage rim = GetComponent();
379 | if (rim != null)
380 | {
381 | rim.texture = texture;
382 | }
383 | }
384 |
385 | #if UNITY_EDITOR
386 | if (!Application.isPlaying)
387 | {
388 | // Force Unity inspector to refresh with new asset
389 | AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
390 | EditorApplication.QueuePlayerLoopUpdate();
391 | EditorSceneManager.MarkAllScenesDirty();
392 | EditorUtility.RequestScriptReload();
393 | }
394 | #endif
395 | }
396 | catch (Exception e)
397 | {
398 | Debug.LogError(e.Message + "\n\n" + e.StackTrace);
399 | }
400 | }
401 | }
402 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/StableDiffusionImage2Image.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f255497c431e7fc43ae59be84eb79cdd
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/StableDiffusionImage2Material.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net;
7 | using UnityEngine;
8 | using System.Threading.Tasks;
9 |
10 | #if UNITY_EDITOR
11 | using UnityEditor;
12 | using UnityEditor.SceneManagement;
13 | #endif
14 |
15 | ///
16 | /// Component to help generate a Material Texture using Stable Diffusion.
17 | ///
18 | [ExecuteAlways]
19 | public class StableDiffusionImage2Material : StableDiffusionGenerator
20 | {
21 | [ReadOnly]
22 | public string guid = "";
23 |
24 | public string prompt;
25 | public string negativePrompt;
26 |
27 | ///
28 | /// List of samplers to display as Drop-Down in the inspector
29 | ///
30 | [SerializeField]
31 | public string[] samplersList
32 | {
33 | get
34 | {
35 | if (sdc == null)
36 | sdc = GameObject.FindAnyObjectByType();
37 | return sdc.samplers;
38 | }
39 | }
40 | ///
41 | /// Actual sampler selected in the drop-down list
42 | ///
43 | [HideInInspector]
44 | public int selectedSampler = 0;
45 |
46 | public int width = -1;
47 | public int height = -1;
48 | public int steps = 0;
49 | public float cfgScale = 0;
50 | public long seed = -1;
51 |
52 | public long generatedSeed = -1;
53 |
54 | public bool tiling = true;
55 | [Range(1, 100)]
56 | public int tilingX = 1;
57 | [Range(1, 100)]
58 | public int tilingY = 1;
59 | [Range(0, 1)]
60 | public float metallic = 0.1f;
61 | [Range(0, 1)]
62 | public float smoothness = 0.5f;
63 |
64 | [Range(0, 1)]
65 | public float denoising_strength = 0.65f;
66 |
67 | public bool generateNormalMap = true;
68 | [Range(0, 100)]
69 | public float normalMapStrength = 0.5f;
70 |
71 | string filename = "";
72 |
73 | private Texture2D generatedTexture = null;
74 | private Texture2D generatedNormal = null;
75 |
76 | private Texture inputTexture;
77 |
78 | ///
79 | /// List of models to display as Drop-Down in the inspector
80 | ///
81 | [SerializeField]
82 | public string[] modelsList
83 | {
84 | get
85 | {
86 | if (sdc == null)
87 | sdc = GameObject.FindAnyObjectByType();
88 | return sdc.modelNames;
89 | }
90 | }
91 | ///
92 | /// Actual model selected in the drop-down list
93 | ///
94 | [HideInInspector]
95 | public int selectedModel = 0;
96 |
97 |
98 | public bool applyRecursively = true;
99 |
100 |
101 | ///
102 | /// On Awake, fill the properties with default values from the selected settings.
103 | ///
104 | void Awake()
105 | {
106 | #if UNITY_EDITOR
107 | if (width < 0 || height < 0)
108 | {
109 | StableDiffusionConfiguration sdc = GameObject.FindAnyObjectByType();
110 | if (sdc != null)
111 | {
112 | SDSettings settings = sdc.settings;
113 | if (settings != null)
114 | {
115 | width = settings.width;
116 | height = settings.height;
117 | steps = settings.steps;
118 | cfgScale = settings.cfgScale;
119 | seed = settings.seed;
120 | return;
121 | }
122 | }
123 |
124 | width = 512;
125 | height = 512;
126 | steps = 50;
127 | cfgScale = 7;
128 | seed = -1;
129 | }
130 | #endif
131 | }
132 |
133 | private void Start()
134 | {
135 | #if UNITY_EDITOR
136 | EditorUtility.ClearProgressBar();
137 | #endif
138 | }
139 |
140 |
141 | ///
142 | /// Get the mesh renderer in this object, or in childrens if allowed.
143 | ///
144 | /// The first mesh renderer found in the hierarchy at this level or in the children
145 | MeshRenderer GetMeshRenderer()
146 | {
147 | MeshRenderer mr = GetComponent();
148 | if (mr == null)
149 | {
150 | if (!applyRecursively)
151 | return null;
152 |
153 | MeshRenderer[] mrs = FindInChildrenAll(this.gameObject);
154 | if (mrs == null || mrs.Length == 0)
155 | return null;
156 |
157 | mr = mrs[0];
158 | }
159 |
160 | return mr;
161 | }
162 |
163 | // Keep track of material properties value, to detect if the user changes them on the fly, from the inspector
164 | float _normalMapStrength = -1;
165 | int _tilingX = -1;
166 | int _tilingY = -1;
167 | float _metallic = -1;
168 | float _smoothness = -1;
169 |
170 | ///
171 | /// Loop update
172 | ///
173 | void Update()
174 | {
175 | #if UNITY_EDITOR
176 | // Clamp image dimensions values between 128 and 2048 pixels
177 | if (width < 128) width = 128;
178 | if (height < 128) height = 128;
179 | if (width > 2048) width = 2048;
180 | if (height > 2048) height = 2048;
181 |
182 | // If not setup already, generate a GUID (Global Unique Identifier)
183 | if (guid == "")
184 | guid = Guid.NewGuid().ToString();
185 |
186 | // Update normal map strength whenever the user modifies it in the inspector
187 | if (_normalMapStrength != normalMapStrength)
188 | {
189 | MeshRenderer mr = GetMeshRenderer();
190 | if (mr != null)
191 | mr.sharedMaterial.SetFloat("_BumpScale", normalMapStrength);
192 |
193 | UpdateMaterialProperties();
194 |
195 | _normalMapStrength = normalMapStrength;
196 | }
197 |
198 | // Update tilling, metallic and smoothness properties whenever the user modifies them in the inspector
199 | if (_tilingX != tilingX || _tilingY != tilingY || _metallic != metallic || _smoothness != smoothness)
200 | {
201 | UpdateMaterialProperties();
202 |
203 | _tilingX = tilingX;
204 | _tilingY = tilingY;
205 | _metallic = metallic;
206 | _smoothness = smoothness;
207 | }
208 | #endif
209 | }
210 |
211 |
212 | // Internally keep tracking if we are currently generating (prevent re-entry)
213 | bool generating = false;
214 |
215 | ///
216 | /// Callback function for the inspector Generate button.
217 | ///
218 | public void Generate()
219 | {
220 | // Start generation asynchronously
221 | if (!generating && !string.IsNullOrEmpty(prompt))
222 | {
223 | StartCoroutine(GenerateAsync());
224 | }
225 | }
226 |
227 |
228 | ///
229 | /// Setup the output path and filename for image generation
230 | ///
231 | void SetupFolders()
232 | {
233 | // Get the configuration settings
234 | if (sdc == null)
235 | sdc = GameObject.FindAnyObjectByType();
236 |
237 | try
238 | {
239 | // Determine output path
240 | string root = Application.dataPath + sdc.settings.OutputFolder;
241 | if (root == "" || !Directory.Exists(root))
242 | root = Application.streamingAssetsPath;
243 | string mat = Path.Combine(root, "SDMaterials");
244 | filename = Path.Combine(mat, guid + ".png");
245 |
246 | // If folders not already exists, create them
247 | if (!Directory.Exists(root))
248 | Directory.CreateDirectory(root);
249 | if (!Directory.Exists(mat))
250 | Directory.CreateDirectory(mat);
251 |
252 | // If the file already exists, delete it
253 | if (File.Exists(filename))
254 | File.Delete(filename);
255 | }
256 | catch (Exception e)
257 | {
258 | Debug.LogError(e.Message + "\n\n" + e.StackTrace);
259 | }
260 | }
261 |
262 |
263 | ///
264 | /// Request an image generation to the Stable Diffusion server, asynchronously.
265 | ///
266 | ///
267 | IEnumerator GenerateAsync()
268 | {
269 | generating = true;
270 |
271 | SetupFolders();
272 |
273 | // Set the model parameters
274 | yield return sdc.SetModelAsync(modelsList[selectedModel]);
275 |
276 | // Generate the image
277 | HttpWebRequest httpWebRequest = null;
278 |
279 | MeshRenderer mr = GetMeshRenderer();
280 | inputTexture = mr.sharedMaterial.mainTexture;
281 | Texture2D inputTexture2D = (Texture2D)inputTexture;
282 |
283 | try
284 | {
285 | // Make a HTTP POST request to the Stable Diffusion server
286 | httpWebRequest = (HttpWebRequest)WebRequest.Create(sdc.settings.StableDiffusionServerURL + sdc.settings.ImageToImageAPI);
287 | httpWebRequest.ContentType = "application/json";
288 | httpWebRequest.Method = "POST";
289 |
290 | // Send the generation parameters along with the POST request
291 | using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
292 | {
293 | byte[] inputImgBytes = inputTexture2D.EncodeToPNG();
294 | string inputImgString = Convert.ToBase64String(inputImgBytes);
295 |
296 | SDParamsInImg2Img sd = new SDParamsInImg2Img();
297 | sd.init_images = new string[] { inputImgString };
298 | sd.prompt = prompt;
299 | sd.negative_prompt = negativePrompt;
300 | sd.steps = steps;
301 | sd.cfg_scale = cfgScale;
302 | sd.width = width;
303 | sd.height = height;
304 | sd.seed = seed;
305 | sd.tiling = false;
306 | sd.denoising_strength = denoising_strength;
307 |
308 | if (selectedSampler >= 0 && selectedSampler < samplersList.Length)
309 | sd.sampler_name = samplersList[selectedSampler];
310 |
311 | // Serialize the input parameters
312 | string json = JsonConvert.SerializeObject(sd);
313 |
314 | // Send to the server
315 | streamWriter.Write(json);
316 | }
317 | }
318 | catch (Exception e)
319 | {
320 | Debug.LogError(e.Message + "\n\n" + e.StackTrace);
321 | }
322 |
323 | // Read the output of generation
324 | if (httpWebRequest != null)
325 | {
326 | // Wait that the generation is complete before procedding
327 | Task t = httpWebRequest.GetResponseAsync();
328 | while (!t.IsCompleted)
329 | {
330 | UpdateGenerationProgress();
331 | yield return new WaitForSeconds(0.5f);
332 | }
333 | var httpResponse = t.Result;
334 |
335 | // Get response from the server
336 | using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
337 | {
338 | // Decode the response as a JSON string
339 | string result = streamReader.ReadToEnd();
340 |
341 | // Deserialize the JSON string into a data structure
342 | SDResponseTxt2Img json = JsonConvert.DeserializeObject(result);
343 |
344 | // If no image, there was probably an error so abort
345 | if (json.images == null || json.images.Length == 0)
346 | {
347 | Debug.LogError("No image was return by the server. This should not happen. Verify that the server is correctly setup.");
348 |
349 | generating = false;
350 | #if UNITY_EDITOR
351 | EditorUtility.ClearProgressBar();
352 | #endif
353 | yield break;
354 | }
355 |
356 | // Decode the image from Base64 string into an array of bytes
357 | byte[] imageData = Convert.FromBase64String(json.images[0]);
358 |
359 | // Write it in the specified project output folder
360 | using (FileStream imageFile = new FileStream(filename, FileMode.Create))
361 | {
362 | #if UNITY_EDITOR
363 | AssetDatabase.StartAssetEditing();
364 | #endif
365 | yield return imageFile.WriteAsync(imageData, 0, imageData.Length);
366 | #if UNITY_EDITOR
367 | AssetDatabase.StopAssetEditing();
368 | AssetDatabase.SaveAssets();
369 | #endif
370 | }
371 |
372 | try
373 | {
374 | // Read back the image into a texture
375 | if (File.Exists(filename))
376 | {
377 | Texture2D texture = new Texture2D(2, 2);
378 | texture.LoadImage(imageData);
379 | texture.Apply();
380 |
381 | LoadIntoMaterial(texture);
382 | }
383 |
384 | // Read the generation info back (only seed should have changed, as the generation picked a particular seed)
385 | if (json.info != "")
386 | {
387 | SDParamsOutTxt2Img info = JsonConvert.DeserializeObject(json.info);
388 |
389 | // Read the seed that was used by Stable Diffusion to generate this result
390 | generatedSeed = info.seed;
391 | }
392 | }
393 | catch (Exception e)
394 | {
395 | Debug.LogError(e.Message + "\n\n" + e.StackTrace);
396 | }
397 | }
398 | }
399 | #if UNITY_EDITOR
400 | EditorUtility.ClearProgressBar();
401 | #endif
402 | generating = false;
403 | yield return null;
404 | }
405 |
406 |
407 | ///
408 | /// Load the texture into a material.
409 | ///
410 | /// Texture to add to the material
411 | void LoadIntoMaterial(Texture2D texture)
412 | {
413 | try
414 | {
415 | MeshRenderer mr = GetMeshRenderer();
416 | if (mr == null)
417 | return;
418 |
419 | // Set the material to a default Standard material with a texture
420 | Shader standardShader = Shader.Find("Standard");
421 | mr.sharedMaterial = new Material(standardShader);
422 | mr.sharedMaterial.mainTexture = texture;
423 | generatedTexture = texture;
424 |
425 | // Apply the material to childrens if required
426 | if (applyRecursively)
427 | {
428 | MeshRenderer[] mrs = FindInChildrenAll(this.gameObject);
429 | foreach (MeshRenderer m in mrs)
430 | if (m != mr)
431 | {
432 | m.sharedMaterial = mr.sharedMaterial;
433 | }
434 | }
435 |
436 | // Generate the normal map
437 | GenerateNormalMap();
438 |
439 | // Force the assets and scene to refresh with new material
440 | #if UNITY_EDITOR
441 | if (!Application.isPlaying)
442 | {
443 | EditorUtility.SetDirty(generatedTexture);
444 | AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
445 | SceneView.RepaintAll();
446 | SceneView.FrameLastActiveSceneView();
447 | //SceneView.FocusWindowIfItsOpen(typeof(SceneView));
448 | EditorApplication.QueuePlayerLoopUpdate();
449 | EditorSceneManager.MarkAllScenesDirty();
450 | EditorUtility.RequestScriptReload();
451 | }
452 | #endif
453 | }
454 | catch (Exception e)
455 | {
456 | Debug.LogError(e.Message + "\n\n" + e.StackTrace);
457 | }
458 | }
459 |
460 |
461 | ///
462 | /// Generate a normal map from the generated texture.
463 | ///
464 | public void GenerateNormalMap()
465 | {
466 | if (generatedTexture == null)
467 | return;
468 |
469 | try
470 | {
471 | MeshRenderer mr = GetMeshRenderer();
472 | if (mr == null)
473 | return;
474 |
475 | if (generateNormalMap)
476 | {
477 | generatedNormal = CreateNormalmap(generatedTexture, 20f);
478 | #if UNITY_EDITOR
479 | EditorUtility.SetDirty(generatedNormal);
480 | #endif
481 | }
482 | else
483 | generatedNormal = null;
484 |
485 | UpdateMaterialProperties();
486 | }
487 | catch (Exception e)
488 | {
489 | Debug.LogError(e.Message + "\n\n" + e.StackTrace);
490 | }
491 | }
492 |
493 |
494 | ///
495 | /// Update the material properties.
496 | /// Also apply to children if set to apply recursively.
497 | ///
498 | void UpdateMaterialProperties()
499 | {
500 | MeshRenderer mr = GetMeshRenderer();
501 | if (mr == null)
502 | return;
503 |
504 | // Apply tilling, metallic and smoothness
505 | mr.sharedMaterial.mainTextureScale = new Vector2(-tilingX, -tilingY);
506 | mr.sharedMaterial.SetFloat("_Metallic", metallic);
507 | mr.sharedMaterial.SetFloat("_Glossiness", smoothness);
508 |
509 | // Apply normal map if required
510 | if (generateNormalMap && generatedNormal != null)
511 | {
512 | mr.sharedMaterial.SetTexture("_BumpMap", generatedNormal);
513 | mr.sharedMaterial.SetFloat("_BumpScale", normalMapStrength);
514 | mr.sharedMaterial.EnableKeyword("_NORMALMAP");
515 | }
516 | // Disable normal map
517 | else
518 | {
519 | mr.sharedMaterial.SetTexture("_BumpMap", null);
520 | mr.sharedMaterial.DisableKeyword("_NORMALMAP");
521 | }
522 |
523 | // Apply recursively if required
524 | if (applyRecursively)
525 | {
526 | MeshRenderer[] mrs = FindInChildrenAll(this.gameObject);
527 | foreach (MeshRenderer m in mrs)
528 | if (m != mr)
529 | {
530 | m.sharedMaterial = mr.sharedMaterial;
531 | }
532 | }
533 | }
534 |
535 |
536 | ///
537 | /// Create a Normal map based on the gradient in 3x3 surrounding neighborhood.
538 | /// Based on UnityCoder code: https://github.com/unitycoder/NormalMapFromTexture
539 | ///
540 | /// Normal map texture
541 | /// Source texture
542 | /// Normal map strength float (example: 1-20)
543 | public static Texture2D CreateNormalmap(Texture2D t, float normalStrength)
544 | {
545 | Color[] pixels = new Color[t.width * t.height];
546 | Texture2D texNormal = new Texture2D(t.width, t.height, TextureFormat.RGB24, false, false);
547 | Vector3 vScale = new Vector3(0.3333f, 0.3333f, 0.3333f);
548 |
549 | Color tc;
550 | for (int y = 0; y < t.height; y++)
551 | {
552 | for (int x = 0; x < t.width; x++)
553 | {
554 | tc = t.GetPixel(x - 1, y - 1); Vector3 cSampleNegXNegY = new Vector3(tc.r, tc.g, tc.g);
555 | tc = t.GetPixel(x - 0, y - 1); Vector3 cSampleZerXNegY = new Vector3(tc.r, tc.g, tc.g);
556 | tc = t.GetPixel(x + 1, y - 1); Vector3 cSamplePosXNegY = new Vector3(tc.r, tc.g, tc.g);
557 | tc = t.GetPixel(x - 1, y - 0); Vector3 cSampleNegXZerY = new Vector3(tc.r, tc.g, tc.g);
558 | tc = t.GetPixel(x + 1, y - 0); Vector3 cSamplePosXZerY = new Vector3(tc.r, tc.g, tc.g);
559 | tc = t.GetPixel(x - 1, y + 1); Vector3 cSampleNegXPosY = new Vector3(tc.r, tc.g, tc.g);
560 | tc = t.GetPixel(x - 0, y + 1); Vector3 cSampleZerXPosY = new Vector3(tc.r, tc.g, tc.g);
561 | tc = t.GetPixel(x + 1, y + 1); Vector3 cSamplePosXPosY = new Vector3(tc.r, tc.g, tc.g);
562 |
563 | float fSampleNegXNegY = Vector3.Dot(cSampleNegXNegY, vScale);
564 | float fSampleZerXNegY = Vector3.Dot(cSampleZerXNegY, vScale);
565 | float fSamplePosXNegY = Vector3.Dot(cSamplePosXNegY, vScale);
566 | float fSampleNegXZerY = Vector3.Dot(cSampleNegXZerY, vScale);
567 | float fSamplePosXZerY = Vector3.Dot(cSamplePosXZerY, vScale);
568 | float fSampleNegXPosY = Vector3.Dot(cSampleNegXPosY, vScale);
569 | float fSampleZerXPosY = Vector3.Dot(cSampleZerXPosY, vScale);
570 | float fSamplePosXPosY = Vector3.Dot(cSamplePosXPosY, vScale);
571 |
572 | float edgeX = (fSampleNegXNegY - fSamplePosXNegY) * 0.25f + (fSampleNegXZerY - fSamplePosXZerY) * 0.5f + (fSampleNegXPosY - fSamplePosXPosY) * 0.25f;
573 | float edgeY = (fSampleNegXNegY - fSampleNegXPosY) * 0.25f + (fSampleZerXNegY - fSampleZerXPosY) * 0.5f + (fSamplePosXNegY - fSamplePosXPosY) * 0.25f;
574 |
575 | Vector2 vEdge = new Vector2(edgeX, edgeY) * normalStrength;
576 | Vector3 norm = new Vector3(vEdge.x, vEdge.y, 5.0f).normalized;
577 | Color c = new Color(norm.x * 0.5f + 0.5f, norm.y * 0.5f + 0.5f, norm.z * 0.5f + 0.5f, 1);
578 |
579 | pixels[x + y * t.width] = c;
580 | }
581 | }
582 |
583 | texNormal.SetPixels(pixels);
584 | texNormal.Apply();
585 |
586 | return texNormal;
587 | }
588 | }
589 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/StableDiffusionImage2Material.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c4dd48b2f3f63964b977880b6af538a8
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/StableDiffusionText2Image.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Net;
7 | using UnityEngine;
8 | using System.Linq;
9 | using System.Text;
10 | using UnityEngine.UI;
11 | using UnityEngine.Networking;
12 | using System.Threading.Tasks;
13 | using Math = System.Math;
14 |
15 | #if UNITY_EDITOR
16 | using UnityEditor;
17 | using UnityEditor.SceneManagement;
18 | #endif
19 |
20 | ///
21 | /// Component to help generate a UI Image or RawImage using Stable Diffusion.
22 | ///
23 | [ExecuteAlways]
24 | public class StableDiffusionText2Image : StableDiffusionGenerator
25 | {
26 | [ReadOnly]
27 | public string guid = "";
28 |
29 | public string prompt;
30 | public string negativePrompt;
31 |
32 | ///
33 | /// List of samplers to display as Drop-Down in the inspector
34 | ///
35 | [SerializeField]
36 | public string[] samplersList
37 | {
38 | get
39 | {
40 | if (sdc == null)
41 | sdc = GameObject.FindAnyObjectByType();
42 | return sdc.samplers;
43 | }
44 | }
45 | ///
46 | /// Actual sampler selected in the drop-down list
47 | ///
48 | [HideInInspector]
49 | public int selectedSampler = 0;
50 |
51 | public int width = 512;
52 | public int height = 512;
53 | public int steps = 90;
54 | public float cfgScale = 7;
55 | public long seed = -1;
56 |
57 | public long generatedSeed = -1;
58 |
59 | string filename = "";
60 |
61 |
62 |
63 | ///
64 | /// List of models to display as Drop-Down in the inspector
65 | ///
66 | [SerializeField]
67 | public string[] modelsList
68 | {
69 | get
70 | {
71 | if (sdc == null)
72 | sdc = GameObject.FindAnyObjectByType();
73 | return sdc.modelNames;
74 | }
75 | }
76 | ///
77 | /// Actual model selected in the drop-down list
78 | ///
79 | [HideInInspector]
80 | public int selectedModel = 0;
81 |
82 |
83 | ///
84 | /// On Awake, fill the properties with default values from the selected settings.
85 | ///
86 | void Awake()
87 | {
88 | #if UNITY_EDITOR
89 | if (width < 0 || height < 0)
90 | {
91 | StableDiffusionConfiguration sdc = GameObject.FindAnyObjectByType();
92 | if (sdc != null)
93 | {
94 | SDSettings settings = sdc.settings;
95 | if (settings != null)
96 | {
97 |
98 | width = settings.width;
99 | height = settings.height;
100 | steps = settings.steps;
101 | cfgScale = settings.cfgScale;
102 | seed = settings.seed;
103 | return;
104 | }
105 | }
106 |
107 | width = 512;
108 | height = 512;
109 | steps = 50;
110 | cfgScale = 7;
111 | seed = -1;
112 | }
113 | #endif
114 | }
115 |
116 |
117 | void Update()
118 | {
119 | #if UNITY_EDITOR
120 | // Clamp image dimensions values between 128 and 2048 pixels
121 | if (width < 128) width = 128;
122 | if (height < 128) height = 128;
123 | if (width > 2048) width = 2048;
124 | if (height > 2048) height = 2048;
125 |
126 | // If not setup already, generate a GUID (Global Unique Identifier)
127 | if (guid == "")
128 | guid = Guid.NewGuid().ToString();
129 | #endif
130 | }
131 |
132 | // Internally keep tracking if we are currently generating (prevent re-entry)
133 | bool generating = false;
134 |
135 | ///
136 | /// Callback function for the inspector Generate button.
137 | ///
138 | public void Generate()
139 | {
140 | // Start generation asynchronously
141 | if (!generating && !string.IsNullOrEmpty(prompt))
142 | {
143 | StartCoroutine(GenerateAsync());
144 | }
145 | }
146 |
147 | ///
148 | /// Setup the output path and filename for image generation
149 | ///
150 | void SetupFolders()
151 | {
152 | // Get the configuration settings
153 | if (sdc == null)
154 | sdc = GameObject.FindAnyObjectByType();
155 |
156 | try
157 | {
158 | // Determine output path
159 | string root = Application.dataPath + sdc.settings.OutputFolder;
160 | if (root == "" || !Directory.Exists(root))
161 | root = Application.streamingAssetsPath;
162 | string mat = Path.Combine(root, "SDImages");
163 | filename = Path.Combine(mat, guid + ".png");
164 |
165 | // If folders not already exists, create them
166 | if (!Directory.Exists(root))
167 | Directory.CreateDirectory(root);
168 | if (!Directory.Exists(mat))
169 | Directory.CreateDirectory(mat);
170 |
171 | // If the file already exists, delete it
172 | if (File.Exists(filename))
173 | File.Delete(filename);
174 | }
175 | catch (Exception e)
176 | {
177 | Debug.LogError(e.Message + "\n\n" + e.StackTrace);
178 | }
179 | }
180 |
181 | IEnumerator GenerateAsync()
182 | {
183 | generating = true;
184 |
185 | SetupFolders();
186 |
187 | // Set the model parameters
188 | yield return sdc.SetModelAsync(modelsList[selectedModel]);
189 |
190 | // Generate the image using UnityWebRequest for better compatibility with cloud-hosted services
191 | string url = sdc.settings.StableDiffusionServerURL + sdc.settings.TextToImageAPI;
192 | Debug.Log("Sending request to: " + url);
193 |
194 | // Prepare the request data
195 | SDParamsInTxt2Img sd = new SDParamsInTxt2Img();
196 | sd.prompt = prompt;
197 | sd.negative_prompt = negativePrompt;
198 | sd.steps = steps;
199 | sd.cfg_scale = cfgScale;
200 | sd.width = width;
201 | sd.height = height;
202 | sd.seed = seed;
203 | sd.tiling = false;
204 |
205 | if (selectedSampler >= 0 && selectedSampler < samplersList.Length)
206 | sd.sampler_name = samplersList[selectedSampler];
207 |
208 | // Serialize the input parameters
209 | string jsonData = JsonConvert.SerializeObject(sd);
210 | Debug.Log("Sending JSON data: " + jsonData);
211 |
212 | // Create the request
213 | UnityWebRequest request = new UnityWebRequest(url, "POST");
214 | request.downloadHandler = new DownloadHandlerBuffer();
215 | request.uploadHandler = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(jsonData));
216 | request.SetRequestHeader("Content-Type", "application/json");
217 |
218 | // Add authentication if needed
219 | if (sdc.settings.useAuth && !sdc.settings.user.Equals("") && !sdc.settings.pass.Equals(""))
220 | {
221 | byte[] bytesToEncode = Encoding.UTF8.GetBytes(sdc.settings.user + ":" + sdc.settings.pass);
222 | string encodedCredentials = Convert.ToBase64String(bytesToEncode);
223 | request.SetRequestHeader("Authorization", "Basic " + encodedCredentials);
224 | }
225 |
226 | // Send the request
227 | request.SendWebRequest();
228 |
229 | // Wait for the request to complete while showing progress
230 | while (!request.isDone)
231 | {
232 | if (sdc.settings.useAuth && !sdc.settings.user.Equals("") && !sdc.settings.pass.Equals(""))
233 | UpdateGenerationProgressWithAuth();
234 | else
235 | UpdateGenerationProgress();
236 |
237 | yield return new WaitForSeconds(0.5f);
238 | }
239 |
240 | // Check if the request was successful
241 | if (request.result != UnityWebRequest.Result.Success)
242 | {
243 | Debug.LogError("Request error: " + request.error);
244 | Debug.LogError("Response code: " + request.responseCode);
245 | Debug.LogError("Response: " + request.downloadHandler.text);
246 |
247 | if (request.responseCode == 405)
248 | {
249 | Debug.LogError("405 Method Not Allowed - This is common with RunPod. Make sure you launched with --api flag and check your firewall/proxy settings.");
250 | Debug.LogError("For RunPod, you might need to configure CORS settings or use their API proxy.");
251 | }
252 |
253 | generating = false;
254 | #if UNITY_EDITOR
255 | EditorUtility.ClearProgressBar();
256 | #endif
257 | yield break;
258 | }
259 |
260 | // Process the response
261 | try
262 | {
263 | string responseText = request.downloadHandler.text;
264 | Debug.Log("Response received: " + responseText.Substring(0, Math.Min(100, responseText.Length)) + "...");
265 |
266 | // Deserialize the JSON string into a data structure
267 | SDResponseTxt2Img json = JsonConvert.DeserializeObject(responseText);
268 |
269 | // If no image, there was probably an error so abort
270 | if (json.images == null || json.images.Length == 0)
271 | {
272 | Debug.LogError("No image was returned by the server. Verify that the server is correctly setup.");
273 | Debug.LogError("Full response: " + responseText);
274 |
275 | generating = false;
276 | #if UNITY_EDITOR
277 | EditorUtility.ClearProgressBar();
278 | #endif
279 | yield break;
280 | }
281 |
282 | // Decode the image from Base64 string into an array of bytes
283 | byte[] imageData = Convert.FromBase64String(json.images[0]);
284 |
285 | // Write it in the specified project output folder
286 | WriteImageFile(imageData, filename);
287 |
288 | // Read back the image into a texture
289 | if (File.Exists(filename))
290 | {
291 | Texture2D texture = new Texture2D(2, 2);
292 | texture.LoadImage(imageData);
293 | texture.Apply();
294 |
295 | LoadIntoImage(texture);
296 | }
297 |
298 | // Read the generation info back (only seed should have changed, as the generation picked a particular seed)
299 | if (json.info != "")
300 | {
301 | SDParamsOutTxt2Img info = JsonConvert.DeserializeObject(json.info);
302 |
303 | // Read the seed that was used by Stable Diffusion to generate this result
304 | generatedSeed = info.seed;
305 | }
306 | }
307 | catch (Exception e)
308 | {
309 | Debug.LogError("Error processing response: " + e.Message);
310 | Debug.LogError("Stack trace: " + e.StackTrace);
311 | Debug.LogError("Response was: " + request.downloadHandler.text);
312 | }
313 |
314 | #if UNITY_EDITOR
315 | EditorUtility.ClearProgressBar();
316 | #endif
317 | generating = false;
318 | yield return null;
319 | }
320 |
321 | ///
322 | /// Helper method to write image data to file without using yield within a try block
323 | ///
324 | /// Image data as byte array
325 | /// Path to write the file
326 | private void WriteImageFile(byte[] imageData, string filepath)
327 | {
328 | try
329 | {
330 | using (FileStream imageFile = new FileStream(filepath, FileMode.Create))
331 | {
332 | #if UNITY_EDITOR
333 | AssetDatabase.StartAssetEditing();
334 | #endif
335 | imageFile.Write(imageData, 0, imageData.Length);
336 | imageFile.Flush();
337 | #if UNITY_EDITOR
338 | AssetDatabase.StopAssetEditing();
339 | AssetDatabase.SaveAssets();
340 | #endif
341 | }
342 | }
343 | catch (Exception e)
344 | {
345 | Debug.LogError("Error writing image file: " + e.Message);
346 | }
347 | }
348 |
349 | ///
350 | /// Load the texture into an Image or RawImage.
351 | ///
352 | /// Texture to setup
353 | void LoadIntoImage(Texture2D texture)
354 | {
355 | try
356 | {
357 | // Find the image component
358 | Image im = GetComponent();
359 | if (im != null)
360 | {
361 | // Create a new Sprite from the loaded image
362 | Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
363 |
364 | // Set the sprite as the source for the UI Image
365 | im.sprite = sprite;
366 | }
367 | // If no image found, try to find a RawImage component
368 | else
369 | {
370 | RawImage rim = GetComponent();
371 | if (rim != null)
372 | {
373 | rim.texture = texture;
374 | }
375 | }
376 |
377 | #if UNITY_EDITOR
378 | if (!Application.isPlaying)
379 | {
380 | // Force Unity inspector to refresh with new asset
381 | AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
382 | EditorApplication.QueuePlayerLoopUpdate();
383 | EditorSceneManager.MarkAllScenesDirty();
384 | EditorUtility.RequestScriptReload();
385 | }
386 | #endif
387 | }
388 | catch (Exception e)
389 | {
390 | Debug.LogError(e.Message + "\n\n" + e.StackTrace);
391 | }
392 | }
393 | }
394 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/StableDiffusionText2Image.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0beed6a09923ca540b45e4a3f055325f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/StableDiffusionText2Material.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections;
4 | using System.IO;
5 | using System.Net;
6 | using System.Text;
7 | using UnityEngine;
8 | using UnityEngine.Networking;
9 | using System.Threading.Tasks;
10 | using Math = System.Math;
11 |
12 | #if UNITY_EDITOR
13 | using UnityEditor;
14 | using UnityEditor.SceneManagement;
15 | #endif
16 |
17 | ///
18 | /// Component to help generate a Material Texture using Stable Diffusion.
19 | ///
20 | [ExecuteAlways]
21 | public class StableDiffusionText2Material : StableDiffusionGenerator
22 | {
23 | [ReadOnly]
24 | public string guid = "";
25 |
26 | public string prompt;
27 | public string negativePrompt;
28 |
29 | ///
30 | /// List of samplers to display as Drop-Down in the inspector
31 | ///
32 | [SerializeField]
33 | public string[] samplersList
34 | {
35 | get
36 | {
37 | if (sdc == null)
38 | sdc = GameObject.FindAnyObjectByType();
39 | return sdc.samplers;
40 | }
41 | }
42 | ///
43 | /// Actual sampler selected in the drop-down list
44 | ///
45 | [HideInInspector]
46 | public int selectedSampler = 0;
47 |
48 | public int width = -1;
49 | public int height = -1;
50 | public int steps = 0;
51 | public float cfgScale = 0;
52 | public long seed = -1;
53 |
54 | public long generatedSeed = -1;
55 |
56 | public bool tiling = true;
57 | [Range(1, 100)]
58 | public int tilingX = 1;
59 | [Range(1, 100)]
60 | public int tilingY = 1;
61 | [Range(0, 1)]
62 | public float metallic = 0.1f;
63 | [Range(0, 1)]
64 | public float smoothness = 0.5f;
65 |
66 | public bool generateNormalMap = true;
67 | [Range(0, 10)]
68 | public float normalMapStrength = 0.5f;
69 |
70 | string filename = "";
71 |
72 | private Texture2D generatedTexture = null;
73 | private Texture2D generatedNormal = null;
74 |
75 | ///
76 | /// List of models to display as Drop-Down in the inspector
77 | ///
78 | [SerializeField]
79 | public string[] modelsList
80 | {
81 | get
82 | {
83 | if (sdc == null)
84 | sdc = GameObject.FindAnyObjectByType();
85 | return sdc.modelNames;
86 | }
87 | }
88 | ///
89 | /// Actual model selected in the drop-down list
90 | ///
91 | [HideInInspector]
92 | public int selectedModel = 0;
93 |
94 |
95 | public bool applyRecursively = true;
96 |
97 |
98 | ///
99 | /// On Awake, fill the properties with default values from the selected settings.
100 | ///
101 | void Awake()
102 | {
103 | #if UNITY_EDITOR
104 | if (width < 0 || height < 0)
105 | {
106 | StableDiffusionConfiguration sdc = GameObject.FindAnyObjectByType();
107 | if (sdc != null)
108 | {
109 | SDSettings settings = sdc.settings;
110 | if (settings != null)
111 | {
112 |
113 | width = settings.width;
114 | height = settings.height;
115 | steps = settings.steps;
116 | cfgScale = settings.cfgScale;
117 | seed = settings.seed;
118 | return;
119 | }
120 | }
121 |
122 | width = 512;
123 | height = 512;
124 | steps = 50;
125 | cfgScale = 7;
126 | seed = -1;
127 | }
128 | #endif
129 | }
130 |
131 | private void Start()
132 | {
133 | #if UNITY_EDITOR
134 | EditorUtility.ClearProgressBar();
135 | #endif
136 | }
137 |
138 |
139 | ///
140 | /// Get the mesh renderer in this object, or in childrens if allowed.
141 | ///
142 | /// The first mesh renderer found in the hierarchy at this level or in the children
143 | MeshRenderer GetMeshRenderer()
144 | {
145 | MeshRenderer mr = GetComponent();
146 | if (mr == null)
147 | {
148 | if (!applyRecursively)
149 | return null;
150 |
151 | MeshRenderer[] mrs = FindInChildrenAll(this.gameObject);
152 | if (mrs == null || mrs.Length == 0)
153 | return null;
154 |
155 | mr = mrs[0];
156 | }
157 |
158 | return mr;
159 | }
160 |
161 | // Keep track of material properties value, to detect if the user changes them on the fly, from the inspector
162 | float _normalMapStrength = -1;
163 | int _tilingX = -1;
164 | int _tilingY = -1;
165 | float _metallic = -1;
166 | float _smoothness = -1;
167 |
168 | ///
169 | /// Loop update
170 | ///
171 | void Update()
172 | {
173 | #if UNITY_EDITOR
174 | // Clamp image dimensions values between 128 and 2048 pixels
175 | if (width < 128) width = 128;
176 | if (height < 128) height = 128;
177 | if (width > 2048) width = 2048;
178 | if (height > 2048) height = 2048;
179 |
180 | // If not setup already, generate a GUID (Global Unique Identifier)
181 | if (guid == "")
182 | guid = Guid.NewGuid().ToString();
183 |
184 | // Update normal map strength whenever the user modifies it in the inspector
185 | if (_normalMapStrength != normalMapStrength)
186 | {
187 | MeshRenderer mr = GetMeshRenderer();
188 | if (mr != null)
189 | mr.sharedMaterial.SetFloat("_BumpScale", normalMapStrength);
190 |
191 | UpdateMaterialProperties();
192 |
193 | _normalMapStrength = normalMapStrength;
194 | }
195 |
196 | // Update tilling, metallic and smoothness properties whenever the user modifies them in the inspector
197 | if (_tilingX != tilingX || _tilingY != tilingY || _metallic != metallic || _smoothness != smoothness)
198 | {
199 | UpdateMaterialProperties();
200 |
201 | _tilingX = tilingX;
202 | _tilingY = tilingY;
203 | _metallic = metallic;
204 | _smoothness = smoothness;
205 | }
206 | #endif
207 | }
208 |
209 |
210 | // Internally keep tracking if we are currently generating (prevent re-entry)
211 | bool generating = false;
212 |
213 | ///
214 | /// Callback function for the inspector Generate button.
215 | ///
216 | public void Generate()
217 | {
218 | // Start generation asynchronously
219 | if (!generating && !string.IsNullOrEmpty(prompt))
220 | {
221 | StartCoroutine(GenerateAsync());
222 | }
223 | }
224 |
225 |
226 | ///
227 | /// Setup the output path and filename for image generation
228 | ///
229 | void SetupFolders()
230 | {
231 | // Get the configuration settings
232 | if (sdc == null)
233 | sdc = GameObject.FindAnyObjectByType();
234 |
235 | try
236 | {
237 | // Determine output path
238 | string root = Application.dataPath + sdc.settings.OutputFolder;
239 | if (root == "" || !Directory.Exists(root))
240 | root = Application.streamingAssetsPath;
241 | string mat = Path.Combine(root, "SDMaterials");
242 | filename = Path.Combine(mat, guid + ".png");
243 |
244 | // If folders not already exists, create them
245 | if (!Directory.Exists(root))
246 | Directory.CreateDirectory(root);
247 | if (!Directory.Exists(mat))
248 | Directory.CreateDirectory(mat);
249 |
250 | // If the file already exists, delete it
251 | if (File.Exists(filename))
252 | File.Delete(filename);
253 | }
254 | catch (Exception e)
255 | {
256 | Debug.LogError(e.Message + "\n\n" + e.StackTrace);
257 | }
258 | }
259 |
260 |
261 | ///
262 | /// Request an image generation to the Stable Diffusion server, asynchronously.
263 | ///
264 | ///
265 | IEnumerator GenerateAsync()
266 | {
267 | generating = true;
268 |
269 | SetupFolders();
270 |
271 | // Set the model parameters
272 | yield return sdc.SetModelAsync(modelsList[selectedModel]);
273 |
274 | // Generate the image using UnityWebRequest for better compatibility with cloud-hosted services
275 | string url = sdc.settings.StableDiffusionServerURL + sdc.settings.TextToImageAPI;
276 | Debug.Log("Sending request to: " + url);
277 |
278 | // Prepare the request data
279 | SDParamsInTxt2Img sd = new SDParamsInTxt2Img();
280 | sd.prompt = prompt;
281 | sd.negative_prompt = negativePrompt;
282 | sd.steps = steps;
283 | sd.cfg_scale = cfgScale;
284 | sd.width = width;
285 | sd.height = height;
286 | sd.seed = seed;
287 | sd.tiling = tiling;
288 |
289 | if (selectedSampler >= 0 && selectedSampler < samplersList.Length)
290 | sd.sampler_name = samplersList[selectedSampler];
291 |
292 | // Serialize the input parameters
293 | string jsonData = JsonConvert.SerializeObject(sd);
294 | Debug.Log("Sending JSON data: " + jsonData);
295 |
296 | // Create the request
297 | UnityWebRequest request = new UnityWebRequest(url, "POST");
298 | request.downloadHandler = new DownloadHandlerBuffer();
299 | request.uploadHandler = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(jsonData));
300 | request.SetRequestHeader("Content-Type", "application/json");
301 |
302 | // Add authentication if needed
303 | if (sdc.settings.useAuth && !sdc.settings.user.Equals("") && !sdc.settings.pass.Equals(""))
304 | {
305 | byte[] bytesToEncode = Encoding.UTF8.GetBytes(sdc.settings.user + ":" + sdc.settings.pass);
306 | string encodedCredentials = Convert.ToBase64String(bytesToEncode);
307 | request.SetRequestHeader("Authorization", "Basic " + encodedCredentials);
308 | }
309 |
310 | // Send the request
311 | request.SendWebRequest();
312 |
313 | // Wait for the request to complete while showing progress
314 | while (!request.isDone)
315 | {
316 | if (sdc.settings.useAuth && !sdc.settings.user.Equals("") && !sdc.settings.pass.Equals(""))
317 | UpdateGenerationProgressWithAuth();
318 | else
319 | UpdateGenerationProgress();
320 |
321 | yield return new WaitForSeconds(0.5f);
322 | }
323 |
324 | // Check if the request was successful
325 | if (request.result != UnityWebRequest.Result.Success)
326 | {
327 | Debug.LogError("Request error: " + request.error);
328 | Debug.LogError("Response code: " + request.responseCode);
329 | Debug.LogError("Response: " + request.downloadHandler.text);
330 |
331 | if (request.responseCode == 405)
332 | {
333 | Debug.LogError("405 Method Not Allowed - This is common with RunPod. Make sure you launched with --api flag and check your firewall/proxy settings.");
334 | Debug.LogError("For RunPod, you might need to configure CORS settings or use their API proxy.");
335 | }
336 |
337 | generating = false;
338 | #if UNITY_EDITOR
339 | EditorUtility.ClearProgressBar();
340 | #endif
341 | yield break;
342 | }
343 |
344 | // Process the response
345 | try
346 | {
347 | string responseText = request.downloadHandler.text;
348 | Debug.Log("Response received: " + responseText.Substring(0, Math.Min(100, responseText.Length)) + "...");
349 |
350 | // Deserialize the JSON string into a data structure
351 | SDResponseTxt2Img json = JsonConvert.DeserializeObject(responseText);
352 |
353 | // If no image, there was probably an error so abort
354 | if (json.images == null || json.images.Length == 0)
355 | {
356 | Debug.LogError("No image was returned by the server. Verify that the server is correctly setup.");
357 | Debug.LogError("Full response: " + responseText);
358 |
359 | generating = false;
360 | #if UNITY_EDITOR
361 | EditorUtility.ClearProgressBar();
362 | #endif
363 | yield break;
364 | }
365 |
366 | // Decode the image from Base64 string into an array of bytes
367 | byte[] imageData = Convert.FromBase64String(json.images[0]);
368 |
369 | // Write it in the specified project output folder
370 | WriteImageFile(imageData, filename);
371 |
372 | // Read back the image into a texture
373 | if (File.Exists(filename))
374 | {
375 | Texture2D texture = new Texture2D(2, 2);
376 | texture.LoadImage(imageData);
377 | texture.Apply();
378 |
379 | LoadIntoMaterial(texture);
380 | }
381 |
382 | // Read the generation info back (only seed should have changed, as the generation picked a particular seed)
383 | if (json.info != "")
384 | {
385 | SDParamsOutTxt2Img info = JsonConvert.DeserializeObject(json.info);
386 |
387 | // Read the seed that was used by Stable Diffusion to generate this result
388 | generatedSeed = info.seed;
389 | }
390 | }
391 | catch (Exception e)
392 | {
393 | Debug.LogError("Error processing response: " + e.Message);
394 | Debug.LogError("Stack trace: " + e.StackTrace);
395 | Debug.LogError("Response was: " + request.downloadHandler.text);
396 | }
397 |
398 | #if UNITY_EDITOR
399 | EditorUtility.ClearProgressBar();
400 | #endif
401 | generating = false;
402 | yield return null;
403 | }
404 |
405 |
406 | ///
407 | /// Helper method to write image data to file without using yield within a try block
408 | ///
409 | /// Image data as byte array
410 | /// Path to write the file
411 | private void WriteImageFile(byte[] imageData, string filepath)
412 | {
413 | try
414 | {
415 | using (FileStream imageFile = new FileStream(filepath, FileMode.Create))
416 | {
417 | #if UNITY_EDITOR
418 | AssetDatabase.StartAssetEditing();
419 | #endif
420 | imageFile.Write(imageData, 0, imageData.Length);
421 | imageFile.Flush();
422 | #if UNITY_EDITOR
423 | AssetDatabase.StopAssetEditing();
424 | AssetDatabase.SaveAssets();
425 | #endif
426 | }
427 | }
428 | catch (Exception e)
429 | {
430 | Debug.LogError("Error writing image file: " + e.Message);
431 | }
432 | }
433 |
434 | ///
435 | /// Load the texture into a material.
436 | ///
437 | /// Texture to add to the material
438 | void LoadIntoMaterial(Texture2D texture)
439 | {
440 | try
441 | {
442 | MeshRenderer mr = GetMeshRenderer();
443 | if (mr == null)
444 | return;
445 |
446 | Shader standardShader = sdc.settings.useUniversalRenderPipeline ? Shader.Find("Universal Render Pipeline/Lit") : Shader.Find("Standard");
447 |
448 | if(!standardShader)
449 | Debug.LogError("Shader setup wrong: Please check if you're project uses 'Standard' or 'Universal Render Pipeline'");
450 |
451 | mr.sharedMaterial = new Material(standardShader);
452 | mr.sharedMaterial.mainTexture = texture;
453 | generatedTexture = texture;
454 |
455 | // Apply the material to childrens if required
456 | if (applyRecursively)
457 | {
458 | MeshRenderer[] mrs = FindInChildrenAll(this.gameObject);
459 | foreach (MeshRenderer m in mrs)
460 | if (m != mr)
461 | {
462 | m.sharedMaterial = mr.sharedMaterial;
463 | }
464 | }
465 |
466 | // Generate the normal map
467 | GenerateNormalMap();
468 |
469 | // Force the assets and scene to refresh with new material
470 | #if UNITY_EDITOR
471 | if (!Application.isPlaying)
472 | {
473 | EditorUtility.SetDirty(generatedTexture);
474 | AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
475 | SceneView.RepaintAll();
476 | SceneView.FrameLastActiveSceneView();
477 | //SceneView.FocusWindowIfItsOpen(typeof(SceneView));
478 | EditorApplication.QueuePlayerLoopUpdate();
479 | EditorSceneManager.MarkAllScenesDirty();
480 | EditorUtility.RequestScriptReload();
481 | }
482 | #endif
483 | }
484 | catch (Exception e)
485 | {
486 | Debug.LogError(e.Message + "\n\n" + e.StackTrace);
487 | }
488 | }
489 |
490 |
491 | ///
492 | /// Generate a normal map from the generated texture.
493 | ///
494 | public void GenerateNormalMap()
495 | {
496 | if (generatedTexture == null)
497 | return;
498 |
499 | try
500 | {
501 | MeshRenderer mr = GetMeshRenderer();
502 | if (mr == null)
503 | return;
504 |
505 | if (generateNormalMap)
506 | {
507 | generatedNormal = CreateNormalmap(generatedTexture, 0.5f);
508 | #if UNITY_EDITOR
509 | EditorUtility.SetDirty(generatedNormal);
510 | #endif
511 | }
512 | else
513 | generatedNormal = null;
514 |
515 | UpdateMaterialProperties();
516 | }
517 | catch (Exception e)
518 | {
519 | Debug.LogError(e.Message + "\n\n" + e.StackTrace);
520 | }
521 | }
522 |
523 |
524 | ///
525 | /// Update the material properties.
526 | /// Also apply to children if set to apply recursively.
527 | ///
528 | void UpdateMaterialProperties()
529 | {
530 | MeshRenderer mr = GetMeshRenderer();
531 | if (mr == null)
532 | return;
533 |
534 | // Apply tilling, metallic and smoothness
535 | mr.sharedMaterial.mainTextureScale = new Vector2(-tilingX, -tilingY);
536 | mr.sharedMaterial.SetFloat("_Metallic", metallic);
537 | mr.sharedMaterial.SetFloat("_Glossiness", smoothness);
538 |
539 | // Apply normal map if required
540 | if (generateNormalMap && generatedNormal != null)
541 | {
542 | mr.sharedMaterial.SetTexture("_BumpMap", generatedNormal);
543 | mr.sharedMaterial.SetFloat("_BumpScale", normalMapStrength);
544 | mr.sharedMaterial.EnableKeyword("_NORMALMAP");
545 | }
546 | // Disable normal map
547 | else
548 | {
549 | mr.sharedMaterial.SetTexture("_BumpMap", null);
550 | mr.sharedMaterial.DisableKeyword("_NORMALMAP");
551 | }
552 |
553 | // Apply recursively if required
554 | if (applyRecursively)
555 | {
556 | MeshRenderer[] mrs = FindInChildrenAll(this.gameObject);
557 | foreach (MeshRenderer m in mrs)
558 | if (m != mr)
559 | {
560 | m.sharedMaterial = mr.sharedMaterial;
561 | }
562 | }
563 | }
564 |
565 |
566 | ///
567 | /// Create a Normal map based on the gradient in 3x3 surrounding neighborhood.
568 | /// Based on UnityCoder code: https://github.com/unitycoder/NormalMapFromTexture
569 | ///
570 | /// Normal map texture
571 | /// Source texture
572 | /// Normal map strength float (example: 1-20)
573 | public static Texture2D CreateNormalmap(Texture2D t, float normalStrength)
574 | {
575 | Color[] pixels = new Color[t.width * t.height];
576 | Texture2D texNormal = new Texture2D(t.width, t.height, TextureFormat.RGB24, false, false);
577 | Vector3 vScale = new Vector3(0.3333f, 0.3333f, 0.3333f);
578 |
579 | Color tc;
580 | for (int y = 0; y < t.height; y++)
581 | {
582 | for (int x = 0; x < t.width; x++)
583 | {
584 | tc = t.GetPixel(x - 1, y - 1); Vector3 cSampleNegXNegY = new Vector3(tc.r, tc.g, tc.g);
585 | tc = t.GetPixel(x - 0, y - 1); Vector3 cSampleZerXNegY = new Vector3(tc.r, tc.g, tc.g);
586 | tc = t.GetPixel(x + 1, y - 1); Vector3 cSamplePosXNegY = new Vector3(tc.r, tc.g, tc.g);
587 | tc = t.GetPixel(x - 1, y - 0); Vector3 cSampleNegXZerY = new Vector3(tc.r, tc.g, tc.g);
588 | tc = t.GetPixel(x + 1, y - 0); Vector3 cSamplePosXZerY = new Vector3(tc.r, tc.g, tc.g);
589 | tc = t.GetPixel(x - 1, y + 1); Vector3 cSampleNegXPosY = new Vector3(tc.r, tc.g, tc.g);
590 | tc = t.GetPixel(x - 0, y + 1); Vector3 cSampleZerXPosY = new Vector3(tc.r, tc.g, tc.g);
591 | tc = t.GetPixel(x + 1, y + 1); Vector3 cSamplePosXPosY = new Vector3(tc.r, tc.g, tc.g);
592 |
593 | float fSampleNegXNegY = Vector3.Dot(cSampleNegXNegY, vScale);
594 | float fSampleZerXNegY = Vector3.Dot(cSampleZerXNegY, vScale);
595 | float fSamplePosXNegY = Vector3.Dot(cSamplePosXNegY, vScale);
596 | float fSampleNegXZerY = Vector3.Dot(cSampleNegXZerY, vScale);
597 | float fSamplePosXZerY = Vector3.Dot(cSamplePosXZerY, vScale);
598 | float fSampleNegXPosY = Vector3.Dot(cSampleNegXPosY, vScale);
599 | float fSampleZerXPosY = Vector3.Dot(cSampleZerXPosY, vScale);
600 | float fSamplePosXPosY = Vector3.Dot(cSamplePosXPosY, vScale);
601 |
602 | float edgeX = (fSampleNegXNegY - fSamplePosXNegY) * 0.25f + (fSampleNegXZerY - fSamplePosXZerY) * 0.5f + (fSampleNegXPosY - fSamplePosXPosY) * 0.25f;
603 | float edgeY = (fSampleNegXNegY - fSampleNegXPosY) * 0.25f + (fSampleZerXNegY - fSampleZerXPosY) * 0.5f + (fSamplePosXNegY - fSamplePosXPosY) * 0.25f;
604 |
605 | Vector2 vEdge = new Vector2(edgeX, edgeY) * normalStrength;
606 | Vector3 norm = new Vector3(vEdge.x, vEdge.y, 1.0f).normalized;
607 | Color c = new Color(norm.x * 0.5f + 0.5f, norm.y * 0.5f + 0.5f, norm.z * 0.5f + 0.5f, 1);
608 |
609 | pixels[x + y * t.width] = c;
610 | }
611 | }
612 |
613 | texNormal.SetPixels(pixels);
614 | texNormal.Apply();
615 |
616 | return texNormal;
617 | }
618 | }
619 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Scripts/StableDiffusionText2Material.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 45733077a48ef55438bdf8ea5e658283
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Settings.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 46614d66126ce3b4a9d0a6be69e70c0c
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Settings/DefaultLocalSDSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: 2624b883c65a4284ba2d9c328a8fe674, type: 3}
13 | m_Name: DefaultLocalSDSettings
14 | m_EditorClassIdentifier:
15 | StableDiffusionServerURL: http://127.0.0.1:7860
16 | ModelsAPI: /sdapi/v1/sd-models
17 | TextToImageAPI: /sdapi/v1/txt2img
18 | ImageToImageAPI: /sdapi/v1/img2img
19 | OptionAPI: /sdapi/v1/options
20 | ProgressAPI: /sdapi/v1/progress
21 | OutputFolder: /streamingAssets
22 | sampler: Euler a
23 | width: 512
24 | height: 512
25 | steps: 35
26 | cfgScale: 7
27 | seed: -1
28 | useAuth: 0
29 | user:
30 | pass:
31 | useUniversalRenderPipeline: 0
32 |
--------------------------------------------------------------------------------
/Assets/Stable-Diffusion-Unity-Integration/Settings/DefaultLocalSDSettings.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2f0a42d2a132f7144b35b4cabb576d34
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 11400000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 49cab40fa4fab254abf0245856cda338
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDImages.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8036a4edcf4cf7c4eaacdae9479ec0eb
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDImages/01d99a33-4deb-4b8f-9c08-cca38e407c38.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/StreamingAssets/SDImages/01d99a33-4deb-4b8f-9c08-cca38e407c38.png
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDImages/01d99a33-4deb-4b8f-9c08-cca38e407c38.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 42e7dbd9491d9e94288f8fd47a08cf4c
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDImages/33e5b251-804a-4709-9f03-1e576a697cf1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/StreamingAssets/SDImages/33e5b251-804a-4709-9f03-1e576a697cf1.png
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDImages/33e5b251-804a-4709-9f03-1e576a697cf1.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 64e25f5ffa246a24d94e23ca4320d996
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDImages/79cec67c-d8e3-4981-a0ba-a03a2f777dda.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/StreamingAssets/SDImages/79cec67c-d8e3-4981-a0ba-a03a2f777dda.png
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDImages/79cec67c-d8e3-4981-a0ba-a03a2f777dda.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 54728f95e90c9c542815a3c095de0aa8
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDImages/b6b07faf-594d-40f0-b312-75d3ce491fff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/StreamingAssets/SDImages/b6b07faf-594d-40f0-b312-75d3ce491fff.png
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDImages/b6b07faf-594d-40f0-b312-75d3ce491fff.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 86a81fef7bcaa9d47bbf1232fd9c6b29
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDImages/d3f9a183-0a41-4c42-ac65-effd3210f227.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/StreamingAssets/SDImages/d3f9a183-0a41-4c42-ac65-effd3210f227.png
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDImages/d3f9a183-0a41-4c42-ac65-effd3210f227.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ee2dbaa3d090db948b0e73d0575cbb8b
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 08aca7186b6351640b20745242b14265
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/062703f4-a2d9-4878-9575-2ce8377ec229.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/StreamingAssets/SDMaterials/062703f4-a2d9-4878-9575-2ce8377ec229.png
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/062703f4-a2d9-4878-9575-2ce8377ec229.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 793e7dcedb2cd4f47b1fd6e103cf2641
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/083f586c-1d94-4167-8897-8d8302c19854.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/StreamingAssets/SDMaterials/083f586c-1d94-4167-8897-8d8302c19854.png
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/083f586c-1d94-4167-8897-8d8302c19854.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c8d1ed4301cdb5c49b670a2fcd5d15d1
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/2acafddf-b5ab-417e-a354-dfd13a58e5ec.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/StreamingAssets/SDMaterials/2acafddf-b5ab-417e-a354-dfd13a58e5ec.png
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/2acafddf-b5ab-417e-a354-dfd13a58e5ec.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3cf312efd00edfc47b57ad52ee086593
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/57a93795-9aad-43d2-b9dc-14ac2a5b81b0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/StreamingAssets/SDMaterials/57a93795-9aad-43d2-b9dc-14ac2a5b81b0.png
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/57a93795-9aad-43d2-b9dc-14ac2a5b81b0.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2b7ca184448812c44ae7bf8c311bab78
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/7089f6a1-e9e0-4189-9e4f-e0ff8875c1cc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/StreamingAssets/SDMaterials/7089f6a1-e9e0-4189-9e4f-e0ff8875c1cc.png
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/7089f6a1-e9e0-4189-9e4f-e0ff8875c1cc.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d67617fba4729cb4daec096d63f60516
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/85de5d56-067f-48b9-83c6-0ee678aba943.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/StreamingAssets/SDMaterials/85de5d56-067f-48b9-83c6-0ee678aba943.png
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/85de5d56-067f-48b9-83c6-0ee678aba943.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0b46074730362fb4f8ba647ac0a53330
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/8712a93a-6704-4650-9044-939f722c8a46.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/StreamingAssets/SDMaterials/8712a93a-6704-4650-9044-939f722c8a46.png
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/8712a93a-6704-4650-9044-939f722c8a46.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 935c9f2783459a443813468da7f626a7
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/90156104-f1a9-4a17-954a-d19e44d73332.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/StreamingAssets/SDMaterials/90156104-f1a9-4a17-954a-d19e44d73332.png
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/90156104-f1a9-4a17-954a-d19e44d73332.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6913caed4fe384f47b655be30f5b2b00
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/c0835069-7d5c-4e75-923e-52424e2b4d44.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/StreamingAssets/SDMaterials/c0835069-7d5c-4e75-923e-52424e2b4d44.png
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/c0835069-7d5c-4e75-923e-52424e2b4d44.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8fdea8bc6a1f77f48aa9c0f136dc48c0
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/ef15cac4-851e-461e-ad33-e6176170ee69.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Assets/StreamingAssets/SDMaterials/ef15cac4-851e-461e-ad33-e6176170ee69.png
--------------------------------------------------------------------------------
/Assets/StreamingAssets/SDMaterials/ef15cac4-851e-461e-ad33-e6176170ee69.png.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e1f9249829bcdb142b84a7125f8b0458
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Packages/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "com.unity.collab-proxy": "2.2.0",
4 | "com.unity.ide.rider": "3.0.26",
5 | "com.unity.ide.visualstudio": "2.0.22",
6 | "com.unity.ide.vscode": "1.2.5",
7 | "com.unity.test-framework": "1.1.33",
8 | "com.unity.textmeshpro": "3.0.6",
9 | "com.unity.timeline": "1.6.5",
10 | "com.unity.ugui": "1.0.0",
11 | "com.unity.visualscripting": "1.9.1",
12 | "com.unity.modules.ai": "1.0.0",
13 | "com.unity.modules.androidjni": "1.0.0",
14 | "com.unity.modules.animation": "1.0.0",
15 | "com.unity.modules.assetbundle": "1.0.0",
16 | "com.unity.modules.audio": "1.0.0",
17 | "com.unity.modules.cloth": "1.0.0",
18 | "com.unity.modules.director": "1.0.0",
19 | "com.unity.modules.imageconversion": "1.0.0",
20 | "com.unity.modules.imgui": "1.0.0",
21 | "com.unity.modules.jsonserialize": "1.0.0",
22 | "com.unity.modules.particlesystem": "1.0.0",
23 | "com.unity.modules.physics": "1.0.0",
24 | "com.unity.modules.physics2d": "1.0.0",
25 | "com.unity.modules.screencapture": "1.0.0",
26 | "com.unity.modules.terrain": "1.0.0",
27 | "com.unity.modules.terrainphysics": "1.0.0",
28 | "com.unity.modules.tilemap": "1.0.0",
29 | "com.unity.modules.ui": "1.0.0",
30 | "com.unity.modules.uielements": "1.0.0",
31 | "com.unity.modules.umbra": "1.0.0",
32 | "com.unity.modules.unityanalytics": "1.0.0",
33 | "com.unity.modules.unitywebrequest": "1.0.0",
34 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
35 | "com.unity.modules.unitywebrequestaudio": "1.0.0",
36 | "com.unity.modules.unitywebrequesttexture": "1.0.0",
37 | "com.unity.modules.unitywebrequestwww": "1.0.0",
38 | "com.unity.modules.vehicles": "1.0.0",
39 | "com.unity.modules.video": "1.0.0",
40 | "com.unity.modules.vr": "1.0.0",
41 | "com.unity.modules.wind": "1.0.0",
42 | "com.unity.modules.xr": "1.0.0"
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Packages/packages-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "com.unity.collab-proxy": {
4 | "version": "2.2.0",
5 | "depth": 0,
6 | "source": "registry",
7 | "dependencies": {},
8 | "url": "https://packages.unity.com"
9 | },
10 | "com.unity.ext.nunit": {
11 | "version": "1.0.6",
12 | "depth": 1,
13 | "source": "registry",
14 | "dependencies": {},
15 | "url": "https://packages.unity.com"
16 | },
17 | "com.unity.ide.rider": {
18 | "version": "3.0.26",
19 | "depth": 0,
20 | "source": "registry",
21 | "dependencies": {
22 | "com.unity.ext.nunit": "1.0.6"
23 | },
24 | "url": "https://packages.unity.com"
25 | },
26 | "com.unity.ide.visualstudio": {
27 | "version": "2.0.22",
28 | "depth": 0,
29 | "source": "registry",
30 | "dependencies": {
31 | "com.unity.test-framework": "1.1.9"
32 | },
33 | "url": "https://packages.unity.com"
34 | },
35 | "com.unity.ide.vscode": {
36 | "version": "1.2.5",
37 | "depth": 0,
38 | "source": "registry",
39 | "dependencies": {},
40 | "url": "https://packages.unity.com"
41 | },
42 | "com.unity.test-framework": {
43 | "version": "1.1.33",
44 | "depth": 0,
45 | "source": "registry",
46 | "dependencies": {
47 | "com.unity.ext.nunit": "1.0.6",
48 | "com.unity.modules.imgui": "1.0.0",
49 | "com.unity.modules.jsonserialize": "1.0.0"
50 | },
51 | "url": "https://packages.unity.com"
52 | },
53 | "com.unity.textmeshpro": {
54 | "version": "3.0.6",
55 | "depth": 0,
56 | "source": "registry",
57 | "dependencies": {
58 | "com.unity.ugui": "1.0.0"
59 | },
60 | "url": "https://packages.unity.com"
61 | },
62 | "com.unity.timeline": {
63 | "version": "1.6.5",
64 | "depth": 0,
65 | "source": "registry",
66 | "dependencies": {
67 | "com.unity.modules.audio": "1.0.0",
68 | "com.unity.modules.director": "1.0.0",
69 | "com.unity.modules.animation": "1.0.0",
70 | "com.unity.modules.particlesystem": "1.0.0"
71 | },
72 | "url": "https://packages.unity.com"
73 | },
74 | "com.unity.ugui": {
75 | "version": "1.0.0",
76 | "depth": 0,
77 | "source": "builtin",
78 | "dependencies": {
79 | "com.unity.modules.ui": "1.0.0",
80 | "com.unity.modules.imgui": "1.0.0"
81 | }
82 | },
83 | "com.unity.visualscripting": {
84 | "version": "1.9.1",
85 | "depth": 0,
86 | "source": "registry",
87 | "dependencies": {
88 | "com.unity.ugui": "1.0.0",
89 | "com.unity.modules.jsonserialize": "1.0.0"
90 | },
91 | "url": "https://packages.unity.com"
92 | },
93 | "com.unity.modules.ai": {
94 | "version": "1.0.0",
95 | "depth": 0,
96 | "source": "builtin",
97 | "dependencies": {}
98 | },
99 | "com.unity.modules.androidjni": {
100 | "version": "1.0.0",
101 | "depth": 0,
102 | "source": "builtin",
103 | "dependencies": {}
104 | },
105 | "com.unity.modules.animation": {
106 | "version": "1.0.0",
107 | "depth": 0,
108 | "source": "builtin",
109 | "dependencies": {}
110 | },
111 | "com.unity.modules.assetbundle": {
112 | "version": "1.0.0",
113 | "depth": 0,
114 | "source": "builtin",
115 | "dependencies": {}
116 | },
117 | "com.unity.modules.audio": {
118 | "version": "1.0.0",
119 | "depth": 0,
120 | "source": "builtin",
121 | "dependencies": {}
122 | },
123 | "com.unity.modules.cloth": {
124 | "version": "1.0.0",
125 | "depth": 0,
126 | "source": "builtin",
127 | "dependencies": {
128 | "com.unity.modules.physics": "1.0.0"
129 | }
130 | },
131 | "com.unity.modules.director": {
132 | "version": "1.0.0",
133 | "depth": 0,
134 | "source": "builtin",
135 | "dependencies": {
136 | "com.unity.modules.audio": "1.0.0",
137 | "com.unity.modules.animation": "1.0.0"
138 | }
139 | },
140 | "com.unity.modules.imageconversion": {
141 | "version": "1.0.0",
142 | "depth": 0,
143 | "source": "builtin",
144 | "dependencies": {}
145 | },
146 | "com.unity.modules.imgui": {
147 | "version": "1.0.0",
148 | "depth": 0,
149 | "source": "builtin",
150 | "dependencies": {}
151 | },
152 | "com.unity.modules.jsonserialize": {
153 | "version": "1.0.0",
154 | "depth": 0,
155 | "source": "builtin",
156 | "dependencies": {}
157 | },
158 | "com.unity.modules.particlesystem": {
159 | "version": "1.0.0",
160 | "depth": 0,
161 | "source": "builtin",
162 | "dependencies": {}
163 | },
164 | "com.unity.modules.physics": {
165 | "version": "1.0.0",
166 | "depth": 0,
167 | "source": "builtin",
168 | "dependencies": {}
169 | },
170 | "com.unity.modules.physics2d": {
171 | "version": "1.0.0",
172 | "depth": 0,
173 | "source": "builtin",
174 | "dependencies": {}
175 | },
176 | "com.unity.modules.screencapture": {
177 | "version": "1.0.0",
178 | "depth": 0,
179 | "source": "builtin",
180 | "dependencies": {
181 | "com.unity.modules.imageconversion": "1.0.0"
182 | }
183 | },
184 | "com.unity.modules.subsystems": {
185 | "version": "1.0.0",
186 | "depth": 1,
187 | "source": "builtin",
188 | "dependencies": {
189 | "com.unity.modules.jsonserialize": "1.0.0"
190 | }
191 | },
192 | "com.unity.modules.terrain": {
193 | "version": "1.0.0",
194 | "depth": 0,
195 | "source": "builtin",
196 | "dependencies": {}
197 | },
198 | "com.unity.modules.terrainphysics": {
199 | "version": "1.0.0",
200 | "depth": 0,
201 | "source": "builtin",
202 | "dependencies": {
203 | "com.unity.modules.physics": "1.0.0",
204 | "com.unity.modules.terrain": "1.0.0"
205 | }
206 | },
207 | "com.unity.modules.tilemap": {
208 | "version": "1.0.0",
209 | "depth": 0,
210 | "source": "builtin",
211 | "dependencies": {
212 | "com.unity.modules.physics2d": "1.0.0"
213 | }
214 | },
215 | "com.unity.modules.ui": {
216 | "version": "1.0.0",
217 | "depth": 0,
218 | "source": "builtin",
219 | "dependencies": {}
220 | },
221 | "com.unity.modules.uielements": {
222 | "version": "1.0.0",
223 | "depth": 0,
224 | "source": "builtin",
225 | "dependencies": {
226 | "com.unity.modules.ui": "1.0.0",
227 | "com.unity.modules.imgui": "1.0.0",
228 | "com.unity.modules.jsonserialize": "1.0.0",
229 | "com.unity.modules.uielementsnative": "1.0.0"
230 | }
231 | },
232 | "com.unity.modules.uielementsnative": {
233 | "version": "1.0.0",
234 | "depth": 1,
235 | "source": "builtin",
236 | "dependencies": {
237 | "com.unity.modules.ui": "1.0.0",
238 | "com.unity.modules.imgui": "1.0.0",
239 | "com.unity.modules.jsonserialize": "1.0.0"
240 | }
241 | },
242 | "com.unity.modules.umbra": {
243 | "version": "1.0.0",
244 | "depth": 0,
245 | "source": "builtin",
246 | "dependencies": {}
247 | },
248 | "com.unity.modules.unityanalytics": {
249 | "version": "1.0.0",
250 | "depth": 0,
251 | "source": "builtin",
252 | "dependencies": {
253 | "com.unity.modules.unitywebrequest": "1.0.0",
254 | "com.unity.modules.jsonserialize": "1.0.0"
255 | }
256 | },
257 | "com.unity.modules.unitywebrequest": {
258 | "version": "1.0.0",
259 | "depth": 0,
260 | "source": "builtin",
261 | "dependencies": {}
262 | },
263 | "com.unity.modules.unitywebrequestassetbundle": {
264 | "version": "1.0.0",
265 | "depth": 0,
266 | "source": "builtin",
267 | "dependencies": {
268 | "com.unity.modules.assetbundle": "1.0.0",
269 | "com.unity.modules.unitywebrequest": "1.0.0"
270 | }
271 | },
272 | "com.unity.modules.unitywebrequestaudio": {
273 | "version": "1.0.0",
274 | "depth": 0,
275 | "source": "builtin",
276 | "dependencies": {
277 | "com.unity.modules.unitywebrequest": "1.0.0",
278 | "com.unity.modules.audio": "1.0.0"
279 | }
280 | },
281 | "com.unity.modules.unitywebrequesttexture": {
282 | "version": "1.0.0",
283 | "depth": 0,
284 | "source": "builtin",
285 | "dependencies": {
286 | "com.unity.modules.unitywebrequest": "1.0.0",
287 | "com.unity.modules.imageconversion": "1.0.0"
288 | }
289 | },
290 | "com.unity.modules.unitywebrequestwww": {
291 | "version": "1.0.0",
292 | "depth": 0,
293 | "source": "builtin",
294 | "dependencies": {
295 | "com.unity.modules.unitywebrequest": "1.0.0",
296 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
297 | "com.unity.modules.unitywebrequestaudio": "1.0.0",
298 | "com.unity.modules.audio": "1.0.0",
299 | "com.unity.modules.assetbundle": "1.0.0",
300 | "com.unity.modules.imageconversion": "1.0.0"
301 | }
302 | },
303 | "com.unity.modules.vehicles": {
304 | "version": "1.0.0",
305 | "depth": 0,
306 | "source": "builtin",
307 | "dependencies": {
308 | "com.unity.modules.physics": "1.0.0"
309 | }
310 | },
311 | "com.unity.modules.video": {
312 | "version": "1.0.0",
313 | "depth": 0,
314 | "source": "builtin",
315 | "dependencies": {
316 | "com.unity.modules.audio": "1.0.0",
317 | "com.unity.modules.ui": "1.0.0",
318 | "com.unity.modules.unitywebrequest": "1.0.0"
319 | }
320 | },
321 | "com.unity.modules.vr": {
322 | "version": "1.0.0",
323 | "depth": 0,
324 | "source": "builtin",
325 | "dependencies": {
326 | "com.unity.modules.jsonserialize": "1.0.0",
327 | "com.unity.modules.physics": "1.0.0",
328 | "com.unity.modules.xr": "1.0.0"
329 | }
330 | },
331 | "com.unity.modules.wind": {
332 | "version": "1.0.0",
333 | "depth": 0,
334 | "source": "builtin",
335 | "dependencies": {}
336 | },
337 | "com.unity.modules.xr": {
338 | "version": "1.0.0",
339 | "depth": 0,
340 | "source": "builtin",
341 | "dependencies": {
342 | "com.unity.modules.physics": "1.0.0",
343 | "com.unity.modules.jsonserialize": "1.0.0",
344 | "com.unity.modules.subsystems": "1.0.0"
345 | }
346 | }
347 | }
348 | }
349 |
--------------------------------------------------------------------------------
/ProjectSettings/AudioManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!11 &1
4 | AudioManager:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Volume: 1
8 | Rolloff Scale: 1
9 | Doppler Factor: 1
10 | Default Speaker Mode: 2
11 | m_SampleRate: 0
12 | m_DSPBufferSize: 1024
13 | m_VirtualVoiceCount: 512
14 | m_RealVoiceCount: 32
15 | m_SpatializerPlugin:
16 | m_AmbisonicDecoderPlugin:
17 | m_DisableAudio: 0
18 | m_VirtualizeEffects: 1
19 | m_RequestedDSPBufferSize: 1024
20 |
--------------------------------------------------------------------------------
/ProjectSettings/ClusterInputManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!236 &1
4 | ClusterInputManager:
5 | m_ObjectHideFlags: 0
6 | m_Inputs: []
7 |
--------------------------------------------------------------------------------
/ProjectSettings/DynamicsManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!55 &1
4 | PhysicsManager:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 11
7 | m_Gravity: {x: 0, y: -9.81, z: 0}
8 | m_DefaultMaterial: {fileID: 0}
9 | m_BounceThreshold: 2
10 | m_SleepThreshold: 0.005
11 | m_DefaultContactOffset: 0.01
12 | m_DefaultSolverIterations: 6
13 | m_DefaultSolverVelocityIterations: 1
14 | m_QueriesHitBackfaces: 0
15 | m_QueriesHitTriggers: 1
16 | m_EnableAdaptiveForce: 0
17 | m_ClothInterCollisionDistance: 0
18 | m_ClothInterCollisionStiffness: 0
19 | m_ContactsGeneration: 1
20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
21 | m_AutoSimulation: 1
22 | m_AutoSyncTransforms: 0
23 | m_ReuseCollisionCallbacks: 1
24 | m_ClothInterCollisionSettingsToggle: 0
25 | m_ContactPairsMode: 0
26 | m_BroadphaseType: 0
27 | m_WorldBounds:
28 | m_Center: {x: 0, y: 0, z: 0}
29 | m_Extent: {x: 250, y: 250, z: 250}
30 | m_WorldSubdivisions: 8
31 | m_FrictionType: 0
32 | m_EnableEnhancedDeterminism: 0
33 | m_EnableUnifiedHeightmaps: 1
34 | m_DefaultMaxAngluarSpeed: 7
35 |
--------------------------------------------------------------------------------
/ProjectSettings/EditorBuildSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1045 &1
4 | EditorBuildSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Scenes: []
8 | m_configObjects: {}
9 |
--------------------------------------------------------------------------------
/ProjectSettings/EditorSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!159 &1
4 | EditorSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 11
7 | m_ExternalVersionControlSupport: Visible Meta Files
8 | m_SerializationMode: 2
9 | m_LineEndingsForNewScripts: 0
10 | m_DefaultBehaviorMode: 0
11 | m_PrefabRegularEnvironment: {fileID: 0}
12 | m_PrefabUIEnvironment: {fileID: 0}
13 | m_SpritePackerMode: 0
14 | m_SpritePackerPaddingPower: 1
15 | m_EtcTextureCompressorBehavior: 1
16 | m_EtcTextureFastCompressor: 1
17 | m_EtcTextureNormalCompressor: 2
18 | m_EtcTextureBestCompressor: 4
19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref
20 | m_ProjectGenerationRootNamespace:
21 | m_CollabEditorSettings:
22 | inProgressEnabled: 1
23 | m_EnableTextureStreamingInEditMode: 1
24 | m_EnableTextureStreamingInPlayMode: 1
25 | m_AsyncShaderCompilation: 1
26 | m_EnterPlayModeOptionsEnabled: 0
27 | m_EnterPlayModeOptions: 3
28 | m_ShowLightmapResolutionOverlay: 1
29 | m_UseLegacyProbeSampleCount: 0
30 | m_SerializeInlineMappingsOnOneLine: 1
31 |
--------------------------------------------------------------------------------
/ProjectSettings/GraphicsSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!30 &1
4 | GraphicsSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 13
7 | m_Deferred:
8 | m_Mode: 1
9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}
10 | m_DeferredReflections:
11 | m_Mode: 1
12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0}
13 | m_ScreenSpaceShadows:
14 | m_Mode: 1
15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0}
16 | m_LegacyDeferred:
17 | m_Mode: 1
18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0}
19 | m_DepthNormals:
20 | m_Mode: 1
21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0}
22 | m_MotionVectors:
23 | m_Mode: 1
24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0}
25 | m_LightHalo:
26 | m_Mode: 1
27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0}
28 | m_LensFlare:
29 | m_Mode: 1
30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0}
31 | m_AlwaysIncludedShaders:
32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0}
33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0}
34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0}
35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0}
36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
38 | m_PreloadedShaders: []
39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
40 | type: 0}
41 | m_CustomRenderPipeline: {fileID: 0}
42 | m_TransparencySortMode: 0
43 | m_TransparencySortAxis: {x: 0, y: 0, z: 1}
44 | m_DefaultRenderingPath: 1
45 | m_DefaultMobileRenderingPath: 1
46 | m_TierSettings: []
47 | m_LightmapStripping: 0
48 | m_FogStripping: 0
49 | m_InstancingStripping: 0
50 | m_LightmapKeepPlain: 1
51 | m_LightmapKeepDirCombined: 1
52 | m_LightmapKeepDynamicPlain: 1
53 | m_LightmapKeepDynamicDirCombined: 1
54 | m_LightmapKeepShadowMask: 1
55 | m_LightmapKeepSubtractive: 1
56 | m_FogKeepLinear: 1
57 | m_FogKeepExp: 1
58 | m_FogKeepExp2: 1
59 | m_AlbedoSwatchInfos: []
60 | m_LightsUseLinearIntensity: 0
61 | m_LightsUseColorTemperature: 0
62 | m_LogWhenShaderIsCompiled: 0
63 | m_AllowEnlightenSupportForUpgradedProject: 0
64 |
--------------------------------------------------------------------------------
/ProjectSettings/InputManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!13 &1
4 | InputManager:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Axes:
8 | - serializedVersion: 3
9 | m_Name: Horizontal
10 | descriptiveName:
11 | descriptiveNegativeName:
12 | negativeButton: left
13 | positiveButton: right
14 | altNegativeButton: a
15 | altPositiveButton: d
16 | gravity: 3
17 | dead: 0.001
18 | sensitivity: 3
19 | snap: 1
20 | invert: 0
21 | type: 0
22 | axis: 0
23 | joyNum: 0
24 | - serializedVersion: 3
25 | m_Name: Vertical
26 | descriptiveName:
27 | descriptiveNegativeName:
28 | negativeButton: down
29 | positiveButton: up
30 | altNegativeButton: s
31 | altPositiveButton: w
32 | gravity: 3
33 | dead: 0.001
34 | sensitivity: 3
35 | snap: 1
36 | invert: 0
37 | type: 0
38 | axis: 0
39 | joyNum: 0
40 | - serializedVersion: 3
41 | m_Name: Fire1
42 | descriptiveName:
43 | descriptiveNegativeName:
44 | negativeButton:
45 | positiveButton: left ctrl
46 | altNegativeButton:
47 | altPositiveButton: mouse 0
48 | gravity: 1000
49 | dead: 0.001
50 | sensitivity: 1000
51 | snap: 0
52 | invert: 0
53 | type: 0
54 | axis: 0
55 | joyNum: 0
56 | - serializedVersion: 3
57 | m_Name: Fire2
58 | descriptiveName:
59 | descriptiveNegativeName:
60 | negativeButton:
61 | positiveButton: left alt
62 | altNegativeButton:
63 | altPositiveButton: mouse 1
64 | gravity: 1000
65 | dead: 0.001
66 | sensitivity: 1000
67 | snap: 0
68 | invert: 0
69 | type: 0
70 | axis: 0
71 | joyNum: 0
72 | - serializedVersion: 3
73 | m_Name: Fire3
74 | descriptiveName:
75 | descriptiveNegativeName:
76 | negativeButton:
77 | positiveButton: left shift
78 | altNegativeButton:
79 | altPositiveButton: mouse 2
80 | gravity: 1000
81 | dead: 0.001
82 | sensitivity: 1000
83 | snap: 0
84 | invert: 0
85 | type: 0
86 | axis: 0
87 | joyNum: 0
88 | - serializedVersion: 3
89 | m_Name: Jump
90 | descriptiveName:
91 | descriptiveNegativeName:
92 | negativeButton:
93 | positiveButton: space
94 | altNegativeButton:
95 | altPositiveButton:
96 | gravity: 1000
97 | dead: 0.001
98 | sensitivity: 1000
99 | snap: 0
100 | invert: 0
101 | type: 0
102 | axis: 0
103 | joyNum: 0
104 | - serializedVersion: 3
105 | m_Name: Mouse X
106 | descriptiveName:
107 | descriptiveNegativeName:
108 | negativeButton:
109 | positiveButton:
110 | altNegativeButton:
111 | altPositiveButton:
112 | gravity: 0
113 | dead: 0
114 | sensitivity: 0.1
115 | snap: 0
116 | invert: 0
117 | type: 1
118 | axis: 0
119 | joyNum: 0
120 | - serializedVersion: 3
121 | m_Name: Mouse Y
122 | descriptiveName:
123 | descriptiveNegativeName:
124 | negativeButton:
125 | positiveButton:
126 | altNegativeButton:
127 | altPositiveButton:
128 | gravity: 0
129 | dead: 0
130 | sensitivity: 0.1
131 | snap: 0
132 | invert: 0
133 | type: 1
134 | axis: 1
135 | joyNum: 0
136 | - serializedVersion: 3
137 | m_Name: Mouse ScrollWheel
138 | descriptiveName:
139 | descriptiveNegativeName:
140 | negativeButton:
141 | positiveButton:
142 | altNegativeButton:
143 | altPositiveButton:
144 | gravity: 0
145 | dead: 0
146 | sensitivity: 0.1
147 | snap: 0
148 | invert: 0
149 | type: 1
150 | axis: 2
151 | joyNum: 0
152 | - serializedVersion: 3
153 | m_Name: Horizontal
154 | descriptiveName:
155 | descriptiveNegativeName:
156 | negativeButton:
157 | positiveButton:
158 | altNegativeButton:
159 | altPositiveButton:
160 | gravity: 0
161 | dead: 0.19
162 | sensitivity: 1
163 | snap: 0
164 | invert: 0
165 | type: 2
166 | axis: 0
167 | joyNum: 0
168 | - serializedVersion: 3
169 | m_Name: Vertical
170 | descriptiveName:
171 | descriptiveNegativeName:
172 | negativeButton:
173 | positiveButton:
174 | altNegativeButton:
175 | altPositiveButton:
176 | gravity: 0
177 | dead: 0.19
178 | sensitivity: 1
179 | snap: 0
180 | invert: 1
181 | type: 2
182 | axis: 1
183 | joyNum: 0
184 | - serializedVersion: 3
185 | m_Name: Fire1
186 | descriptiveName:
187 | descriptiveNegativeName:
188 | negativeButton:
189 | positiveButton: joystick button 0
190 | altNegativeButton:
191 | altPositiveButton:
192 | gravity: 1000
193 | dead: 0.001
194 | sensitivity: 1000
195 | snap: 0
196 | invert: 0
197 | type: 0
198 | axis: 0
199 | joyNum: 0
200 | - serializedVersion: 3
201 | m_Name: Fire2
202 | descriptiveName:
203 | descriptiveNegativeName:
204 | negativeButton:
205 | positiveButton: joystick button 1
206 | altNegativeButton:
207 | altPositiveButton:
208 | gravity: 1000
209 | dead: 0.001
210 | sensitivity: 1000
211 | snap: 0
212 | invert: 0
213 | type: 0
214 | axis: 0
215 | joyNum: 0
216 | - serializedVersion: 3
217 | m_Name: Fire3
218 | descriptiveName:
219 | descriptiveNegativeName:
220 | negativeButton:
221 | positiveButton: joystick button 2
222 | altNegativeButton:
223 | altPositiveButton:
224 | gravity: 1000
225 | dead: 0.001
226 | sensitivity: 1000
227 | snap: 0
228 | invert: 0
229 | type: 0
230 | axis: 0
231 | joyNum: 0
232 | - serializedVersion: 3
233 | m_Name: Jump
234 | descriptiveName:
235 | descriptiveNegativeName:
236 | negativeButton:
237 | positiveButton: joystick button 3
238 | altNegativeButton:
239 | altPositiveButton:
240 | gravity: 1000
241 | dead: 0.001
242 | sensitivity: 1000
243 | snap: 0
244 | invert: 0
245 | type: 0
246 | axis: 0
247 | joyNum: 0
248 | - serializedVersion: 3
249 | m_Name: Submit
250 | descriptiveName:
251 | descriptiveNegativeName:
252 | negativeButton:
253 | positiveButton: return
254 | altNegativeButton:
255 | altPositiveButton: joystick button 0
256 | gravity: 1000
257 | dead: 0.001
258 | sensitivity: 1000
259 | snap: 0
260 | invert: 0
261 | type: 0
262 | axis: 0
263 | joyNum: 0
264 | - serializedVersion: 3
265 | m_Name: Submit
266 | descriptiveName:
267 | descriptiveNegativeName:
268 | negativeButton:
269 | positiveButton: enter
270 | altNegativeButton:
271 | altPositiveButton: space
272 | gravity: 1000
273 | dead: 0.001
274 | sensitivity: 1000
275 | snap: 0
276 | invert: 0
277 | type: 0
278 | axis: 0
279 | joyNum: 0
280 | - serializedVersion: 3
281 | m_Name: Cancel
282 | descriptiveName:
283 | descriptiveNegativeName:
284 | negativeButton:
285 | positiveButton: escape
286 | altNegativeButton:
287 | altPositiveButton: joystick button 1
288 | gravity: 1000
289 | dead: 0.001
290 | sensitivity: 1000
291 | snap: 0
292 | invert: 0
293 | type: 0
294 | axis: 0
295 | joyNum: 0
296 |
--------------------------------------------------------------------------------
/ProjectSettings/MemorySettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!387306366 &1
4 | MemorySettings:
5 | m_ObjectHideFlags: 0
6 | m_EditorMemorySettings:
7 | m_MainAllocatorBlockSize: -1
8 | m_ThreadAllocatorBlockSize: -1
9 | m_MainGfxBlockSize: -1
10 | m_ThreadGfxBlockSize: -1
11 | m_CacheBlockSize: -1
12 | m_TypetreeBlockSize: -1
13 | m_ProfilerBlockSize: -1
14 | m_ProfilerEditorBlockSize: -1
15 | m_BucketAllocatorGranularity: -1
16 | m_BucketAllocatorBucketsCount: -1
17 | m_BucketAllocatorBlockSize: -1
18 | m_BucketAllocatorBlockCount: -1
19 | m_ProfilerBucketAllocatorGranularity: -1
20 | m_ProfilerBucketAllocatorBucketsCount: -1
21 | m_ProfilerBucketAllocatorBlockSize: -1
22 | m_ProfilerBucketAllocatorBlockCount: -1
23 | m_TempAllocatorSizeMain: -1
24 | m_JobTempAllocatorBlockSize: -1
25 | m_BackgroundJobTempAllocatorBlockSize: -1
26 | m_JobTempAllocatorReducedBlockSize: -1
27 | m_TempAllocatorSizeGIBakingWorker: -1
28 | m_TempAllocatorSizeNavMeshWorker: -1
29 | m_TempAllocatorSizeAudioWorker: -1
30 | m_TempAllocatorSizeCloudWorker: -1
31 | m_TempAllocatorSizeGfx: -1
32 | m_TempAllocatorSizeJobWorker: -1
33 | m_TempAllocatorSizeBackgroundWorker: -1
34 | m_TempAllocatorSizePreloadManager: -1
35 | m_PlatformMemorySettings: {}
36 |
--------------------------------------------------------------------------------
/ProjectSettings/MultiplayerManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!655991488 &1
4 | MultiplayerManager:
5 | m_ObjectHideFlags: 0
6 | m_EnableMultiplayerRoles: 0
7 | m_StrippingTypes: {}
8 |
--------------------------------------------------------------------------------
/ProjectSettings/NavMeshAreas.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!126 &1
4 | NavMeshProjectSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | areas:
8 | - name: Walkable
9 | cost: 1
10 | - name: Not Walkable
11 | cost: 1
12 | - name: Jump
13 | cost: 2
14 | - name:
15 | cost: 1
16 | - name:
17 | cost: 1
18 | - name:
19 | cost: 1
20 | - name:
21 | cost: 1
22 | - name:
23 | cost: 1
24 | - name:
25 | cost: 1
26 | - name:
27 | cost: 1
28 | - name:
29 | cost: 1
30 | - name:
31 | cost: 1
32 | - name:
33 | cost: 1
34 | - name:
35 | cost: 1
36 | - name:
37 | cost: 1
38 | - name:
39 | cost: 1
40 | - name:
41 | cost: 1
42 | - name:
43 | cost: 1
44 | - name:
45 | cost: 1
46 | - name:
47 | cost: 1
48 | - name:
49 | cost: 1
50 | - name:
51 | cost: 1
52 | - name:
53 | cost: 1
54 | - name:
55 | cost: 1
56 | - name:
57 | cost: 1
58 | - name:
59 | cost: 1
60 | - name:
61 | cost: 1
62 | - name:
63 | cost: 1
64 | - name:
65 | cost: 1
66 | - name:
67 | cost: 1
68 | - name:
69 | cost: 1
70 | - name:
71 | cost: 1
72 | m_LastAgentTypeID: -887442657
73 | m_Settings:
74 | - serializedVersion: 2
75 | agentTypeID: 0
76 | agentRadius: 0.5
77 | agentHeight: 2
78 | agentSlope: 45
79 | agentClimb: 0.75
80 | ledgeDropHeight: 0
81 | maxJumpAcrossDistance: 0
82 | minRegionArea: 2
83 | manualCellSize: 0
84 | cellSize: 0.16666667
85 | manualTileSize: 0
86 | tileSize: 256
87 | accuratePlacement: 0
88 | debug:
89 | m_Flags: 0
90 | m_SettingNames:
91 | - Humanoid
92 |
--------------------------------------------------------------------------------
/ProjectSettings/PackageManagerSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &1
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 61
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0}
13 | m_Name:
14 | m_EditorClassIdentifier:
15 | m_EnablePreReleasePackages: 0
16 | m_EnablePackageDependencies: 0
17 | m_AdvancedSettingsExpanded: 1
18 | m_ScopedRegistriesSettingsExpanded: 1
19 | m_SeeAllPackageVersions: 0
20 | oneTimeWarningShown: 0
21 | m_Registries:
22 | - m_Id: main
23 | m_Name:
24 | m_Url: https://packages.unity.com
25 | m_Scopes: []
26 | m_IsDefault: 1
27 | m_Capabilities: 7
28 | m_UserSelectedRegistryName:
29 | m_UserAddingNewScopedRegistry: 0
30 | m_RegistryInfoDraft:
31 | m_Modified: 0
32 | m_ErrorMessage:
33 | m_UserModificationsInstanceId: -830
34 | m_OriginalInstanceId: -832
35 | m_LoadAssets: 0
36 |
--------------------------------------------------------------------------------
/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "m_Name": "Settings",
3 | "m_Path": "ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json",
4 | "m_Dictionary": {
5 | "m_DictionaryValues": []
6 | }
7 | }
--------------------------------------------------------------------------------
/ProjectSettings/Physics2DSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!19 &1
4 | Physics2DSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 4
7 | m_Gravity: {x: 0, y: -9.81}
8 | m_DefaultMaterial: {fileID: 0}
9 | m_VelocityIterations: 8
10 | m_PositionIterations: 3
11 | m_VelocityThreshold: 1
12 | m_MaxLinearCorrection: 0.2
13 | m_MaxAngularCorrection: 8
14 | m_MaxTranslationSpeed: 100
15 | m_MaxRotationSpeed: 360
16 | m_BaumgarteScale: 0.2
17 | m_BaumgarteTimeOfImpactScale: 0.75
18 | m_TimeToSleep: 0.5
19 | m_LinearSleepTolerance: 0.01
20 | m_AngularSleepTolerance: 2
21 | m_DefaultContactOffset: 0.01
22 | m_JobOptions:
23 | serializedVersion: 2
24 | useMultithreading: 0
25 | useConsistencySorting: 0
26 | m_InterpolationPosesPerJob: 100
27 | m_NewContactsPerJob: 30
28 | m_CollideContactsPerJob: 100
29 | m_ClearFlagsPerJob: 200
30 | m_ClearBodyForcesPerJob: 200
31 | m_SyncDiscreteFixturesPerJob: 50
32 | m_SyncContinuousFixturesPerJob: 50
33 | m_FindNearestContactsPerJob: 100
34 | m_UpdateTriggerContactsPerJob: 100
35 | m_IslandSolverCostThreshold: 100
36 | m_IslandSolverBodyCostScale: 1
37 | m_IslandSolverContactCostScale: 10
38 | m_IslandSolverJointCostScale: 10
39 | m_IslandSolverBodiesPerJob: 50
40 | m_IslandSolverContactsPerJob: 50
41 | m_AutoSimulation: 1
42 | m_QueriesHitTriggers: 1
43 | m_QueriesStartInColliders: 1
44 | m_CallbacksOnDisable: 1
45 | m_ReuseCollisionCallbacks: 1
46 | m_AutoSyncTransforms: 0
47 | m_AlwaysShowColliders: 0
48 | m_ShowColliderSleep: 1
49 | m_ShowColliderContacts: 0
50 | m_ShowColliderAABB: 0
51 | m_ContactArrowScale: 0.2
52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412}
53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432}
54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745}
55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804}
56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
57 |
--------------------------------------------------------------------------------
/ProjectSettings/PresetManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1386491679 &1
4 | PresetManager:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_DefaultPresets: {}
8 |
--------------------------------------------------------------------------------
/ProjectSettings/ProjectVersion.txt:
--------------------------------------------------------------------------------
1 | m_EditorVersion: 2021.3.33f1
2 | m_EditorVersionWithRevision: 2021.3.33f1 (ee5a2aa03ab2)
3 |
--------------------------------------------------------------------------------
/ProjectSettings/QualitySettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!47 &1
4 | QualitySettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 5
7 | m_CurrentQuality: 5
8 | m_QualitySettings:
9 | - serializedVersion: 2
10 | name: Very Low
11 | pixelLightCount: 0
12 | shadows: 0
13 | shadowResolution: 0
14 | shadowProjection: 1
15 | shadowCascades: 1
16 | shadowDistance: 15
17 | shadowNearPlaneOffset: 3
18 | shadowCascade2Split: 0.33333334
19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
20 | shadowmaskMode: 0
21 | blendWeights: 1
22 | textureQuality: 1
23 | anisotropicTextures: 0
24 | antiAliasing: 0
25 | softParticles: 0
26 | softVegetation: 0
27 | realtimeReflectionProbes: 0
28 | billboardsFaceCameraPosition: 0
29 | vSyncCount: 0
30 | lodBias: 0.3
31 | maximumLODLevel: 0
32 | streamingMipmapsActive: 0
33 | streamingMipmapsAddAllCameras: 1
34 | streamingMipmapsMemoryBudget: 512
35 | streamingMipmapsRenderersPerFrame: 512
36 | streamingMipmapsMaxLevelReduction: 2
37 | streamingMipmapsMaxFileIORequests: 1024
38 | particleRaycastBudget: 4
39 | asyncUploadTimeSlice: 2
40 | asyncUploadBufferSize: 16
41 | asyncUploadPersistentBuffer: 1
42 | resolutionScalingFixedDPIFactor: 1
43 | excludedTargetPlatforms: []
44 | - serializedVersion: 2
45 | name: Low
46 | pixelLightCount: 0
47 | shadows: 0
48 | shadowResolution: 0
49 | shadowProjection: 1
50 | shadowCascades: 1
51 | shadowDistance: 20
52 | shadowNearPlaneOffset: 3
53 | shadowCascade2Split: 0.33333334
54 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
55 | shadowmaskMode: 0
56 | blendWeights: 2
57 | textureQuality: 0
58 | anisotropicTextures: 0
59 | antiAliasing: 0
60 | softParticles: 0
61 | softVegetation: 0
62 | realtimeReflectionProbes: 0
63 | billboardsFaceCameraPosition: 0
64 | vSyncCount: 0
65 | lodBias: 0.4
66 | maximumLODLevel: 0
67 | streamingMipmapsActive: 0
68 | streamingMipmapsAddAllCameras: 1
69 | streamingMipmapsMemoryBudget: 512
70 | streamingMipmapsRenderersPerFrame: 512
71 | streamingMipmapsMaxLevelReduction: 2
72 | streamingMipmapsMaxFileIORequests: 1024
73 | particleRaycastBudget: 16
74 | asyncUploadTimeSlice: 2
75 | asyncUploadBufferSize: 16
76 | asyncUploadPersistentBuffer: 1
77 | resolutionScalingFixedDPIFactor: 1
78 | excludedTargetPlatforms: []
79 | - serializedVersion: 2
80 | name: Medium
81 | pixelLightCount: 1
82 | shadows: 1
83 | shadowResolution: 0
84 | shadowProjection: 1
85 | shadowCascades: 1
86 | shadowDistance: 20
87 | shadowNearPlaneOffset: 3
88 | shadowCascade2Split: 0.33333334
89 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
90 | shadowmaskMode: 0
91 | blendWeights: 2
92 | textureQuality: 0
93 | anisotropicTextures: 1
94 | antiAliasing: 0
95 | softParticles: 0
96 | softVegetation: 0
97 | realtimeReflectionProbes: 0
98 | billboardsFaceCameraPosition: 0
99 | vSyncCount: 1
100 | lodBias: 0.7
101 | maximumLODLevel: 0
102 | streamingMipmapsActive: 0
103 | streamingMipmapsAddAllCameras: 1
104 | streamingMipmapsMemoryBudget: 512
105 | streamingMipmapsRenderersPerFrame: 512
106 | streamingMipmapsMaxLevelReduction: 2
107 | streamingMipmapsMaxFileIORequests: 1024
108 | particleRaycastBudget: 64
109 | asyncUploadTimeSlice: 2
110 | asyncUploadBufferSize: 16
111 | asyncUploadPersistentBuffer: 1
112 | resolutionScalingFixedDPIFactor: 1
113 | excludedTargetPlatforms: []
114 | - serializedVersion: 2
115 | name: High
116 | pixelLightCount: 2
117 | shadows: 2
118 | shadowResolution: 1
119 | shadowProjection: 1
120 | shadowCascades: 2
121 | shadowDistance: 40
122 | shadowNearPlaneOffset: 3
123 | shadowCascade2Split: 0.33333334
124 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
125 | shadowmaskMode: 1
126 | blendWeights: 2
127 | textureQuality: 0
128 | anisotropicTextures: 1
129 | antiAliasing: 0
130 | softParticles: 0
131 | softVegetation: 1
132 | realtimeReflectionProbes: 1
133 | billboardsFaceCameraPosition: 1
134 | vSyncCount: 1
135 | lodBias: 1
136 | maximumLODLevel: 0
137 | streamingMipmapsActive: 0
138 | streamingMipmapsAddAllCameras: 1
139 | streamingMipmapsMemoryBudget: 512
140 | streamingMipmapsRenderersPerFrame: 512
141 | streamingMipmapsMaxLevelReduction: 2
142 | streamingMipmapsMaxFileIORequests: 1024
143 | particleRaycastBudget: 256
144 | asyncUploadTimeSlice: 2
145 | asyncUploadBufferSize: 16
146 | asyncUploadPersistentBuffer: 1
147 | resolutionScalingFixedDPIFactor: 1
148 | excludedTargetPlatforms: []
149 | - serializedVersion: 2
150 | name: Very High
151 | pixelLightCount: 3
152 | shadows: 2
153 | shadowResolution: 2
154 | shadowProjection: 1
155 | shadowCascades: 2
156 | shadowDistance: 70
157 | shadowNearPlaneOffset: 3
158 | shadowCascade2Split: 0.33333334
159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
160 | shadowmaskMode: 1
161 | blendWeights: 4
162 | textureQuality: 0
163 | anisotropicTextures: 2
164 | antiAliasing: 2
165 | softParticles: 1
166 | softVegetation: 1
167 | realtimeReflectionProbes: 1
168 | billboardsFaceCameraPosition: 1
169 | vSyncCount: 1
170 | lodBias: 1.5
171 | maximumLODLevel: 0
172 | streamingMipmapsActive: 0
173 | streamingMipmapsAddAllCameras: 1
174 | streamingMipmapsMemoryBudget: 512
175 | streamingMipmapsRenderersPerFrame: 512
176 | streamingMipmapsMaxLevelReduction: 2
177 | streamingMipmapsMaxFileIORequests: 1024
178 | particleRaycastBudget: 1024
179 | asyncUploadTimeSlice: 2
180 | asyncUploadBufferSize: 16
181 | asyncUploadPersistentBuffer: 1
182 | resolutionScalingFixedDPIFactor: 1
183 | excludedTargetPlatforms: []
184 | - serializedVersion: 2
185 | name: Ultra
186 | pixelLightCount: 4
187 | shadows: 2
188 | shadowResolution: 2
189 | shadowProjection: 1
190 | shadowCascades: 4
191 | shadowDistance: 150
192 | shadowNearPlaneOffset: 3
193 | shadowCascade2Split: 0.33333334
194 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
195 | shadowmaskMode: 1
196 | blendWeights: 4
197 | textureQuality: 0
198 | anisotropicTextures: 2
199 | antiAliasing: 2
200 | softParticles: 1
201 | softVegetation: 1
202 | realtimeReflectionProbes: 1
203 | billboardsFaceCameraPosition: 1
204 | vSyncCount: 1
205 | lodBias: 2
206 | maximumLODLevel: 0
207 | streamingMipmapsActive: 0
208 | streamingMipmapsAddAllCameras: 1
209 | streamingMipmapsMemoryBudget: 512
210 | streamingMipmapsRenderersPerFrame: 512
211 | streamingMipmapsMaxLevelReduction: 2
212 | streamingMipmapsMaxFileIORequests: 1024
213 | particleRaycastBudget: 4096
214 | asyncUploadTimeSlice: 2
215 | asyncUploadBufferSize: 16
216 | asyncUploadPersistentBuffer: 1
217 | resolutionScalingFixedDPIFactor: 1
218 | excludedTargetPlatforms: []
219 | m_PerPlatformDefaultQuality:
220 | Android: 2
221 | Lumin: 5
222 | Nintendo 3DS: 5
223 | Nintendo Switch: 5
224 | PS4: 5
225 | PSP2: 2
226 | Stadia: 5
227 | Standalone: 5
228 | WebGL: 3
229 | Windows Store Apps: 5
230 | XboxOne: 5
231 | iPhone: 2
232 | tvOS: 2
233 |
--------------------------------------------------------------------------------
/ProjectSettings/SceneTemplateSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "templatePinStates": [],
3 | "dependencyTypeInfos": [
4 | {
5 | "userAdded": false,
6 | "type": "UnityEngine.AnimationClip",
7 | "defaultInstantiationMode": 0
8 | },
9 | {
10 | "userAdded": false,
11 | "type": "UnityEditor.Animations.AnimatorController",
12 | "defaultInstantiationMode": 0
13 | },
14 | {
15 | "userAdded": false,
16 | "type": "UnityEngine.AnimatorOverrideController",
17 | "defaultInstantiationMode": 0
18 | },
19 | {
20 | "userAdded": false,
21 | "type": "UnityEditor.Audio.AudioMixerController",
22 | "defaultInstantiationMode": 0
23 | },
24 | {
25 | "userAdded": false,
26 | "type": "UnityEngine.ComputeShader",
27 | "defaultInstantiationMode": 1
28 | },
29 | {
30 | "userAdded": false,
31 | "type": "UnityEngine.Cubemap",
32 | "defaultInstantiationMode": 0
33 | },
34 | {
35 | "userAdded": false,
36 | "type": "UnityEngine.GameObject",
37 | "defaultInstantiationMode": 0
38 | },
39 | {
40 | "userAdded": false,
41 | "type": "UnityEditor.LightingDataAsset",
42 | "defaultInstantiationMode": 0
43 | },
44 | {
45 | "userAdded": false,
46 | "type": "UnityEngine.LightingSettings",
47 | "defaultInstantiationMode": 0
48 | },
49 | {
50 | "userAdded": false,
51 | "type": "UnityEngine.Material",
52 | "defaultInstantiationMode": 0
53 | },
54 | {
55 | "userAdded": false,
56 | "type": "UnityEditor.MonoScript",
57 | "defaultInstantiationMode": 1
58 | },
59 | {
60 | "userAdded": false,
61 | "type": "UnityEngine.PhysicMaterial",
62 | "defaultInstantiationMode": 0
63 | },
64 | {
65 | "userAdded": false,
66 | "type": "UnityEngine.PhysicsMaterial",
67 | "defaultInstantiationMode": 0
68 | },
69 | {
70 | "userAdded": false,
71 | "type": "UnityEngine.PhysicsMaterial2D",
72 | "defaultInstantiationMode": 0
73 | },
74 | {
75 | "userAdded": false,
76 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile",
77 | "defaultInstantiationMode": 0
78 | },
79 | {
80 | "userAdded": false,
81 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources",
82 | "defaultInstantiationMode": 0
83 | },
84 | {
85 | "userAdded": false,
86 | "type": "UnityEngine.Rendering.VolumeProfile",
87 | "defaultInstantiationMode": 0
88 | },
89 | {
90 | "userAdded": false,
91 | "type": "UnityEditor.SceneAsset",
92 | "defaultInstantiationMode": 0
93 | },
94 | {
95 | "userAdded": false,
96 | "type": "UnityEngine.Shader",
97 | "defaultInstantiationMode": 1
98 | },
99 | {
100 | "userAdded": false,
101 | "type": "UnityEngine.ShaderVariantCollection",
102 | "defaultInstantiationMode": 1
103 | },
104 | {
105 | "userAdded": false,
106 | "type": "UnityEngine.Texture",
107 | "defaultInstantiationMode": 0
108 | },
109 | {
110 | "userAdded": false,
111 | "type": "UnityEngine.Texture2D",
112 | "defaultInstantiationMode": 0
113 | },
114 | {
115 | "userAdded": false,
116 | "type": "UnityEngine.Timeline.TimelineAsset",
117 | "defaultInstantiationMode": 0
118 | }
119 | ],
120 | "defaultDependencyTypeInfo": {
121 | "userAdded": false,
122 | "type": "",
123 | "defaultInstantiationMode": 1
124 | },
125 | "newSceneOverride": 0
126 | }
--------------------------------------------------------------------------------
/ProjectSettings/TagManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!78 &1
4 | TagManager:
5 | serializedVersion: 2
6 | tags: []
7 | layers:
8 | - Default
9 | - TransparentFX
10 | - Ignore Raycast
11 | - Post-Processing
12 | - Water
13 | - UI
14 | -
15 | -
16 | -
17 | -
18 | -
19 | -
20 | -
21 | -
22 | -
23 | -
24 | -
25 | -
26 | -
27 | -
28 | -
29 | -
30 | -
31 | -
32 | -
33 | -
34 | -
35 | -
36 | -
37 | -
38 | -
39 | -
40 | m_SortingLayers:
41 | - name: Default
42 | uniqueID: 0
43 | locked: 0
44 |
--------------------------------------------------------------------------------
/ProjectSettings/TimeManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!5 &1
4 | TimeManager:
5 | m_ObjectHideFlags: 0
6 | Fixed Timestep: 0.02
7 | Maximum Allowed Timestep: 0.33333334
8 | m_TimeScale: 1
9 | Maximum Particle Timestep: 0.03
10 |
--------------------------------------------------------------------------------
/ProjectSettings/TimelineSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &1
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 61
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: a287be6c49135cd4f9b2b8666c39d999, type: 3}
13 | m_Name:
14 | m_EditorClassIdentifier:
15 | assetDefaultFramerate: 60
16 | m_DefaultFrameRate: 60
17 |
--------------------------------------------------------------------------------
/ProjectSettings/UnityConnectSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!310 &1
4 | UnityConnectSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 1
7 | m_Enabled: 0
8 | m_TestMode: 0
9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com
12 | m_DashboardUrl: https://dashboard.unity3d.com
13 | m_TestInitMode: 0
14 | CrashReportingSettings:
15 | m_EventUrl: https://perf-events.cloud.unity3d.com
16 | m_Enabled: 0
17 | m_LogBufferSize: 10
18 | m_CaptureEditorExceptions: 1
19 | UnityPurchasingSettings:
20 | m_Enabled: 0
21 | m_TestMode: 0
22 | UnityAnalyticsSettings:
23 | m_Enabled: 0
24 | m_TestMode: 0
25 | m_InitializeOnStartup: 1
26 | UnityAdsSettings:
27 | m_Enabled: 0
28 | m_InitializeOnStartup: 1
29 | m_TestMode: 0
30 | m_IosGameId:
31 | m_AndroidGameId:
32 | m_GameIds: {}
33 | m_GameId:
34 | PerformanceReportingSettings:
35 | m_Enabled: 0
36 |
--------------------------------------------------------------------------------
/ProjectSettings/VFXManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!937362698 &1
4 | VFXManager:
5 | m_ObjectHideFlags: 0
6 | m_IndirectShader: {fileID: 0}
7 | m_CopyBufferShader: {fileID: 0}
8 | m_SortShader: {fileID: 0}
9 | m_StripUpdateShader: {fileID: 0}
10 | m_RenderPipeSettingsPath:
11 | m_FixedTimeStep: 0.016666668
12 | m_MaxDeltaTime: 0.05
13 |
--------------------------------------------------------------------------------
/ProjectSettings/VersionControlSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!890905787 &1
4 | VersionControlSettings:
5 | m_ObjectHideFlags: 0
6 | m_Mode: Visible Meta Files
7 | m_CollabEditorSettings:
8 | inProgressEnabled: 1
9 |
--------------------------------------------------------------------------------
/ProjectSettings/XRSettings.asset:
--------------------------------------------------------------------------------
1 | {
2 | "m_SettingKeys": [
3 | "VR Device Disabled",
4 | "VR Device User Alert"
5 | ],
6 | "m_SettingValues": [
7 | "False",
8 | "False"
9 | ]
10 | }
--------------------------------------------------------------------------------
/ProjectSettings/boot.config:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/ProjectSettings/boot.config
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Stable Diffusion Unity Integration v1.3.0
2 | A basic but functional Unity Editor Component for image generation using Stable Diffusion Automatic 1111 [webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) from within the Unity Editor.
3 | [](https://youtu.be/8gf5GPzhgk8)
4 |
5 |
6 | # Token of Appreciation
7 | If you like it, feel free to Buy me a Coffee (https://www.buymeacoffee.com/dobrado76)
8 |
9 | Cheers!
10 |
11 | # Overview
12 | Simple server configuration with StableDiffusionConfiguration component and SDSettings ScriptableObject assets.
13 | 
14 | 
15 |
16 | Easy Text-to-Image generation for 3D models:
17 | 
18 |
19 | Straightforward Text-to-Image generation for UI elements:
20 | 
21 |
22 |
23 | # Features
24 | - Text-to-Image generation with Prompt and Negative prompt for:
25 | a) texturing 3D models having a MeshRenderer component with tiling option and generation of Normal/Bump maps,
26 | b) UI component having a Image or RawImage component (Canvas, Panel, Image, Button, etc.)
27 | - Image-to-Image generation with Prompt and Negative prompt for:
28 | a) UI component having a Image or RawImage component (Canvas, Panel, Image, Button, etc.)
29 | - Editor only components for scene/level design (no runtime dependencies to Stable Diffusion)
30 | - Image generation using any Stable Diffusion models available in the server model folder
31 | - Standard parameters control over image generation (Prompt and Negative Prompt, Sampler, Nb. of Steps, CFG Scale, Image dimension and Seed)
32 | - All images saved in the Assets folder for persistent storage and reference
33 | - Can run from a local Stable Diffusion server, which requires no API key, or from an online surver such as a Runpod Virtual instance.
34 |
35 |
36 | # Dependencies and requirements
37 | This Unity Editor tool requires access to a Stable Diffusion Automatic 1111 server. Installation or usage of such server is outside the scope of this documentation.
38 | Please refer to the SD A111 WebUI repo: https://github.com/AUTOMATIC1111/stable-diffusion-webui
39 |
40 |
41 | # Getting Started
42 | 1. Install [Stable Diffusion WebUI Automatic 1111](https://github.com/AUTOMATIC1111/stable-diffusion-webui).
43 | 2. Launch [Stable DIffusion WebUI Automatic 1111](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/API) with the '--api' argument in the command line define in the "webui-user.bat" command file, in the root folder of your SD server.
44 | Without Authentication:
45 | set COMMANDLINE_ARGS= --api
46 | ; Or with Authentication:
47 | set COMMANDLINE_ARGS=--listen --api --api-auth YOUR_USERNAME:YOUR_PASSWORD --cors-allow-origins=*
48 |
49 | 3. Either, Download the stable-diffusion-unity-integration repository, for example by running `git clone https://github.com/dobrado76/Stable-Diffusion-Unity-Integration.git`. Then, Open the stable-diffusion-unity-integration project in Unity.then open the Demo Scene provided in the package found in `StableDiffusionIntegration/Scenes/DemoScene.unity`.
50 |
51 | Or;
52 |
53 | 3. Create and open a new Unity project for Built-in Pipeline, download and import the stable-diffusion-unity-integration.unitypackage file into the project (https://github.com/dobrado76/Stable-Diffusion-Unity-Integration/blob/main/Stable-Diffusion-Unity-Integration.unitypackage). By starting from a new project and importing the package, none of the demo pre-generated images will be available in the Asset folder but the project should work as-is, since the textures and images are embedded in the Unity project.
54 |
55 | 4. Open the Demo Scene provided in the package found in `StableDiffusionIntegration/Scenes/DemoScene.unity`. There is a version with Post-Processing (you need to install the Post-Processing package, you will need to re-open the scene after installing the package) and a version without Post-Processing.
56 |
57 | 5. Select the StableDiffusionConfiguration component and make sure the selected setting point to the correct URL and Port (default: http://127.0.0.1:7860/).
58 | 6. Click on the `List Model` button to get the list of all available models from your local Stable Diffusion server.
59 |
60 | 
61 |
62 | 7. Select any existing GameObject with a MeshRenderer (or that contains at least one child with a MeshRenderer) or an Image (or RawImage) and click Generate from the StableDiffusionText2Material, StableDiffusionText2Image or StableDiffusionImage2Image component to generate a new image using the specified parameters.
63 |
64 | 
65 |
66 | 8. If any error occured, it should be catched by a try/catch and the exception displayed in the Unity Console.
67 |
68 | - The StableDiffusionMaterial component requires to be added to a GameObject that has a MeshRenderer (if apply recursively is not used) or have at least one children GameObject (if apply recursively is used).
69 | - The StableDiffusionImage component requires to be added to a UI GameObject (in a Canvas hierachy) that has an Image or RawImage component.
70 |
71 |
72 | # Limitations
73 | Be aware of a few limitations:
74 | - This repo has been testing only in some versions of Unity (2019, 2020, 2021 and Unity 6). It is believed that it has only basic low level Unity dependencies and should work in any versions.
75 | - The components for generating materials are designed for the Built-in render pipeline and Universal Render Pipeline (URP) only. It may be easy to get it to work for HDRP but no effort has been done in that regard. Feel free to contribute your changes if you make it work.
76 |
77 |
78 | # Contributing
79 | To contribute, clone the repository, make your changes, commit and push to your clone, and submit a pull request (PR).
80 |
81 | Before submitting a PR, make sure that:
82 | - you do not add multiple unrelated things in same PR.
83 | - your changes do not break anything before submitting.
84 | - you do not submit PRs where you just take existing lines and reformat them without changing what they do.
85 |
86 | If you think you found a bug, please first make sure that you are using the latest version of both this repo (as well as the Stable Diffusion repo) and that the bug has not already been fixed.
87 | If you are submitting a bug fix, there must be a way for me to reproduce the bug. Please, provide step-by-step instructions on how to reproduce the bug.
88 |
89 |
90 | # Credits
91 | Thanks to [UnityCoder](https://github.com/unitycoder/NormalMapFromTexture) for a straightforward and functional algorithm to automatically generate a normal map from a texture. - https://github.com/unitycoder/NormalMapFromTexture.
92 | Also, thanks to [ALBRRT](https://github.com/albrrt), [FOXYTOCIN](https://github.com/Foxytocin), [PeixuanL](https://github.com/PeixuanL) for their contributions here.
93 | Additional thank you to [TeoVibe](https://github.com/TeoVibe) for adding suport to online cloud Runpod server, as well as a more solid error catching/handling in various situations.
94 |
95 | # Licence
96 | This repository is under Lesser General Public License (LGPL) v2.1, that you can find in the `LICENSE` file (https://github.com/dobrado76/Stable-Diffusion-Unity-Integration/blob/72560920786b909e829b567567699f332256ea19/LICENSE).
97 |
98 | Mainly, it allows you to:
99 | - use or distribute any artwork generated using this tool without the need to mention this tool, repo or author.
100 | - use, modify, and distribute this code base and other copyrighted work.
101 | - create derivative works to be distributed under a different license than the original.
102 |
103 | Requires that the source code for the derative work be made available to others. This does not introduce any limitations on your own Unity projects, since this tool is a Design time, Editor only tool (your game or application is obviously not required to be open source).
104 | Requires that any partial, full or modified distribution of this repo mentions the original source (this repo/author).
105 |
106 |
107 | # Change Log
108 | 2025-03-30: v1.3.0 - Merged Pull Request from [TeoVibe](https://github.com/TeoVibe), thanks for your contribution adding support for online cloud Runpod server.
109 |
110 | 2023-03-15: v1.2.6 - Added StableDiffusionImage2Material, thanks to [PeixuanL](https://github.com/PeixuanL).
111 |
112 | 2023-03-10: v1.2.5 - Merged Pull Request from [FOXYTOCIN](https://github.com/Foxytocin) to add support for Authentication API keys and URP materials.
113 |
114 | 2023-02-02: v1.2.4 - Merged Pull Request from [ALBRRT](https://github.com/albrrt) to add support for Image-2-Image for UI Image and RawImage. To that effect, renamed StableDiffusionImage to StableDiffusionText2Image and StableDiffusionMaterial to StableDiffusionText2Material, and added a new StableDiffusionImage2Image component.
115 |
116 | 2023-01-31: v1.2.3 - Merged Pull Request from [ALBRRT](https://github.com/albrrt) to fix an issue with progress bar when generating an image with StableDiffusionImage. Not perfect but somewhat/sometimes working ok.
117 |
118 | 2023-01-31: v1.2.2 - Changed the call to Stable Diffusion server to be asynchronous and non-blocking. Also added a Progress Bar for generation progress feedback.
119 |
120 | 2023-01-30: v1.2.1 - Added some comments in the code and updated the package with new codebase, to include last merge and post-processing settings for the demo scene with post-processing.
121 |
122 | 2023-01-25: v1.2.0 - Merged Pull Request from [ALBRRT](https://github.com/albrrt) to enable Editor assets refresh only when not in Play mode, or returning from Play mode. Also added the display of the GUID for easier reference between the Component and the Image file.
123 |
124 | 2023-01-24: v1.1.0 - Added handling of the samplers as generation parameter. Manual list in StableDiffusionConfiguration that can be culled to remove samplers that you don't use.
125 |
126 | 2023-01-23: v1.0.0 - Initial public distribution version 1.0.0 with brief documentation.
127 |
--------------------------------------------------------------------------------
/SDConfiguration.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/SDConfiguration.png
--------------------------------------------------------------------------------
/SDImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/SDImage.png
--------------------------------------------------------------------------------
/SDListModels.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/SDListModels.png
--------------------------------------------------------------------------------
/SDLogo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/SDLogo.jpg
--------------------------------------------------------------------------------
/SDMaterial.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/SDMaterial.png
--------------------------------------------------------------------------------
/SDSettings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/SDSettings.png
--------------------------------------------------------------------------------
/Stable-Diffusion-Unity-Integration.unitypackage:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/Stable-Diffusion-Unity-Integration.unitypackage
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dobrado76/Stable-Diffusion-Unity-Integration/82ad37027051a91161f70f340fb6b1a5fbfda540/screenshot.png
--------------------------------------------------------------------------------