# Make 2D Build System (LITE)

This guide will quickly walk through how to easily create an expandable 2D building system with Easy Grid Builder LITE features.

{% hint style="info" %}
This guide doesn't cover setting up Easy Grid Builder Pro settings and packages. It is highly recommended to read the [**Quick Start Guide**](../getting-started/quick-start-guide) and get your project all set up to work with Easy Grid Builder Pro before following this guide.
{% endhint %}

We will break this guide into smaller sections and will walk you through step by step.

## Step 01. Setting Up The Scene

Open **Demo 2D Tutorial** scene located in _**EasyGridBuilder Pro > Demo Scenes**_**.** Then select the Main Camera from the scene and set its Transform Position values to 0, 100, -10, and in the camera component change the Projection property to Orthographic and Size to 60. Now we have a proper 2D view.

The next step is to add EGB Pro prefab which is located in _**EasyGridBuilder Pro > Prefabs**_ and simply drag and drop it into the scene. Now right-click on EGB Pro prefab from the hierarchy and _**Prefab > Unpack Completely**_**.** This part is important, otherwise, it can cause unnecessary issues later.

For this guide, we only need one grid system therefore delete **Easy Grid Builder Pro XZ** child object inside EGB Pro object.

Now you will end up with a scene similar to the image below.

<figure><img src="https://4076857463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzgUHYggWkJIGXQGAerRm%2Fuploads%2Fy2X1qXw3zbQUq4sjq5mg%2FScreenshot_101.png?alt=media&#x26;token=abc76f07-5f46-4d55-929d-4e58443072c8" alt=""><figcaption></figcaption></figure>

## Step 02: Setting Up the Grid System

{% hint style="info" %}
To get a better understanding It is highly recommended to read the [Easy Grid Builder Pro Component](../primary-components/easy-grid-builder-pro) and all its functionalities before proceeding with this guide.
{% endhint %}

_**NOTE**: In this guide, we are using GRID LITE version of the Easy Grid Builder Pro component. Click on GRID LITE button to switch to GRID LITE mode. You can always switch back to GRID PRO version anytime._

Now select **Easy Grid Builder Pro XY** child object inside EGB pro object and set the CORE GRID properties as follows.

* [x] Grid Axis = XY
* [x] Grid Width = 20
* [x] Grid Length = 12
* [x] Cell Size  = 10
* [x] Use Holder Position As Origin = Enable

You can see when you change the properties the grid visual updates in real-time. Let's leave all other properties as default for now.

Now you will end up with a scene similar to the image below.

<figure><img src="https://4076857463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzgUHYggWkJIGXQGAerRm%2Fuploads%2FyOLZD0Be2EBCMTHgCPR5%2FScreenshot_103.png?alt=media&#x26;token=6cb3538d-cb92-4c32-9342-60ae6f26ac02" alt=""><figcaption></figcaption></figure>

## Step 03: Setting Up Buildable Prefabs

To use buildable objects in EGB Pro, we need to prepare buildable prefabs first. We will prepare 2 buildable prefabs in this guide.

First create a new folder in your scene to hold our two prefabs and name it to "**2D Prefabs"**. For our first prefab we will use the "**Blue"** sprite located in _**EasyGridBuilder Pro > Misc Assets > 2D Sprites.**_ **Drag & drop the sprite to your hierarchy and then again drag & drop it to newly created folder to create a prefab out of it. Then delete the object from your hierarchy.**

Now **Double click** on the prefab or **Right click** then select **Open** to open the prefab view. Then add a **Box Collider** component to the object. Now select the parent object "**Blue**" and add the [**Buildable Grid Object**](../primary-components/buildable-grid-object) component to it. Now **Enable** the "**Rotate Scale & Pivot For XY"** property and then simply click on [**Calculate Size & Pivot**](auto-pivot-and-scale-calculation) button to automatically calculate the pivot and scale.

_**NOTE**: The collider component that is added to the object sprite should be a 3D collider(a **Box Collider** in this case ). 2D colliders don't work the same. You can still add 2D colliders to the object with the 3D collider, for your own features._

Now you will end up with an object similar to the image below.

<figure><img src="https://4076857463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzgUHYggWkJIGXQGAerRm%2Fuploads%2FdYGBWfWmv3zbCbnlQiQV%2FScreenshot_139.png?alt=media&#x26;token=b14cf913-c2d1-481d-bba6-9e18e0cb9375" alt=""><figcaption></figcaption></figure>

