Creating Buildable Object SO Assets
Last updated
Last updated
Now that we have five Buildable Objects ready to use in our grid, the next step is to create Buildable Object SO assets. These assets store data that defines how the Buildable Object prefabs behave in the Easy Grid Builder Pro 2 system.
As a reminder, there are four Buildable Object Types, and corresponding to those, there are four Buildable Object SO types. These are scriptable objects that hold data specific to the Buildable Objects.
Inside the 2D City Builder Tutorial Demo folder, create a new folder and name it Buildable Objects SO Assets.
Right-click inside the new folder and select: Create > SoulGames > Easy Grid Builder Pro 2 > Buildable Grid Object SO. Rename the newly created asset to: Buildable Grid Object SO - TopDown House 01.
This process creates a Buildable Grid Object SO asset.
As you can see, the Buildable Object SO asset includes many properties. In this guide, we’ll focus on the most essential ones needed to quickly set up our City Builder. For detailed information on all the features, refer to the following links:
Set the Object Name
Use the same name as the Buildable Object. For example: TopDown House 01.
Set the Object Icon
For the Object Icon property, assign a sprite image to represent the Buildable Object in the UI.
Since we are using 2D sprites, we don’t need an additional icon. Simply use the TopDown House 01 sprite located in: 2D City Builder Tutorial Demo > 2D Top Down Sprites.
Now, let’s set up the Buildable Object Category SO property for our Buildable Grid Object SO - TopDown House 01 asset.
Inside the Buildable Objects SO Assets folder, right-click and select: Create > SoulGames > Easy Grid Builder Pro 2 > Buildable Grid Object Category SO. Name the new asset: Buildable Grid Object Category SO - TopDown Tutorial.
Each Buildable Object SO asset requires a corresponding Category SO asset. Similar to the Buildable Object SO types, there are four Buildable Object SO Category types:
It’s highly recommended to read more about these assets through the provided links.
Category SO assets allow layered placement of objects on grid cells. For example: A Floor Buildable Grid Object occupies 1 grid cell and has a category called Modular Parts. A Bed Buildable Grid Object also occupies 1 grid cell but has a category called Furniture. Since the two objects belong to different categories, they can occupy the same grid cell simultaneously.
In the Buildable Grid Object SO - TopDown House 01 asset, assign the newly created Buildable Grid Object Category SO - TopDown Tutorial to the Buildable Object Category SO property.
This completes the setup for the Buildable Object Category SO. For this tutorial, we only need one category, so you can reuse this asset for other Buildable Grid Object SO assets.
The Buildable Object UI Category SO property is used to categorize Buildable Objects in the Easy Grid Builder Pro 2 UI. To set it up:
In the Buildable Objects SO Assets folder, right-click and select: Create > SoulGames > Easy Grid Builder Pro 2 > Buildable Object UI Category SO. Name the new asset Buildable Object UI Category SO - Houses.
Open the asset and set the following:
Category Name: Set it to Houses.
Category Icon: Use the TopDown House 01 sprite from 2D City Builder Tutorial Demo > 2D Top Down Sprites.
Alternatively, you can assign any other icon that fits your needs.
This UI Category SO helps organize Buildable Objects into categories within the Easy Grid Builder Pro 2 UI, improving the clarity and usability of the interface.
Now, simply assign the newly created Buildable Object UI Category SO - Houses asset to the Buildable Object UI Category SO property in the Buildable Grid Object SO - TopDown House 01 asset.
Now, let’s configure the Random Prefabs property in the Buildable Grid Object SO - TopDown House 01 asset. This property allows you to assign one or more Buildable Objects, setting the probability for selecting a random one when the object is placed on the grid. For this asset, we’ll use just one prefab.
Click the + icon next to the Random Prefabs property to create a new element.
In the new element, locate the Object Prefab property. Drag and drop the TopDown House 01 Buildable Object prefab from: 2D City Builder Tutorial Demo > 2D Buildable Objects.
Locate the Ghost Object Prefab property. Drag and drop the same TopDown House 01 prefab here as well. (Alternatively, you can assign a different prefab to use a unique ghost object for placement visualization. If you do this, the ghost object will be shown during placement, but the final object will be the prefab assigned to the Object Prefab property.)
The Probability slider determines the likelihood of selecting this prefab if multiple prefabs are added. Since we’re only using one prefab, leave this value at 0.
Finally, let’s configure the Object Placement Type property in the Buildable Grid Object SO - TopDown House 01 asset.
Locate the Object Placement Type property. By default, it is set to Single Placement. Open the dropdown menu and select Box Placement.
This option allows the TopDown House 01 object to be placed using the Box Placement method, ideal for creating multiple instances in a defined area.
For this tutorial, we’ll leave all other properties as default. This completes the configuration for the Buildable Grid Object SO - TopDown House 01 asset.
To create two more Buildable Grid Object SO assets, follow these steps:
Select the Buildable Grid Object SO - TopDown House 01 asset.
Press Ctrl + D to duplicate it twice, creating two new assets.
Rename the second asset to Buildable Grid Object SO - TopDown House 02.
Change the Object Name
Open the Buildable Grid Object SO - TopDown House 02 asset.
Set the Object Name property to TopDown House 02.
Update the Object Icon
Replace the Object Icon property with the TopDown House 02 sprite, located in: 2D City Builder Tutorial Demo > 2D Top Down Sprites.
Modify the Random Prefabs Section
In the Random Prefabs section, locate the first element.
Update the Object Prefab and Ghost Object Prefab properties with the TopDown House 02 Buildable Object Prefab from: 2D City Builder Tutorial Demo > 2D Buildable Objects.
Change the Object Placement Type
Set the Object Placement Type property to Single Placement.
Follow these steps to configure the Buildable Grid Object SO - TopDown House 03 asset:
Rename the Object Name
Open the Buildable Grid Object SO - TopDown House 03 asset.
Set the Object Name property to TopDown House 03.
Update the Object Icon
Replace the Object Icon property with the TopDown House 03 sprite, located in: 2D City Builder Tutorial Demo > 2D Top Down Sprites.
Modify the Random Prefabs Section
In the Random Prefabs section, locate the first element.
Replace the Object Prefab and Ghost Object Prefab properties with the TopDown House 03 Buildable Grid Object Prefab from: 2D City Builder Tutorial Demo > 2D Buildable Objects.
Set the Object Placement Type
Change the Object Placement Type property to Paint Placement.
As you know, our smallest Buildable Grid Object is TopDown House 01. However, as we saw earlier, it occupies 2 x 2 grid cells when placed because our Grid Cell Size is set to 1.
When using any Box Placement Types (e.g., Box Placement, Wire Box Placement, Four Directional Wire Placement, or L-Shaped Placement), it is recommended to use objects that occupy only 1 x 1 grid cells (one cell) for optimal functionality.
For example, TopDown House 01 would occupy only 1 cell if we increased the Grid Cell Size to 2. However, for this guide, we will keep the Grid Cell Size at 1 and proceed accordingly.
Now let’s create a Buildable Free Object SO asset for the trees:
Create a New Buildable Free Object SO Asset
Inside the Buildable Objects SO Assets folder, right-click and select: Create > SoulGames > Easy Grid Builder Pro 2 > Buildable Free Object SO.
Rename the new asset to Buildable Free Object SO - TopDown Tree.
Configure the Asset
Set the Object Name property to TopDown Tree.
For the Object Icon, assign the TopDown Tree 01 sprite located in: 2D City Builder Tutorial Demo > 2D Top Down Sprites.
Since we cannot use the previously created Buildable Grid Object Category SO - TopDown Tutorial asset (as it’s for Grid Objects), follow these steps:
Right-click in the Buildable Objects SO Assets folder and select: Create > SoulGames > Easy Grid Builder Pro 2 > Buildable Free Object Category SO.
Rename the new asset to Buildable Free Object Category SO - TopDown Tutorial.
Drag and drop this asset into the Buildable Object Category SO property of the Buildable Free Object SO - TopDown Tree asset.
For the Buildable Object UI Category SO, we could use a different asset to show the object in a new UI category. However, for simplicity, we’ll reuse the existing Buildable Object UI Category SO - Houses. Assign it to the Buildable Object UI Category SO property.
Add two elements to the Random Prefabs section by clicking the + button twice. For the First Element:
Object Prefab: Assign the TopDown Tree 01 Buildable Free Object Prefab.
Ghost Object Prefab: Assign the same TopDown Tree 01 Buildable Free Object Prefab.
Probability: Set to 50 (50%).
For the Second Element:
Object Prefab: Assign the TopDown Tree 02 Buildable Free Object Prefab.
Ghost Object Prefab: Assign the same TopDown Tree 02 Buildable Free Object Prefab.
Probability: Set to 50 (50%).
With this setup, the Buildable Free Object SO - TopDown Tree asset will randomly choose between TopDown Tree 01 and TopDown Tree 02 when placing objects on the grid. Each has an equal probability of being selected.
For Buildable Free Objects, you can select one of three placement types. For this object, we’ll use Spline Placement. Set the Object Placement Type to Spline Placement. This will reveal additional properties. Adjust them as follows:
Base Spacing Along Spline: 1 (Defines the space between each object along the spline.)
Min Spacing Along Spline: 0.5 (Specifies the minimum allowable spacing between objects, used with spline space adjustment inputs.)
Max Spacing Along Spline: 2 (Specifies the maximum allowable spacing between objects, used with spline space adjustment inputs.)
Rotate Towards Spline Direction: False (Prevents objects from automatically rotating to follow the spline’s direction.)
Input Space Change Speed: 0.5 (Controls the speed at which spacing changes when using input adjustments.)
Spline Tangent Mode: Auto Smooth (Automatically smooths spline tangents for clean curves.)
Closed Spline: False (Keeps the spline open, rather than looping into a closed shape.)
And that’s it for the Buildable Object SO assets! Now, complete the setup by following these steps:
Drag and drop all three Buildable Grid Object SO assets we created into the Buildable Grid Object SO List property located in the Grid Buildables section of the Easy Grid Builder Pro XY component.
Drag and drop the Buildable Free Object SO asset we created into the Buildable Free Object SO List property in the same section.
This links the Buildable Object SO assets to the grid system, making them ready for use.