Grid Builder 2 works by using specific components to do different jobs. You may want all the functionality in your game, or only some, and there is little point in wasting resources with everything built in.
If you want to use every function Grid Builder 2 has to offer, grab a prefab of each type listed here from the /Prefabs folder. Either this, or study the demo scenes, to see how they are set up.
If you only want bits and pieces of the system, see the list below stating what each component needs, and what is optional. Using components without the Required – *Component* will result in loss of that functionality.
GridBuilder2Manager
Connects all of the parts of grid builder 2 together and is a required component in most circumstances.
This manager component is required when using anything other than the GridSquare component.
When adding any other components in your hierarchy (except GridSquare’s), make sure to also place them in this component.
Required – None.
Optional – None.
GridSquare
This is the basic component generating the visual grid for you. It is also responsible for initiating the saving process as well as loading the objects back onto the grid.
Every other class will need at least one GridSquare in the scene to work.
Required – None.
Optional – ObjectPlacer.
GridSelector
This class calculates the center or the points of each cell and moves its ’tile’ or MeshRenderer mesh across it.
Grid selector also serves as the preview placement logic, showing the objects before being able to place them down.
This component is the central hub for most other classes in Grid Builder 2.
Required – GridBuilder2Manager, GridSquare.
Optional – ObjectPlacer, ObjectRemover, ObjectSelector, GridObjectOptions.
PickBuildingBtn && PickBuildingWithKey
These components act as input methods for selecting what object to place. The PickBuildingBtn should sit on a button component while the PickBuildingWithKey should be just placed on an empty gameObject.
This class will pass the information set up on this component to the GridSelector for previewing.
Both of these components should have a Building component added to the building slot in the inspector.
Required – GridBuilder2Manager, GridSelector.
Optional – ObjectPlacer, ObjectSelector, RemoveMode.
ObjectPlacer
Responsible for placing objects and blocking cells, whether it be by hand via the GridSelector class or by loading them directly from a save via the GridSquare.
Required – GridBuilder2Manager, GridSquare, GridSelector.
Optional – None.
ObjectRemover
This class is responsible for removing placed objects and unblocking cells.
Required – GridBuilder2Manager, GridSquare, GridSelector.
Optional – ObjectPlacer, ObjectSelector.
ObjectSelector
Handles selection of objects placed on the grid. This can include hover material changes, clicked(selected) material changes and can include a varying sized sliced image to give further visual confirmation of selection.
Required – GridBuilder2Manager, GridSquare, GridSelector.
Optional – ObjectRemover, GridObjectOptions.
GridObjectOptions
This class contains extra methods for manipulating objects such as moving an already placed object. This is accompanied with an optional pop up menu after selecting an object via the ObjectSelector.
This class could easily be expanded with additional functionality for those confident in programming.
Required – GridBuilder2Manager, GridSquare, GridSelector, ObjectPlacer, ObjectRemover, ObjectSelector.
Optional – None.
RemoveMode
This class should be added on an object with a button. When clicked, this will enable the ObjectRemover.
Required – GridBuilder2Manager, GridSquare, GridSelector, ObjectRemover.
Optional – ObjectSelector.
BuildMode
This class should be added on an object with a button. When enabled and clicked, will toggle the visibility of the active grid objects.
It can also hide all objects contained on those grids.
Required – GridBuilder2Manager, GridSquare, GridSelector.
Optional – ObjectSelector, RemoveMode.