Let's make our second object prefab. Similar to the previous steps, drag & drop the "**Yellow"** sprite located in _**EasyGridBuilder Pro > Misc Assets > 2D Sprites.**_ **Drag & drop the sprite to your hierarchy and then again drag & drop it to the** "**2D Prefabs" folder to create a prefab out of it. Then delete the object from your hierarchy.**

Now **Double click** on the prefab or **Right click** then select **Open** to open the prefab view. Then add a **Box Collider** component to the object. Now select the parent object "**Yellow**" and add the [**Buildable Grid Object**](../primary-components/buildable-grid-object) component to it. Now **Enable** the "**Rotate Scale & Pivot For XY"** property and then simply click on [**Calculate Size & Pivot**](auto-pivot-and-scale-calculation) button to automatically calculate the pivot and scale.

Now you will end up with an object similar to the image below.

<figure><img src="https://4076857463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzgUHYggWkJIGXQGAerRm%2Fuploads%2F8uH3kbOlMgi6QoOATV9B%2FScreenshot_140.png?alt=media&#x26;token=e80825b4-3d4e-4c7c-9f9b-fede6d08b964" alt=""><figcaption></figcaption></figure>

And that's it for the buildable prefab preparation. You can see the same process in the video down below.

{% embed url="https://youtu.be/DKhMHg-nLgw" %}

## Step 04: Setting Up Buildable Type SO Assets

In this step, we will create two scriptable object assets for our 2 buildable prefabs. These assets hold all the data of your buildable objects.

{% hint style="info" %}
To get a better understanding It is highly recommended to read about the [**Buildable Grid Object Type SO**](../scriptable-objects/buildable-grid-object-type-so) assets and all their functionalities before proceeding with this guide.
{% endhint %}

Now create a new folder in your project and name it "**Buildable 2D Grid Object Type SO Assets**" go to **Buildable 2D Grid Object Type SO assets** folder and _**right-click > Create > SoulGames > Easy Grid Builder Pro > Buildable Grid Object Type SO**_ and create a new "**Buildable Grid Object Type SO"** asset and name it as "**2D Building Small Buildable Grid Object Type SO**". You can see how to create the asset in the image below.

<figure><img src="https://4076857463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzgUHYggWkJIGXQGAerRm%2Fuploads%2F4gLCLTDxlFcfOhT18i6t%2FScreenshot_109.png?alt=media&#x26;token=5aa8c6bc-854a-4d90-b9d3-491342c56bb1" alt=""><figcaption></figcaption></figure>

_**NOTE**: This buildable object should snap to grid cells as that's the reason we are using the "**Buildable Grid Object Type SO"** asset instead of a "**Buildable Free Object Type SO"** asse&#x74;**.**_

Let's fill in the properties of our "**2D Building Small Buildable Grid Object Type SO"** asset as follows.

* [x] Unique Object Name = 2D Building Small
* [x] Object Prefab = Drag & drop previously created **2D Building Small** prefab
* [x] Placeable Ghost Material = Drag & drop **PlaceableVisualMat** material located in _**EasyGridBuilder Pro > Misc Assets > Materials**_
* [x] Not Placeable Ghost Material = Drag & drop **NotPlaceableVisualMat** material located in _**EasyGridBuilder Pro > Misc Assets > Materials**_
* [x] Show Grid Below Object = Enable
* [x] Object Grid Canvas = Drag & drop **Grid Canvas** prefab located in _**EasyGridBuilder Pro > Prefabs > Canvas Grid Samples**_
* [x] Grid Image Sprite = Drag & drop any sprite image from _**EasyGridBuilder Pro > Prefabs > Canvas Grid Samples**_**.** I'll be using **WhiteBoxMiddleEmpty02** sprite.
* [x] Grid Image Placeable Color = Set a blue color
* [x] Grid Image Not Placeable Color = Set a red color

Now your "**2D Building Small Buildable Grid Object Type SO"** should look similar to the image below.

<figure><img src="https://4076857463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzgUHYggWkJIGXQGAerRm%2Fuploads%2F1Xb1iiIenuvXjPs1WT22%2FScreenshot_142.png?alt=media&#x26;token=2df298c4-6916-44fc-a0e3-df73e539e480" alt=""><figcaption></figcaption></figure>

