
Good day to all! I would like to tell you the story of my new puzzle game Neo Angle, as well as share the experience of importing, storing and generating levels in Unity.
I will begin with a brief background of 5 years ago, when I decided to take up game dev, having first become acquainted with the programming language action script 3.0 (for developing flash games) at the university.
Having finished the semester, I decided that I could master my own game. So, after sitting for a while behind a notebook and a karadash, the idea of a puzzle with triangles came in, where a player needs to fill a given shape by turning a triangular stone and finish the level on the finish cell.
')
Thus, having spent a week on development alone, my first flash game
SeaQuest was released.

And I suffered to develop further. After releasing some more portal flash drives, I returned to the idea with triangles, which led to a new part, where the gameplay was completely redesigned, namely, additional interactive objects were added: buttons with obstacles, teleports and rotators. The goal of the level has also changed, now it was necessary to collect all the pearls and come to the finish line.
The result is called Stone QuestOn this line of logic games ended and was successfully forgotten by me.
This was followed by the promised collapse of the flash industry, which threw me into the unity development for mobile. And so, in December 2016, quite by chance, the thought of triangular-oriented puzzles returned to my head. Especially pushed to the development of the fact that the gameplay is great for touchscreen. It was decided to use the mechanics of the previous game, but with a different styling.
Here is a background that led to the active development of a month and a half. Most of the work, oddly enough, went into game design. From the previous version, almost all levels seemed to me not interesting enough, although the possibilities of gameplay have much greater potential. As a result, development began with the level editor, which I wrote for the evening in the good old flash, with the ability to test written levels and export / import them in xml.
The result of the work in the editor is shown below:

Before moving on to working with Unity, I needed to make sure that I could provide enough levels for a mobile game that requires a variety of content. Therefore, for the first week and a half I didn’t even open Unity, but I worked in my editor, at the same time doing graphics. By the way, the 80s' retro-style synthwave, which is gaining popularity, was chosen. It is quite simple in execution, while being very attractive.

Thus, having created a valid set of levels, I proceeded to porting them to Unity, continuing to spend some of my time refining and creating new ones.
In this regard, the following questions arose: how to import, store and generate levels in Unity from the xml file?
There were three possible solutions:
1. When starting the game, read the xml file and dynamically create levels each time at runtime.
2. In edit mode, generate levels and create for each stage.
3. In edit mode, generate levels and create for each prefab.
Obviously, the first option is not the best, because all levels are prepared in advance and there is no sense to re-create them each time. The second option is more suitable for more complex and large-scale projects, where each level has its own logic, interface, structure, etc. In my case, I would have to duplicate interfaces and key objects in each scene with a level, and every time ui changes, all scenes would need to be updated. It remains the last third option, which is just very well approached. On its implementation, I will continue the story.
To work with objects in edit mode, add a custom panel in the Unity editor. To do this, create a class inherited from
EditorWindow in the
Assets / Editor folder and add the following method there:
[MenuItem ("Window/Level Loader")]
Immediately check that the panel is created in
Window -> Level Loader :

Further, in the OnGUI method, you can start adding buttons and fields for our window.
Basic examples:
void OnGUI() { GUILayout.Label ("Custom Label", EditorStyles.boldLabel);
More information on the components can be found in the official documentation. And I will continue the description of my Level Loader'a, demonstrating the principle of operation below:

First, we read the levels from the xml file by clicking on Read Levels, then a drop-down list is created with a choice of level and additional controls appear that allow you to generate a level on the stage, create a prefab of the selected level, recreate prefabs of all levels, show / hide numbers fields (for testing drawing and tracking errors).
To create objects on the scene in edit mode, the standard function
Instantiate is used , and to delete
DestroyImmediate .
For a while, I created the prefabs of levels manually, dragging them from the stage to the Resources folder. However, I quickly got tired of it and I got into the Internet for information on how to create prefabs in edit mode using software. Below is a construction to do this:
private void CreateLevelPrefab() { GameObject levelGO = GameObject.FindGameObjectWithTag("Level").gameObject;
Next, in game mode, the levels are added to the scene as follows:
GameObject levelGO = Instantiate (Resources.Load ("Level"+levelNum) as GameObject);
Thus, the stages of adding levels turned out the following:
- Creating / editing a level in a flash editor and then exporting to xml
- Read xml level in unity
- Level generation on stage in edit mode
- Create / update prefab level in the Resources folder
That's all. For me, this was the first experience with objects in edit mode. I will be glad to get acquainted with your ideas about the implementation of the level editor directly in Unity, passing Flash.
Thanks for attention! You can play the game on
Google Play at the request of
Neo Angle .