📜 ⬆️ ⬇️

Character Story: Sound, Advertising and Language Managers in Unity3D

My name is Eli and I am ... a worm.

Yes, you heard it right. The most common ringed worm, which now jumps on the keyboard and swaps weights, so that you, my dear reader, can enjoy punctuation marks and capital letters. One day I will publish a book called “Quick Keyboard Printing for Ringed Worms and Their Zombie Half in 23 Years.” Perhaps not one worm will live to the end of this book, but there must be some flaw in a completely immaculate book.

In any case, it certainly will be sooner than the Creators independently release themselves to write an article about me and my mouth-watering insides. And there is something to write about! How much I did not persuade the programmer (P) to write at least a little about these complex pieces with patterns, video ads and iPhones. No matter how much I asked the artist (X) to write a few lines about that specific work with a brush in games, he, such a scoundrel, is silent as a Buddhist.
')
We also have a game designer (G). I do not understand at all: what kind of person is he and why is he needed? I did not ask for anything or persuade him, although it seems to me that he thinks otherwise. Or I think the opposite. Or he thinks that I think the opposite. In short, one of us thanks to someone feverishly recursively thinks, periodically overflowing the stack. I once heard that he came up with the Idea, but what kind of Idea, and why it is needed, I did not find out. And nobody wants to explain. One way or another, these people are holding me by a worm who stays asleep when I try to convince them that my story of intergalactic escape of the universe can be incredibly interesting to someone. Although I am starting to prepare for the opening of the fan club.

So, a landmark story. It began, like all great things - at 5 am (at least in one of the time zones it was clearly 5 am). My Creators learned about the imminent danger of an alien invasion that threatened all mobile devices of the planet Earth. But being noble people, they did not raise hype, and began to carefully recruit a team. I have, by the way, left the first letter sent for P. from G.

image


Really handsome? I will show my grandchildren. Literally the first "pre-front" letter. Although, if P. had waited a couple more weeks, this article might not have been. Rather, it is not. But it could not be at all. Like me. Like you, my dear reader.

The creators have long fumbled with the choice of the ideal hero of the savior. This is understandable, because there were so many search criteria with which the hero had to answer: be a worm, be ringed, the name should begin with “E” and end with “barking” and, if possible, it should be slightly elastic. Long overwhelmed by the most difficult competitive selection, I successfully passed all the tests. It is a pity, however, that there were no other applicants, perhaps it would be more interesting. But on the other hand, I understand them. Few people want to risk their lives for the sake of others.

For me, this is a hobby.



The dimension and space chosen for my tests and for my development as a super hero is called Unity3D. When I asked P., why exactly Unty3D, he meaningfully flashed his glasses and told me: “Because it’s too lazy.” I was offended because I did not understand at all what exactly he had in mind - it looked like a mockery. But a couple of times I saw how he, with foaming at the mouth, argued to someone about flexibility, cross-platform, free of charge, security, security, awesomeness, Visual Studio Audio, large community and other% text% ness. And then he grumbled under his breath, something about fluid abstractions, when I was working with streams and shortcuts in my nervous system. It seems to me that he is damn prejudiced. I am sure one of the “people above” pays him to promote Unity3D. Yes, he is even coated on Unity3D on weekends and runs on the Internet, inviting everyone to code in C # and write short texts. And he knows one great, really funny joke. But more about that later. The idea is that his brain is completely captured by the obsessive idea to create in the dimension of Unity3D, which became my testing ground. My health was improved first in MonoDevelop (primitive Debug.Log () Debug.Error () and Debug.Break ()), but then they switched to more modern and effective products in the form of VisualStudio 2015 Comunity Edition, coupled with a free plug-in from Visual Studio for Unity3d This made it possible to debug each frame, eliminating the causes of the disease, rather than drape symptoms. What is interesting is that Debug.Log () is not sick of performance on the build so much - especially if it is in the Update () method. Therefore, all operational tools (debug output to the console) were painstakingly pulled out (commented out) of me before assembly.

