2D Level Creator - Documentation

2D Level Creator is a tool to create levels of 2D games in Unity - Game Engine. Allows you to create complete terrains composed of trees, walls, stairs, water and an infinite number of objects whose material has been provided.

The function of the tool is to form a material from the images provided and apply this material according to the parameters entered to polygon created by the developer using the points system that offers.

The aim of this tool is to save the maximum time possible in the creation of levels for 2D games so that the developer can quickly create any kind of terrain through the union of a set of reference points.



The tool is located in the directory /Assets/2DLC and contains the following subdirectories:
  • EXAMPLES: Contains various examples that illustrate the use and capacity of the tool, the scenes are in the directory /Assets/2DLC/Examples/Scenes.
  • IMGS: Contains images of the tool. Please do not rename or delete these images as they are necessary for the correct functioning of the tool.
  • MATERIALS: Contains custom materials (.mat).
  • MATERIALS_AUTO: Contains materials (.mat) generated automatically. All files in this directory have its corresponding T2DMaterial in the directory /Assets/2DLC/Prefabs. Those who are not associated are periodically removed. It is not recommended to use this directory for another purpose.
  • PREFABS: Contains those prefabricated of the tool among them is located the T2DMaterials.
  • SCRIPTS: Contains all the code of the tool.
  • SHADES: Contains some shadows recommended for materials (.mat).
  • SPRITES: Contains images of materials.

The tool contains the following components:
Terrain 2D
T2D Settings
T2D Material
T2D Animator

And the following utilities:
T2D Animation
T2D Material Applicator

Do not forget to take a look at these usage tips:
Usage Tips

TERRAIN 2D

Terrain2D is the base component of the tool, from which you create all the objects in the level.
To create a new terrain:

GameObject > 2D Level Creator > Create Terrain 2D:



Then a chooser is deployed to assign a Terrain Material (T2DMaterial).

Static Settings
Refers to a prefab that uses the T2DSettings component and contains all common settings that can be used on multiple terrains.
Terrain Material
Refers to a prefab that uses the T2DMaterial component and contains the textures and mesh materials needed to model the terrain. Currently available 2 types: Terrain and Component.
Depending on the type selected, will exist or not some parameters of the terrain.
Auto Assign Mesh Materials
This option assign automatically the Mesh Materials (.mat) associated with the selected Terrain Material to the MeshRenderer Component. Commissioning False, only then it allows to manually modifying these materials.
The aim is that different Mesh Materials can be used for the same Terrain Material.
Terrain Mode
Defines the terrain mode and contains 2 options:
  • FILLED: It is the mode that is selected by default and means that the terrain will internally regarding the points system.
  • INVERTED: Contrary to FILLED, the terrain will be formed outside the points system. When you select this option, the parameter Investment Distance is exposed to indicate the margin of the terrain walls.
Pixels Per Unit
It is the scale of pixel equivalent to a unit on the scene. 100 pixels per unit would mean that a Sprite of 100 pixels is considered a unit on the scene. It affects both physics and the quality of the terrain.
Material Overlap
It allows you to configure the overlap of Mesh Materials (.mat) and the order of the different parts of selected Terrain Material. Contains the following options:
  • Drawing Order On Mesh: Enable/Disable overlap configuration during the mesh drawing of the parts of the Terrain Material.
  • Faces Order: Option available for all parts of the Terrain Material that are composed of several faces and allows to specify an order for these.
Material Options
Allows the configuration of the different parts of the selected Terrain Material. All options are described below:
Edge Mode
Indicates how the edges relate to each other and contains 2 options:
  • DETACHED: Means that the opposite sides of the edges are independent.
  • CONCATENATED: Means that the opposite sides of the edges will be concatenated.
Turning Ability
Each side of edges and corners is conditioned by the previous and next side so that one side can be tilted more or less according to these to suit your situation, the turning ability tries to control this inclination. This significantly affects the thickness of edges and corners. Only has 2 parameters:
  • X: Ability to turn or tilt in the x axis.
  • Y: Ability to turn or tilt in the y axis.
Corner (Top Left, Top Right, Bottom Left, Bottom Right)
Each corner of the terrain contains its own configuration and is composed of an image and has the following parameters:
  • Enabled: Enable/Disable the corner.
  • Alignment: Alignment of the corner in relation to the line of terrain, can be one of the following options:
    • CENTER: Corner is centered with respect to the terrain line.
    • HIGH: Corner is high with respect to the terrain line.
    • SUNK: Corner is sunken on the terrain line.
  • Fixed Size: This parameter enables you to set the size of the corner to the specified size. The entered value is divided by the number of pixels per unit.
  • Offset: Allows to give a margin to the face.
  • Vertex Z: Allows to set the depth of the corner through the application of the value entered to the z-axis of all vertices.