Now for our other buildable object go to the "**Buildable 2D Gird Object Type SO assets"** folder and _**right-click > Create > SoulGames > Easy Grid Builder Pro > Buildable Grid Object Type SO**_ and create another new "**Buildable Grid Object Type SO"** asset and name it as "**2D Building Big Buildable Grid Object Type SO**".

Let's fill in the properties of our "**2D Building Big Buildable Grid Object Type SO"** asset as follows.

* [x] Unique Object Name = 2D Building Big
* [x] Object Prefab = Drag & drop previously created **2D Building Big** prefab
* [x] Placeable Ghost Material = Drag & drop **PlaceableVisualMat** material located in _**EasyGridBuilder Pro > Misc Assets > Materials**_
* [x] Not Placeable Ghost Material = Drag & drop **NotPlaceableVisualMat** material located in _**EasyGridBuilder Pro > Misc Assets > Materials**_
* [x] Show Grid Below Object = Enable
* [x] Object Grid Canvas = Drag & drop **Grid Canvas** prefab located in _**EasyGridBuilder Pro > Prefabs > Canvas Grid Samples**_
* [x] Grid Image Sprite = Drag & drop any sprite image from _**EasyGridBuilder Pro > Prefabs > Canvas Grid Samples**_**.** I'll be using **WhiteBoxMiddleEmpty02** sprite.
* [x] Grid Image Placeable Color = Set a blue color
* [x] Grid Image Not Placeable Color = Set a red color

Now your "**2D Building Big Buildable Grid Object Type SO**" should look similar to the image below.

<figure><img src="https://4076857463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzgUHYggWkJIGXQGAerRm%2Fuploads%2F4O1V8kfnfsvfxPqNTAPg%2FScreenshot_141.png?alt=media&#x26;token=3b888275-62e0-4cfa-98de-e4c4bb71eb8c" alt=""><figcaption></figcaption></figure>

You can see the same process in the video down below.

{% embed url="https://youtu.be/KlcRZHgKyZY" %}

## Step 05: Finalize Buildable Prefabs

Now, to finalize our created buildable prefabs select each prefab and drag and drop created "**Type SO**" assets to their "**Buildable Grid Object**" component property fields.

You can see how it should look after you added the asset references to both prefabs.

<div><figure><img src="https://4076857463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzgUHYggWkJIGXQGAerRm%2Fuploads%2Fedx4svDMimORnhvIDHLI%2FScreenshot_145.png?alt=media&#x26;token=bd3d8f4c-b400-4750-a9a6-2feb817a742d" alt=""><figcaption></figcaption></figure> <figure><img src="https://4076857463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzgUHYggWkJIGXQGAerRm%2Fuploads%2FqmLinEgfKEN27lE3DB1A%2FScreenshot_146.png?alt=media&#x26;token=b79c156e-a897-47a3-ba51-1af27dd1b220" alt=""><figcaption></figcaption></figure></div>

You can see the same process in the video down below.

{% embed url="https://youtu.be/SXI_dxq_xcI" %}

## Step 06: Check Input Setup

You can change or add new inputs to Easy Grid Builder Pro very easily. To learn how the input system works and how to change and add inputs, it is recommended to read about [**Multi Grid Input Manager**](../primary-components/multi-grid-input-manager) component and [**Easy Grid Builder Pro Inputs SO**](../scriptable-objects/easy-grid-builder-pro-inputs-so) assets.

For now, we can use the default built-in Easy Grid Builder Pro input setup.

## Step 07: Play Test

Now before we play test select "**EGB Pro Grid XY**" grid system and add created "**2D Building Small Buildable Grid Object Type SO**" asset and "**2D Building Big Buildable Grid Object Type SO**" asset to the "**Buildable Grid Object Type SO List**".

That's it! now press play and press the "**R**" key to toggle build mode then select buildable objects by using the **mouse scroll**. And place objects on the grid using the **left mouse button**. To check or change the inputs, use **Default KeyBoard - Easy Grid Builder Pro Inputs SO** asset located in _**EasyGridBuilder Pro > Scriptable Objects > Easy Grid Builder Pro Inputs SO**_.

## Step 08: Setting UP the UI