True, there is a small nuance. Tiny.

I was his first project.

The very first.

How would you explain so that you understand, my dear reader ... Ah!

Here you go:



This crazy man thought that having “3D” in the name of the game engine is enough to put on stereo glasses and write games in three-dimensional space. Not having normal shaders and experience with light. That's just funny. As these people just did not mock me - they increased the number of polygons, turned out the normals, twisted my arms, shone a light bulb in my face. The result was a little like expectations. As a result, said G .: “Yes! This is definitely not our hero! ”As a result, I was led to the human two-dimensional dimension, and I became amazing and irresistible. I could even touch my hands.



Do you know what important thing I realized while working with these guys? I realized what a real team is. Believe me, I asked around for a couple of birds and plants from neighboring farms. P., not only always immaculately responded to the slightest remark of others, but also took the initiative himself, screwing in his features and ideas. At the same time, everybody understood perfectly: what has been done today (spent gigatmeters of nerves and building materials), then tomorrow may be in the trash can (this is even if you are lucky and click Delete without Shift). And it happened and vice versa - funny bugs flowed into the mechanics.

For example, I still do not know where my nose and ears are and ... but no.

All in a helmet.

Fuh.

Interestingly, the most difficult thing was to teach the player to control me. I considered myself a rather appeasable guy, but the myth about intuitive control was rather quickly dispelled. G. bother with the tutorial most of all to help the player understand that you need to “start” a svayp in my territory, and finish at any point on the screen. They say 30% of the players fell off on my tutorial. Thirty percent ... We were afraid of losing even one. Therefore, a quickly assembled consilium, having barely gathered a quorum, decided to cut out this element of the space simulator from my casual world.

Here is a small MRI of my cerebellum. I think experts will quickly understand the principles of my telepania.

//   Input.multiTouchEnabled = false; if ((Input.touchCount == 1)){ Touch touch = Input.touches [0]; //   - " ,    " if (touch.phase == TouchPhase.Began){ //    p0 = touch.position; //         p0_cam = Camera.main.ScreenToWorldPoint(p0); } //   - " " if (touch.phase == TouchPhase.Moved){ p1 = touch.position; p1_cam = Camera.main.ScreenToWorldPoint(p1); //       } //   - " ,    " if (touch.phase == TouchPhase.Ended){ dis = Vector2.Distance(p0, p1); //   ,      if (dis > 5 ){ //  } else { //  } } } 

There is no mouse in android. There is a “touch”. To test it, you need an Android device with UnityRemote on board. My P. was always interested in whether the touchscreen in the Unity Editor works on monoblocks with a touchscreen. Tachem controlled only my body, and the store. All buttons work on good old methods like OnMouseDown ().

It is worth telling about the operating table on which I was collected. Iron is average. Two cores, two gigs. More than modest, but in order to compile enough. However, there are three important points, without which I would not be. I am not there anyway, but without this there wouldn’t be perfect:


Without android, firstly, it is physically impossible to check the control of the wheelbarrow. Secondly, some services: advertising (except for UnityAds), banners, InApp in the Editor still do not potest (falling out of the infa in the console does not count as a test).

The bad news: without a Mac (at least a mini), it is impossible to build an iOS version. Even to use Unity Cloud Build, you will need a .p12 file and a provisionfile, which cannot be generated without a Mac. And there are too many pitfalls in the compilation under iOS to immediately go to the cloud. Of course, we also need a device for tests, and, preferably, of the last-second-last generation. So, if you are burning with the desire to deploit in the appstore, get ready for large investments.

And also, my dear reader, I often died. And then resurrected. Sometimes partially. For this process, P. used something like a life control system. Since at these moments I (although sometimes partially) did not exist in any of the worlds, here is a small note on behalf of P. himself, which I had so hard got out of him.

