Sloyd Documentation
Sloyd AILogin
  • About Sloyd
    • How Sloyd Works
    • AI Prompting in Sloyd
    • Texturing and Painting Sloyd Exports
  • Products
    • API
    • Unity Plugin
    • Unity SDK
Powered by GitBook
On this page
  • Exposing AI Prompting In Play Mode
  • Exposing AI Editing In Play Mode
  • Configuring AI to also color the object based on prompt
  1. Products
  2. Unity SDK
  3. Runtime Usage

AI Prompting at Runtime

To fully understand how to use AI prompting in play mode, ask your Sloyd contact (or email ) for the example file "SloydAiExampleIntegration.unitypackage" and look at the scene called "AIPromptExample"

Exposing AI Prompting In Play Mode

  1. Open Scene AIPromptExample

  2. Inside you can see a very rudimental UI and object ExampleAIPrompt

  3. For Spawning an object we need two things:

    1. SloydAICredentials (we created that in Setup phase)

    2. SloydCachedTemplates (we will talk about this later)

  4. This script is very simple all it does is takes text from Input field and passes it to SloydSDK when button is pressed.

  5. This is done via SloydAIRuntime class (all runtime functionalities are packed in this class, for editor functionalities we have SloydAIEditor)

public async void Awake()
{
    await SloydAIRuntime.Authenticate(_credentials);
    _button.onClick.AddListener(OnButtonClicked);
}

private void OnButtonClicked()
{
    Prompt(_inputField.text);
}
public async void Prompt(string prompt)
{
    SloydObject sloydObject = await SloydAIRuntime.RequestSloydObject(prompt, _cachedTemplates);
}
  1. On Awake we authenticate (you can put this method on your application start).

  2. Then on button click we pass prompt to helper class that returns SloydObject with which you can work


Exposing AI Editing In Play Mode

  1. Open Scene AIPromptExample

  2. For Spawning an object we need two things:

    1. SloydAICredentials (we created that in Setup phase)

    2. SloydObjectContainer (on object where we will perform edits)

  3. This script is very simple all it does is takes text from Input field and passes it to SloydSDK when button is pressed.

  4. This is done via SloydAIRuntime class (all runtime functionalities are packed in this class, for editor functionalities we have SloydAIEditor)

public async void Awake()
{
    await SloydAIRuntime.Authenticate(_credentials);
    _button.onClick.AddListener(OnButtonClicked);
}

private void OnButtonClicked()
{
    AIEdit(_inputField.text);
}

private async void AIEdit(string prompt)
{
    _statusText.text = "Ok I am working on it";
    string humanMessage = await SloydAIRuntime.AiEditingRequest(prompt, _container);
    _statusText.text = humanMessage;
    await _container.SloydObject.RebuildMesh();
}
  1. On Awake we authenticate (you can put this method on your application start).

  2. Then on button click we pass prompt to helper class that changes properties SloydObject. And then we need to rebuild mesh with this new properties

Configuring AI to also color the object based on prompt

By default AI prompting does not understand color information. For example if you ask for a "Yellow school bus" you'll get the shape of a school bus but the color might be a different default color. If you want the AI to also change colors based on the prompt you need to enable it, here's how:

await SloydAIHelper.RecolorSloydObject(sloydObject, textPrompt, nogResponse.objectId, _paletteCollectionScriptableObject, authorizationToken); 

And you'll get a response like this:

SloydAIHelper.NogOutput nogResponse = await SloydAIHelper.ClipRequest(input.Prompt, input.Token).Value;

To fully understand how to use AI prompting in play mode, ask your Sloyd contact () for an example file: SloydAiExampleIntegration.unitypackage. and look at the scene called "AIEditExample".

Inside you can see a very rudimental UI and object ExampleAIEdit

hello@sloyd.ai
hello@sloyd.ai