Runtime Usage
With Sloyd, you can even generate 3D models at runtime!
Sliders, toggles and buttons are automatically available for use during playmode.
This section will show you how to access parameter control through code.
Spawning A Sloyd Object In Play Mode
Add a reference to an existing SloydAsset:
Create SloydObject via its constructor:
Call SloydObject.RebuildMesh()
each time you create new SloydObject or update its controls (see more about controls below)
Editing A Sloyd Object In Play Mode
In edit mode you have sliders, checkboxes and buttons to edit a Sloyd object. The same functions can be accessed by code.
There are two types of SloydObject's control collections: unique controls specified for a concrete template and common controls which are same for each template.
Here is the way to get access to these two types of controls:
Each ControlsCollection contains different sets of controls:
SliderControl
A container for float
value between 0 and 1.
Example slider (from web app)
ToggleControl
A container for bool
value. Typically turns parts off/on, or switches between different states.
Example toggles:
SwitchListControl
A container for named and indexed items. Allows the user to switch between various parts of a model.
Example switch list:
GroupControl
A container for sets of Slider-, Toggle- and SwitchList controls. A group can be disabled if it has a toggle controller.
Example groups, with and without toggle:
Unique controls are specific controls/parameters for a given generator.
Common controls are shared across all generators.
Random values
You are also able to set random values to whole collection by calling ControlsCollection.Randomize()
Important common controls
Currently all Sloyd Objects have following common controls:
LOD – Level Of Detail slider.
Wack – controls group with a set of sliders for deforming a Sloyd Object in different ways.
Moving and Rotating A Sloyd Object In Play Mode
You can translate and rotate an object via SloydObject.Position
and SloydObject.Rotation
properties or directly by using its Transform
**Next, see:**AI prompting in play mode (https://doc.clickup.com/d/h/kh4k0-705/ed114594b2af381/kh4k0-7695)