From a conversation with P .:
The first thing I did when I wrote the code was to just copy the folders and rename them, substituting the date and time at the end ... Oh, everyone did that at first. I still consider this method the most reliable way to backup. Especially after the case when instead of merging a feature line into a wizard, I did the opposite. By the way, since I use only one branch - master, I am silent about what I am ashamed of, but is this conversation only between us, Eli?

Then there was a problem about consistent work on two computers, and I added to this DropBox. With each saving “throw-box” I got a message about the impossibility of updating the index.lock file. Excluded temp and library.

Now I, of course, use the entire version control system. I highly recommend using SourceTree + Git (downloaded when installing SourceTree) + BitBucket. Free and convenient. Only in contrast to the same dropbox, every change of the project must be committed. It looks like an obvious thought, but when you first become familiar with version control systems, you think that you can track every change up to every semicolon (something like the infinite Ctrl-Z). In fact, it turned out that comparisons can only be between commits - a kind of checkpoint. Of course, you can commit at least every character, but this is beyond common sense (each commit needs a comment about the list of changes). Therefore, I commit and push to the server two or three times per working day. Fichu finished - zakomitil, started.

By the way, it was a disappointment. I thought version control would give me more. Although, most likely I just have little experience with Git. Until.

Before using the git project, unty needs to be slightly configured:

1. Go to Edit> Project Settings> Editor
2. Set Version Control to Meta Files
3. Parameter Asset Serialization set in Forced Text

And add to the project folder a file called “.gitignore“ without quotes with the following content.

.Gitignore file
Temp / *
Obj / *
UnityGenerated / *
Library / *
ExportedObj / *
* .svd
* .userprefs
* .csproj
* .pidb
* .suo
* .sln
* .user
* .unityproj
* .booproj
.DS_Store
.DS_Store?
._ *
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
* .apk
* .rar
* .zip
* .unitypackage

By the way, remembering the backup of folders, to this day I keep a file in the folder that cleans up all the excess from the directory after copying and carefully sends it to the folder with the box as a ZIP archive. If used, replace the values ​​of the following variables:

PathSource - the path to the source folder
Path7Zip - path to the c 7zip folder
PathDropBox - the path of the destination folder in DropBox
NameDropbox - archive name

Bat file to create backups
 @ECHO OFF set CY=%date:~6,4% set CM=%date:~3,2% set CD=%date:~0,2% set TH=%time:~0,2% set TM=%time:~3,2% set PathSource=D:\Repo\btbw set Path7Zip=D:\Program Files\7-Zip set PathDropBox=D:\Dropbox\#BTBW set NameDropbox=btbw echo. echo Backup started at %TIME% echo =============================== echo 5%%.. [Directory copying] echo f|xcopy /y "%PathSource%" "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\" /e >nul echo 35%%.. [Directory clearing] IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\.git" rd /s /q "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\.git" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\.vs" rd /s /q "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\.vs" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\Temp" rd /s /q "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\Temp" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\Obj" rd /s /q "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\Obj" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\UnityGenerated" rd /s /q "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\UnityGenerated" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\Library" rd /s /q "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\Library" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\ExportedObj" rd /s /q "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\ExportedObj" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.svd" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.svd" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.userprefs" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.userprefs" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.csproj" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.csproj" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.pidb" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.pidb" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.suo" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.suo" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.sln" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.sln" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.user" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.user" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.unityproj" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.unityproj" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.booproj" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.booproj" IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\.DS_Store" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\.DS_Store" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\.DS_Store?" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\.DS_Store?" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\._*" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\._*" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\.Spotlight-V100" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\.Spotlight-V100" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\.Trashes" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\.Trashes" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\Icon?" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\Icon?" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\ehthumbs.db" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\ehthumbs.db" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\Thumbs.db" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\Thumbs.db" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.apk" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.apk" >nul IF EXIST "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.unitypackage" del /s "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\*.unitypackage" >nul echo 40%%.. [File compressing] "%Path7Zip%\7z.exe" a -tzip "%PathSource%_%CD%%CM%%CY%-%TH%%TM%.zip" -i!"%PathSource%_%CD%%CM%%CY%-%TH%%TM%\" >nul echo 70%%.. [Archives copying] echo y | copy "%PathSource%_%CD%%CM%%CY%-%TH%%TM%.zip" "%PathDropBox%\%NameDropbox%_%CD%%CM%%CY%-%TH%%TM%.zip" >nul echo 95%%.. [Deleting temporary files] rd /s /q "%PathSource%_%CD%%CM%%CY%-%TH%%TM%\" del "%PathSource%_%CD%%CM%%CY%-%TH%%TM%.zip" echo 100%%.. DONE! echo =============================== echo Backup ended at %TIME%. echo. pause 


