2
2
3
3
[ ![ openupm] ( https://img.shields.io/npm/v/com.rest.blockadelabs?label=openupm®istry_uri=https://package.openupm.com )] ( https://openupm.com/packages/com.rest.blockadelabs/ )
4
4
5
- A BlockadeLabs package for the [ Unity] ( https://unity.com/ ) Game Engine.
5
+ A non-official [ BlockadeLabs] ( https://www.blockadelabs.com/ ) Skybox AI RESTful client for the [ Unity] ( https://unity.com/ ) Game Engine.
6
+
7
+ I am not affiliated with BlockadeLabs and an account with api access is required.
8
+
9
+ *** All copyrights, trademarks, logos, and assets are the property of their respective owners.***
6
10
7
11
## Installing
8
12
13
+ Requires Unity 2021.3 LTS or higher.
14
+
15
+ The recommended installation method is though the unity package manager and [ OpenUPM] ( https://openupm.com/packages/com.openai.unity ) .
16
+
9
17
### Via Unity Package Manager and OpenUPM
10
18
11
19
- Open your Unity project settings
@@ -15,7 +23,7 @@ A BlockadeLabs package for the [Unity](https://unity.com/) Game Engine.
15
23
- Name: ` OpenUPM `
16
24
- URL: ` https://package.openupm.com `
17
25
- Scope(s):
18
- - ` com.rest `
26
+ - ` com.rest.blockadelabs `
19
27
- ` com.utilities `
20
28
- Open the Unity Package Manager window
21
29
- Change the Registry from Unity to ` My Registries `
@@ -25,11 +33,112 @@ A BlockadeLabs package for the [Unity](https://unity.com/) Game Engine.
25
33
26
34
- Open your Unity Package Manager
27
35
- Add package from git url: ` https://github.com/RageAgainstThePixel/com.rest.blockadelabs.git#upm `
36
+ > Note: this repo has dependencies on other repositories! You are responsible for adding these on your own.
37
+ - [ com.utilities.async] ( https://github.com/RageAgainstThePixel/com.utilities.async )
38
+ - [ com.utilities.rest] ( https://github.com/RageAgainstThePixel/com.utilities.rest )
28
39
29
40
## Documentation
30
41
31
- ### Project Setup
42
+ ### Table of Contents
43
+
44
+ - [ Authentication] ( #authentication )
45
+ - [ Skyboxes] ( #skyboxes )
46
+ - [ Get Skybox Styles] ( #get-skybox-styles )
47
+ - [ Generate Skybox] ( #generate-skybox )
48
+ - [ Get Skybox by Id] ( get-skybox )
49
+
50
+ ### Authentication
51
+
52
+ There are 4 ways to provide your API keys, in order of precedence:
53
+
54
+ 1 . [ Pass keys directly with constructor] ( #pass-keys-directly-with-constructor )
55
+ 2 . [ Unity Scriptable Object] ( #unity-scriptable-object )
56
+ 3 . [ Load key from configuration file] ( #load-key-from-configuration-file )
57
+ 4 . [ Use System Environment Variables] ( #use-system-environment-variables )
58
+
59
+ #### Pass keys directly with constructor
60
+
61
+ ``` csharp
62
+ var api = new BlockadeLabsClient (" yourApiKey" );
63
+ ```
64
+
65
+ Or create a ` BlockadeLabsAuthentication ` object manually
66
+
67
+ ``` csharp
68
+ var api = new BlockadeLabsClient (new BlockadeLabsAuthentication (" yourApiKey" ));
69
+ ```
70
+
71
+ #### Unity Scriptable Object
72
+
73
+ You can save the key directly into a scriptable object that is located in the ` Assets/Resources ` folder.
74
+
75
+ You can create a new one by using the context menu of the project pane and creating a new ` BlockadeLabsConfiguration ` scriptable object.
76
+
77
+ ![ Create new BlockadeLabsConfiguration] ( images/create-scriptable-object.png )
78
+
79
+ #### Load key from configuration file
80
+
81
+ Attempts to load api keys from a configuration file, by default ` .blockadelabs ` in the current directory, optionally traversing up the directory tree or in the user's home directory.
82
+
83
+ To create a configuration file, create a new text file named ` .blockadelabs ` and containing the line:
84
+
85
+ ##### Json format
86
+
87
+ ``` json
88
+ {
89
+ "apiKey" : " yourApiKey" ,
90
+ }
91
+ ```
92
+
93
+ You can also load the file directly with known path by calling a static method in Authentication:
94
+
95
+ ``` csharp
96
+ var api = new BlockadeLabsClient (BlockadeLabsAuthentication .Default .LoadFromDirectory (" your/path/to/.blockadelabs" ));;
97
+ ```
98
+
99
+ #### Use System Environment Variables
100
+
101
+ Use your system's environment variables specify an api key to use.
102
+
103
+ - Use ` BLOCKADE_LABS_API_KEY ` for your api key.
104
+
105
+ ``` csharp
106
+ var api = new BlockadeLabsClient (BlockadeLabsAuthentication .Default .LoadFromEnvironment ());
107
+ ```
108
+
109
+ ### Skyboxes
110
+
111
+ #### [ Get Skybox Styles] ( https://blockade.cloudshell.run/redoc#tag/skybox/operation/Get_Skybox_Styles_api_v1_skybox_styles_get )
112
+
113
+ Returns the list of predefined styles that can influence the overall aesthetic of your skybox generation.
114
+
115
+ ``` csharp
116
+ var api = new BlockadeLabsClient ();
117
+ var skyboxStyles = await api .SkyboxEndpoint .GetSkyboxStylesAsync ();
118
+
119
+ foreach (var skyboxStyle in skyboxStyles )
120
+ {
121
+ Debug .Log ($" {skyboxStyle .Name }" );
122
+ }
123
+ ```
124
+
125
+ #### [ Generate Skybox] ( https://blockade.cloudshell.run/redoc#tag/skybox/operation/Generate_Skybox_api_v1_skybox_generate_post )
126
+
127
+ Generate a skybox image
128
+
129
+ ``` csharp
130
+ var api = new BlockadeLabsClient ();
131
+ var request = new SkyboxRequest (" underwater" , depth : true );
132
+ var skyboxInfo = await api .SkyboxEndpoint .GenerateSkyboxAsync (request );
133
+ skyboxMaterial .mainTexture = skyboxInfo .MainTexture ;
134
+ skyboxMaterial .depthTexture = skyboxInfo .DepthTexture ;
135
+ ```
136
+
137
+ #### [ Get Skybox] ( https://blockade.cloudshell.run/redoc#tag/skybox/operation/Get_Skybox_By_Id_api_v1_skybox_info__id__get )
138
+
139
+ Returns the skybox metadata for the given skybox id.
32
140
33
141
``` csharp
34
- // TODO
142
+ var skyboxInfo = await api .SkyboxEndpoint .GetSkyboxInfoAsync (" skybox-id" );
143
+ Debug .Log ($" Skybox: {result .Id } | {result .MainTextureUrl }" );
35
144
```
0 commit comments