A stack is a 2D object in Spark AR Studio. Use it to easily set the position of 2D objects by laying them out in positions relative to each other and their parent object. Stacks are particularly useful for creating frames, UI, games and other 2D effects.
The stack object itself won’t render anything in your effect, unless you add a material to it. Instead, it acts as a container for any 2D objects added as children.
To add a stack to your project:
To make it easier to edit and position 2D objects like stacks, click Mode and then Edit 2D Objects at the top of the Viewport. Here’s how the stack will look:
You can add the following 2D objects as children of a stack:
In the example below, we’ve added 3 rectangles as children of a stack:
The stack and each rectangle have materials applied to them. In the Inspector we’ve edited the stack's properties, setting:
Edit a stack by adjusting its properties in the Inspector. This will control things like the direction child objects are positioned in, how objects are distributed along the stack’s axis, and the space between objects.
Alignment
Alignment moves the rectangle around within the parent object. Rectangles can be aligned to the top, center, bottom, left and right.
Visible
Clear this box to stop the stack from being rendered in the scene.
Width and Height
Adjust the width and height of the stack.
You can adjust these values to fill the width and height of the parent canvas. To do this:
Width and Height can either be set to Fixed or Relative:
Pinning
Pinning a stack means it will maintain the same distance to its parent's border - however much you transform the parent. Stacks can be pinned to the top, bottom, left and right.
Direction
A stack can be used to arrange child objects in a horizontal or vertical direction:
Distribute
Edit Distribute to control where objects are placed along a stack’s main axis. There are six options:
Alignment
Adjust Alignment to controls where objects are placed along the stack’s cross axis.
Padding
Padding controls the amount of space between the stack's edges. Selecting:
Padding is affected by the Distribution setting. For example, when Distribution is set to Horizontal, left padding applies but right padding does not. Set Distribution to Space Between to apply padding to both sides.
Transformations
Edit the Scale and Rotation of the slack object. Selecting:
Material
Create a new material for the rectangle or apply an existing one. Once you've added a material to a rectangle, you can add textures and color to the material to change the appearance of the rectangle in the scene.
Enable for
When the boxes are selected next to Front Camera and Back Camera the rectangle will be visible through both the front and back camera on a device.
When the boxes are selected next to Preview and Capture the rectangle will be visible both before the person using your effect is capturing a video and during capture.
Interactions
Insert simple combinations of patches into the Patch Editor, like tap gestures.