The only problem is that when unpacking an archive with a backup in which such a bat-file worked, you have to switch the build platform again.

Another caveat - make sure that the repository with the project are NOT on the SSD. I found out a bit later that the number of rewrites was limited and when I found out the hair on my head began to move. I compiled often. And packaged sprites more often.

Probably a little off topic, but once I started talking about the version control system, it is worth mentioning the ticket tracker. We used RedBooth. This is a place where we laid each other sheets of subtasks. By the way, Eli! I heard a terrific joke here: Helium enters the bar ...


Honestly, I practically did not understand anything from what P. said. But “practically nothing,” is it not so bad for a ringed worm, eh? If you want to know something more, about my dear reader, write me a comment in the e-mail: eli@greensnowgames.com. In the comments here sit only all sorts of smart guys, for whom what P. writes long ago is obvious.

In addition to my hobby - saving the population of devices from alien vegetables, I still have a job. And I changed this job a couple of times. At first, I worked as a seller of the “Continue” button, which opened in the main menu when a player bought the game. The job was not dusty, but it brought almost no profit. I had to go into the budget sphere. The money here is stable, but small, so you have to earn money immediately in 4 places: 3 video ads (Charboost, Vungle, UnityADS) and banners from AdMob. In order to be in time everywhere and never get confused, I even had to hire a manager, since at least the work was more or less the same everywhere. Here is the job description of my manager, P. commented painstakingly.

Admanager.cs

Just in case, I asked P. how to give this guy instructions and explain what he can do and how. I do not understand the work of managers. I heard that they are specially studying at the university of software engineering. Or they themselves are taught. Or learn how to do them. I really did not understand, but I know one thing - they are very smart. At least smarter than the ringed worms. At least those who are not smarter than me.

From a conversation with P .:
Eli, it's simple with him. After the necessary libraries are implemented, somewhere in the code it is indicated:
 If (AdManager.IsReady()) { AdManager.me.ShowAd(AdManager.Reward.Coin); } 

The manager is looking for which service has already cached advertising and, depending on this, starts the Show () method of this service. Napimer, if the event was shot Vungle. onAdFinishedEvent, which reports that the advertisement was successfully reviewed to the end, then control is passed to the AdManager.OnAdFinished delegate, which already has the GiveReward () method running. The latter method, in fact, gives out gingerbread encoded with a magic number. Eli! You did not hear one amazing joke that time! So, helium enters the bar, and the bartender tells him - we do not serve inert gases, and helium ...


Advertising manager is not the only hired hard worker. Unfortunately, I am only a ringed worm and I don’t have a lot of things. For example, my dear, reader, I do not know how to speak. H. drew me a language, and a new person was invited to the team - the Musician (M.). But neither H. nor M., nor even P. could not endow the ringed worm with vocal cords. Therefore, it was decided to call for a small share of the sales manager of the verbiage. True, this time the manager was a girl named Voman (from Voice Manager).

As in the previous case, here is her position:

VoiceManager.cs

I found a common language with her, so we’ll not disturb our big P. once more. To play the sound, you just need to write to her:

 VoiceManager.me.PlaySound(myClip); 