Edge (Top, Bottom, Left, Right)
Each edge of the selected Terrain Material has one or more images and its own configuration with the following parameters:
  • Enabled: Enable/Disable the edge.
  • Alignment: Alignment of the edge in relation to the line or the polygon of terrain, can be one of the following options:
    • CENTER: Edge is centered with respect to the terrain line.
    • HIGH: Edge is high with respect to the terrain line.
    • SUNK: Edge is depressed on the terrain line.
  • Faces Mode: Faces mode indicates if the edge faces are concatenated or independent.
    • CONCATENATED: concatenated faces share their sides so that the right side of the face 1 is the left side of the face 2. This option exposes the parameter Twist Average which if set to True, allows to adjust the sides shared in bends.
    • INDEPENDENT: Independent faces have each their own sides. This could be more expensive at the level of memory but it could also provide higher quality. Logically when this option is used will appear cuts between faces and for this reason is exposed the parameter Include Corners Between Cuts which if set to True, allows to create corners for these cuts.
      Also appears the parameter Faces Offset that allows to give a margin to the faces. But it is necessary to be careful not to assign a negative margin that exceeds the size of faces since it can lead to drawing lots of faces in the same space and thus causing an excess in the mesh besides memory problems.
  • Faces Order: It is the order of appearance of the faces, has 3 options:
    • CONSECUTIVE_BETWEEN_TWO_POINTS: The consecutive order between two points consists in using the images provided to the edge consecutively between two points and start again at the next point.
    • CONSECUTIVE_AT_TERRAIN_LEVEL: The consecutive order at terrain level consists in using the images provided to the edge consecutively at the terrain level.
    • RANDOMIZED_CONTROLLED: The controlled random order is to use randomly the images provided to the edge recalling always the generated positions. This option exposes the button Refresh Random Order to regenerate the positions.
  • Fixed Size / Pixels Per Unit: This parameter allows you to assign a fixed size to all faces. The entered value is divided by the number of pixels per unit.
    Each axis has the option Average Size that allows to assign to all the faces an average size based on the size of these (all faces size ÷ faces count).
  • Equate Faces Between Points: When drawing faces between two points almost always the last face has a different size, this option allows to assign an average size to all faces between two points (two points distance ÷ faces count).
  • Vertex Z: Allows to set the depth of the edge through the application of the value entered to the z-axis of all vertices.
Fill (Middle)
The filling has one or more images and the following configuration parameters:
  • Enabled: Enable/Disable the fill.
  • Faces Order: It is the order of appearance of the faces, has 2 options:
    • CONSECUTIVE: The consecutive order consists in using consecutively the images provided to the fill.
    • RANDOMIZED_CONTROLLED: The controlled random order is to use randomly the images provided to the fill recalling always generated positions. This option exposes the button Refresh Random Order to regenerate the positions.
  • Vertex Z: Allows to set the depth of the fill by applying the value entered to the zaxis of all vertices.
Split Degrees
The terrain is initially composed of a polygon, this polygon is formed by many sides, each one of them has a different slope and is precisely this inclination that indicates what the type of edge. With this tool, the developer can decide the rules of the terrain, indicate when one side of the polygon is considered floor, ceiling or wall.
  • Left: The range of degrees to consider that a side of the polygon is a right wall (left part of T2DMaterial).
  • Right: The range of degrees to consider that a side of the polygon is a left wall (right part of T2DMaterial).
  • Top: The range of degrees to consider that a side of the polygon is a soil (upper part of T2DMaterial).
  • Bottom: The range of degrees to consider that a side of the polygon is a ceiling (lower part of T2DMaterial). The degrees of this option are reversed (360-0), since the value is from the end to the beginning.
Collider Options
It is obviously the Collider suitable for the terrain configuration. Once enabled and by default creates a Collider of type POLYGON_2D in mode automatic (the Collider will use the polygon of the ground and will adapt to the changes of this). This default state can be modified using the following parameters:
  • Enabled: Enable/Disable the collider.
  • Manual Mode: The manual mode, if enabled, creates an independent polygon for the collider (not updated with the terrain) and exposes the option Edit On Scene that once enabled allows you to modify this polygon points in scene. Are also shown the editable points of the generated polygon and the button Reset Collider Points used to restore the generated polygon to the terrain polygon.
  • Type: It's the type of collider, currently there are available 3 types:
  • Mesh Type: The type of mesh only exists for the terrain whose T2DMaterial is a component and contains 2 options:
    • LINE: The Collider will be open, a line is generated through the points of this collider.
    • FORM: The Collider will be closed, a polygon is generated through the points of this collider. In this case is exposed the option Use All Vertices that allows to use all the vertices of the terrain for the collider polygon.
  • Offset: Is a margin to the vertices of the collider. It is not used in manual mode.
To modify the collider using the points system Collider Options > Manual Mode > Edit On Scene. Do not forget to disable this option when the modification is complete, to handle again the terrain points.
Also keep in mind that when type changes between 2d colliders are made, the object retains both to allow use them in conjunction. So if you do not want to use both, do not forget to remove the unwanted collider.
Points
It contains all points of the terrain and allows to make them editable.
Render
Allows to render the terrain.
Animate Terrain
This button creates a T2DAnimator component and adds the first animation.


