Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Latest commit

 

History

History
144 lines (97 loc) · 4.92 KB

README.md

File metadata and controls

144 lines (97 loc) · 4.92 KB

com.rest.blockadelabs

openupm

A non-official BlockadeLabs Skybox AI RESTful client for the Unity Game Engine.

I am not affiliated with BlockadeLabs and an account with api access is required.

All copyrights, trademarks, logos, and assets are the property of their respective owners.

Installing

Requires Unity 2021.3 LTS or higher.

The recommended installation method is though the unity package manager and OpenUPM.

Via Unity Package Manager and OpenUPM

  • Open your Unity project settings
  • Select the Package Manager scoped-registries
  • Add the OpenUPM package registry:
    • Name: OpenUPM
    • URL: https://package.openupm.com
    • Scope(s):
      • com.rest.blockadelabs
      • com.utilities
  • Open the Unity Package Manager window
  • Change the Registry from Unity to My Registries
  • Add the BlockadeLabs package

Via Unity Package Manager and Git url

  • Open your Unity Package Manager
  • Add package from git url: https://github.com/RageAgainstThePixel/com.rest.blockadelabs.git#upm

    Note: this repo has dependencies on other repositories! You are responsible for adding these on your own.

Documentation

Table of Contents

Authentication

There are 4 ways to provide your API keys, in order of precedence:

  1. Pass keys directly with constructor
  2. Unity Scriptable Object
  3. Load key from configuration file
  4. Use System Environment Variables

Pass keys directly with constructor

var api = new BlockadeLabsClient("yourApiKey");

Or create a BlockadeLabsAuthentication object manually

var api = new BlockadeLabsClient(new BlockadeLabsAuthentication("yourApiKey"));

Unity Scriptable Object

You can save the key directly into a scriptable object that is located in the Assets/Resources folder.

You can create a new one by using the context menu of the project pane and creating a new BlockadeLabsConfiguration scriptable object.

Create new BlockadeLabsConfiguration

Load key from configuration file

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.

To create a configuration file, create a new text file named .blockadelabs and containing the line:

Json format
{
  "apiKey": "yourApiKey",
}

You can also load the file directly with known path by calling a static method in Authentication:

var api = new BlockadeLabsClient(BlockadeLabsAuthentication.Default.LoadFromDirectory("your/path/to/.blockadelabs"));;

Use System Environment Variables

Use your system's environment variables specify an api key to use.

  • Use BLOCKADE_LABS_API_KEY for your api key.
var api = new BlockadeLabsClient(BlockadeLabsAuthentication.Default.LoadFromEnvironment());

Skyboxes

Returns the list of predefined styles that can influence the overall aesthetic of your skybox generation.

var api = new BlockadeLabsClient();
var skyboxStyles = await api.SkyboxEndpoint.GetSkyboxStylesAsync();

foreach (var skyboxStyle in skyboxStyles)
{
    Debug.Log($"{skyboxStyle.Name}");
}

Generate a skybox image

var api = new BlockadeLabsClient();
var request = new SkyboxRequest("underwater", depth: true);
var skyboxInfo = await api.SkyboxEndpoint.GenerateSkyboxAsync(request);
skyboxMaterial.mainTexture = skyboxInfo.MainTexture;
skyboxMaterial.depthTexture = skyboxInfo.DepthTexture;

Returns the skybox metadata for the given skybox id.

var skyboxInfo = await api.SkyboxEndpoint.GetSkyboxInfoAsync("skybox-id");
Debug.Log($"Skybox: {result.Id} | {result.MainTextureUrl}");