and she will say it out loud. Absolutely simple and unpretentious. We all love when they understand us at a glance, right? And she allows me to communicate - to tell the world what I can only write, wriggling, jumping on buttons and rearranging weights. It is always nice to feel that not only your creator has a team. By the way, my team also has good looks and bad habits. Your dreams. Of course, this appearance has nothing to do with the appearance of a person, just as the appearance of a worm has nothing to do with what I feel inside myself. I think, just passing the posts of my friends diagonally, you can already realize how they differ and how they are similar. What an awkward, but very smart uncle advertising manager, and what a bold, but simple-minded girl Voman.

But even they can not sometimes find a common language with me. Perhaps (I judge by my company), in any company there are people who do not communicate much with each other, although at the same time they are in this very common company. What unites them? Probably other people. People through whom they access each other. I call such intermediaries. They are in our company. Whole two brothers by the name of “Singleton”. The first mediator exists from scene to scene — his name is Tator. Its fields are spelled out or computed in its internal logic, and access to them can always be obtained through static. I can not remember the parties, in which he would not participate. The second name is "Medi" - the mediator within the same scene. I see him less often, but if I do, I literally pray to him. He knows everything about everyone, but only inside this particular rave scene.

Of course, each has its own message methods and access fields. But basically only thanks to them we get access to those members of our team who are either hard to look for, or have to be awakened, or have to be completely redone. So what?

The brothers work on the same principle as the managers, just do not have a specific specialization, but simply ... mediate? In short, they are the soul of our company. Sometimes it seems to me that all our work lies on their broad shoulders.



Oh, my dear reader, forgive me these ringed tenderness, something I was completely impressed. I do not understand why the Creators will not tell you all this. I am sure: they know much more. Much better than me. They know me, much better than me.

Or not…

Do not they feel the emotions that we experience on the other side of the display. Or they feel it, but not so ... Oh ... Since this rainy weather has gone, so be it, I will reveal to you a little secret. I still hide it from the Creators, but something I jumped for myself.

The fact is that I have a dream.

I want to be a world class worm. Truly international, not just English-speaking. For this, I study as a foreign language manager. The idea that I came up with consists of two parts. This thought came to me when I was working on a farm in the fall and accidentally cut myself with a shovel. One thought at that moment came to both halves. When I merged back, I got such a full-fledged thought. Here is the part that came in the first half:

LanguageManager.cs

But the second part. I mark this object with the logic that I want to translate. For a few nights, I painstakingly translate a plate and put it in the Resources folder / language. I must say right away that there is an objective problem here: if there is no language, the game will fly out. It is useless to do the check, because the plates with the “reference” tongue may suddenly not appear either. Therefore, this method must be used with caution.

LanguageClient.cs

I am sure that the question immediately arose: what is Messenger and where can I get it? These are delegates. Without these guys in the dimension space of Unity3D (and maybe outside of it) there would not be very much. It consists of two parts - the listener and the broadcaster. The broadcaster shouts loudly various funny phrases, and the listener tries to discern something familiar and react in these phrases. I once looked at how this trick does P. Here you can read more about it:

Advanced C # Messenger

By the way, about the "react"! P. recently told me a terrific anecdote, but I absolutely do not remember its beginning. I remember only the last two words: "does not respond . " But I am sure, my dear reader, if you heard him, you laughed till you drop. P., at least, laughs every time he talks. He has a great sense of humor.

On this satirical note, I finish jumping on the keyboard and rearrange the weights.
I will try to post this post, a small post on the way of a big fan club with T-shirts and cool parties. And perhaps, on one of them, we will meet with you, my dear reader.
Let's meet one big company.

See you all together.

Remember my friends managers every time you hear sounds or watch commercials. I wonder how you imagine them? Perhaps the same as I present you, my dear readers.



The materials presented in the article can be found in the githab repository .

Source: https://habr.com/ru/post/277835/


All Articles