Let's take our build system a little further by setting up a UI system. To display our buildable objects in the UI system we need to categorize our buildable objects by adding [**Buildable Object Type Category SO**](../scriptable-objects/buildable-object-type-category-so) assets to them.

Create a new folder in your project and name it "**Buildable Object Type Category SO Assets**". Then _**right-click > Create > SoulGames > Easy Grid Builder Pro > Buildable Object Type Category SO**_ and create a new **Buildable Object Type Category SO** asset. Let's name it as "**Buildings Buildable Object Type Category SO**" and then fill in the properties of the asset as follows.

* [x] Category Name = Buildings
* [x] Category Icon = Drag & drop "**UI Category Buildings Icon**" from _**EasyGridBuilder Pro > Misc Assets > Icons**_

Now go back to your **2D Building Small Buildable Grid Object Type SO** asset and **2D Building Big Buildable Grid Object Type SO** asset then add **Buildings Buildable Object Type Category SO** asset to the both of their **Buildable Category SO** property.

And also drag and drop the **2D Building 1x1 Icon** located in _**EasyGridBuilder Pro > Misc Assets > Icons** to the **Object Icon**_ property in **2D Building Small Buildable Grid Object Type SO** asset. And the **2D Building 3x2 Icon** located in _**EasyGridBuilder Pro > Misc Assets > Icons** to the **Object Icon**_ property in **2D Building Big Buildable Grid Object Type SO** asset.

Now your **2D Building Small Buildable Grid Object Type SO** asset and **2D Building Big Buildable Grid Object Type SO** asset should look similar to the below images.

<div><figure><img src="https://4076857463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzgUHYggWkJIGXQGAerRm%2Fuploads%2FkiaDjlQps3t1BYo9PPB0%2FScreenshot_114.png?alt=media&#x26;token=eff642b9-da1f-49d6-87a3-8388faa00103" alt=""><figcaption></figcaption></figure> <figure><img src="https://4076857463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzgUHYggWkJIGXQGAerRm%2Fuploads%2FdDkaPkUm7UgIIdrmIRVC%2FScreenshot_115.png?alt=media&#x26;token=f32a2b1c-2120-44e4-895b-07eaed9778ef" alt=""><figcaption></figcaption></figure></div>

Drag & drop "**EGB Pro UI**" and "**EGB Pro UI ToolTip**" prefabs from _**EasyGridBuilder Pro > Prefabs**_ to the scene and set _**right-click > Prefab > Unpack Completely**_. Then select EGB Pro UI object and add previously created two **Buildable Object Type Category SO** asset to the **Buildable Object Type Category SO** property in [**Multi Grid UI Manager**](../primary-components/multi-grid-ui-manager) component.

Now press play and you have a fully functioning UI system. From now on you can add any newly created **Buildable Object Type Category SO** assets to the Multi Grid UI Manager component to expand the categories.

The UI system automatically identifies all the buildable objects the current grid system has, and displays them in the UI. This way you can have multiple grids with different buildable objects and the UI system will auto-update the UI according to the active grid system in real-time.

Also when you are in play mode you can see a question mark button in the right bottom corner of your screen. When you press it you will get an auto-updating Help Menu that displays all the Input Keys. If you change any input from your active [**Easy Grid Builder Pro Inputs SO**](../scriptable-objects/easy-grid-builder-pro-inputs-so) asset this UI section will also update automatically.

<figure><img src="https://4076857463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzgUHYggWkJIGXQGAerRm%2Fuploads%2Fhwmi7xWCs5sraVdqe2me%2FScreenshot_116.png?alt=media&#x26;token=db5b9c46-2fda-4fa5-8e9f-ec7b831eed28" alt=""><figcaption></figcaption></figure>

You can see the same process in the video down below.

{% embed url="https://youtu.be/Zo4Aa8iDGV8" %}

## Step 09: Setup Save & Load

Adding save and load to your grid system is extremely easy. Simply select **"EGB Pro Grid XY"** grid system and enable **Enable Save & Load** property. For the **Unique Save Name** property, make sure to add and provide a unique name, otherwise, grid systems with the same name will override its saved data.

That's it! Press play and place objects on your grid and press the "**O**" key or press the save button from your UI to save your grid data. And press the "**P**" key or press the load button to load your saved grid data.