T2D SETTINGS

Gathers all static terrain settings such as view preferences or default size, below is a brief description of the options.
To create a new terrain settings:

GameObject > 2D Level Creator > Create T2D Settings:

Scene Tools
As you can see in the image contains the preferences of the scene.

Default Size
This is the default size when creating a terrain.


T2D MATERIAL

T2DMaterial is the material of terrain, a component that includes all necessary images of classified and parameterized way for the terrain. It is also responsible for generating from the provided images the required materials (.mat) for the terrain mesh.
By default is created in the directory /Assets/2DLC/Prefabs although you can refer to a T2DMaterial that is located in a different location.

To create a new terrain material:

GameObject > 2D Level Creator > Create T2D Material

Material Type
This type is also considered the type of terrain and has an impact on the parameters of the terrain that makes use of this T2DMaterial. Currently there are two types:
  • TERRAIN: It is designed to create a complete terrain with floors, walls, ceiling and filling.
  • COMPONENT: Intended for the different complements of terrain such as a ladder, a pipe or trees.
Static Selection Options
Indicates the type of resource to display in the chooser when the button Select is pressed. With an exception for Middle Part that only accepts Texture2D.
The indicated value is used for all T2DMaterial components.
Material Parts Selector
The selector of the different parts of T2DMaterial which includes all the required images for the terrain and is divided into the following parts:
  • TOP LEFT: Left top corner, is composed of an image.
  • TOP: Top edge, is composed of one or several image.
  • TOP RIGHT: Right upper corner, is composed of an image.
  • LEFT: Left edge, is composed of one or several image.
  • FILL: Filling, is composed of one or several image.
  • RIGHT: Right edge, is composed of one or several image.
  • BOTTOM LEFT: Left bottom corner, is composed of an image.
  • BOTTOM: Bottom, is composed of one or several image.
  • BOTTOM RIGHT: Right bottom corner, is composed of an image.
Depending on the material type selected, will exist or not some parts.

UV Orientation
Allows you to change the orientation of the parts, thus facilitating the reuse of images from different parts and with different orientations. For each part are exposed the following states:
  • HORIZONTAL: Indicates that images of this part are horizontal. It is the default state of the parts Top, Top Left and Top Right.
  • INVERTED_HORIZONTAL: Indicates that images of this part are inverted horizontally. It is the default state of the parts Bottom, Bottom Left and Bottom Right.
  • VERTICAL: Indicates that images of this part are vertically. It is the default state of the Left Part.
  • INVERTED_VERTICAL: Indicates that images of this part are inverted vertically. It is the default state of the Right Part.

You think you should always assign the orientation of the indicated image.
Ex. if we assign the image that is in the left part to the bottom part, we must indicate in UV Orientation that Edge (Bottom) = VERTICAL
Auto Generate Mesh Materials
Enabled, allows to automatically generate the materials (.mat) needed for the terrain mesh, these materials are stored in the directory /Assets/2DLC/Materials_Auto where it must remain. Otherwise are removed the materials automatically generated and will be exposed the parameter Materials.
Materials
Allows specify custom Mesh Materials.
Render Associated
Displays the T2D Material Applicator that allows rendering the terrains associated with this material prefabs or in scene.
Terrains are rendered automatically when selected, with this utility you can render all at once.


T2D ANIMATOR

Controller of animations, it contains the following options:
Selected Animation
Indicates the assigned animation during the startup and can be changed by:
T2DAnimator t2DAnimator = myTerrain.GetComponent<T2DAnimator>();
t2DAnimator.animationIndex = /*index of animation*/;
You can also assign a delegate to detect the completion of an animation:
t2DAnimator.animationFinishListener = delegate {
// Here step to the next animation
int animLength = t2DAnimator.animations.Length;
int currentIndex = t2DAnimator.animationIndex;
if(currentIndex < animLength) {
currentIndex++;
t2DAnimator.animationIndex = currentIndex;
}
};
Animations
Contains all terrain animations. Each animation has the following options:
Name
Name of the animation.
Loop
Indicates whether the animation is repeated after it is finished.
Samples
Basically allows to modify the speed of the animation. Against more samples faster is the animation.
Points
The curves of the terrain points that have been animated.
Events
The different events assigned during the animation.
Buttons
The first allows you to open the T2D Animation and the second to add a new animation.


T2D ANIMATION

T2DAnimation it has been created based on Unity Animation so it works in a very similar way except that it is destined to the points of our terrain.
The terrain must have the T2DAnimator component to use this utility.



T2D MATERIAL APPLICATOR

Its function is to apply the starting material to all the associated terrains in the current scene and prefabs.



USAGE TIPS

Main Keys On Scene:
(Shift) To insert a new point
(Ctrl + Shift) To delete a point
(Ctrl) To select point/s
(Selection + Ctrl + Shift) To delete selected points

Proper Construction Of Polygon:
Usually you can create any shape:
>

Provided that there is no intersection in the polygon:
>


Please, if you have any doubts leave your comment, we or other users will answer your question.

Sending, please wait ..