Advanced Play Mode Functions
Saving objects
You might want to save a Sloyd object at runtime. If, for example, a player created an object while playing and she wants to save her progress and get back to it later.
The way to accomplish this you need to turn the object, at it's current state, into a json file and save it (in Sloyd objects are made out of code that's stored in json). Then, at loading, you need to retrieve the json file and create a mesh object.
First for exporting a Sloyd object into json file, follow these steps:
Create a JsonExporter class
Then run this function
You're ready to export the file
Alternatively, you can manually save the file with:
Now when it's time to load a game with Sloyd objects, you'll need to create a SloydObject instance via its constructor:
Fetching object metadata
When an object is generated out of a text prompt it also comes with metadata. One important field in the metadata is 'confidence score'. The confidence score is a ranking of how close the generated model is to the text prompt. You can read more about it in Using Confidence Score (https://doc.clickup.com/d/h/kh4k0-705/ed114594b2af381/kh4k0-8035)
First, make this call to fetch metadata:
The ClipResponse contains the following metadata:
Once you get a response, the call you can call:
To get your sloyd object created.
Configuring object properties
A Sloyd object can be turned into a static object. You can read more about it in Edit Mode (https://doc.clickup.com/d/h/kh4k0-705/ed114594b2af381/kh4k0-7555) at the last section "Configuring Sloyd object properties".
To change a dynamic Sloyd object to a static object at runtime you need to:
To change an object back to a dynamic object at runtime you need to:
To switch a Sloyd object to 'Solid Mesh' (see details in) mode you need to:
To make a Sloyd object non interactable (see details in) you need to: