📜 ⬆️ ⬇️

Unity3d and dispelling some myths

Recently, I read another article about Unity3d on Habré, once again there were interesting comments - both literate and literate not quite.
I was inspired and decided to comment a little on what is happening.
I hope someone will get something new and interesting here.

Few comments

This subsection of the article is a comment to the comments - the text in quotes is not mine.

"Support for caching assets on the client is sold for some very large money (this is not in the browser, but separately on the disk)."

In 3.2, there is caching for everyone (with limitations, of course).
')
“The author carefully lowered two very serious problems:
- Unity games require a lot of traffic,
“You can't use complex dynamic scenes.”
"Games on Unity have an elementary game mechanics - a difficult fight with several players will be very slow."
“By a difficult fight I meant the joint game of several players. For Unity, this is a bottleneck. It is impossible to omit this moment, since The main requirement for modern games is a high degree of socialization. Players want to play games with their friends. Note that there are almost no games on social networks on Unity. ”

Note that most games on social networks have an asynchronous principle of operation. Those. when Petya was at the university, I came and broke the bed for him - Petya came home, went to his page in contact, got angry and sent a detachment of avengers to me on the garden bed. And I, of course, at the time of the attack did not interact with Petya directly. The phrase that “a multi-player co-game is the bottleneck of Unity” sounds, to put it mildly, indecent - especially if we are talking about a really small number of players in the same room, or a third-party network solution.

"And as a result:
- Unity games for people with low traffic turn into a nightmare,
“Games on Unity have an elementary game mechanics - a difficult fight with several players will be very slow.”

In general, the minimum application in the web player will weigh a little more than 500kb, and additional resources can be downloaded in Asset Bundles (which are packaged 7z). If we are talking about the traffic that occurs when exchanging game messages, the selected solution for the network again plays the role.

"Unity is good, but before you rush to write comprehend 2 minus
1: ZD is not a panacea and must be applied carefully. Look at the top appstore - there are basically 2d games. Look at the social games that are played by hundreds of millions - there is no 3d. Only a small number of game mechanics truly require 3D.
2: Make juicy attractive graphics on 3D is much more complicated than on 2D and it can only be done by professionals. Lovers and beginners make a 3D image causing fear and horror ... ".

There is clearly a lack of understanding of the fact that at Unity you can do great 2d games. What does the whole crowd of developers in appstore do (and there was a certain percentage of games in top100, by the way) and casual players.

"Unity has deferred lighting, a built-in shader editor."

A small mistake. By default, no such tool is supplied, but there is one free quality tool - the Strumpy Shader Editor and one paid shader editor - ShaderFusion . Shading in 3.x stepped on the developer’s meeting (surface shaders appeared), so writing your own shaders (without a visual editor) does not seem incredible. The porting of shaders is generally excellent (for example, you can easily take and quickly remake something from here ).

“He [Unity3d] is closed. Those. source codes will not be given to you even under license. ”

Source codes can be purchased if you are a very serious developer (although the cost of source codes starts from 100k, I guess, and I also see a very slim chance that you will need these sources).

And on the license ($ 1500 if we are talking about Unity PRO), by the way, there are discounts several times a year, usually ~ 20%. The limitations of the basic versions (Unity for $ 0, Unity iPhone for $ 400) are not so great - a significant number of projects can be developed for them.

“Has anyone tried Unity for Android / iOS? How are your impressions? ”

Impressions are great.
Recently, for example, there was a competition from Qualcomm to create augmented reality applications (it was possible to use the Qualcomm Unity SDK) and the prizes were quite good 125, 50 and 25 thousand dollars for the first, second and third places, respectively.
Both platforms developers actively finish and optimize.
On high-power mobile phones, Open GL ES 2.0 (pixel-by-pixel lighting, shaders) is supported - this is, in my opinion, excellent. You can try to do something similar in quality to Epic Citadel.

More thoughts

While I wrote out thoughts on paper, there was a new article on Unity from the same author (author well done!).

“It’s more convenient to give serious scenes to doing the same to artists in 3DS Max. The only thing that is bad is that of FBX (intermediate format between max and unit) Unity does not import light sources. I had to write a plugin for Unity in C ++. And it is available only in the paid version. Vobschem namuchalis with this engine. "

Tell me, why write a plugin in C ++, if the light sources are normally transferred to the unit in the form of dummy game objects? You can agree with the artists on how to properly call light sources and write a small script in the unit that would create these sources when importing the model. Both the assembly level in a unit, and the assembly level in a 3D package have their pros and cons - and the choice more, in my opinion, depends on the preferences of the developers.

“Perhaps, all the same it is worth taking up the implementation of your minecraft with blackjack - all the possibilities seem to be there.”

If this helps, then there is the Unity Minecraft Starter Package .

Network

They say that with a network in Unity3d things are bad, and capacity is not suitable for a large number of connections. In fact, everything is simpler - and the one who knows what he is talking about is built-in networking. Because instead of the built-in solution, you can use almost anything:

Network solutions with API specially prepared for working with Unity3d:
  1. Smartfox .
  2. Photon .
  3. Badumna .
  4. Electroserver .

Network solutions that can be screwed by yourself:
  1. The original Raknet (c ++, not suitable for webplayer).
  2. Lidgren .
  3. RedDwarf .
  4. NetDog (c ++, not suitable for webplayer and he also has some kind of really freaky price tag).

Some solutions are free, some are not expensive at all, and they also provide a free version with a limited number of connections (for Photon, for example, 100 - for others, to be honest, they were not interested).

Naturally, you can write something of your own on an arbitrary technology (c ++, Java, Erlang, c #, whatever) and fasten some other existing networking solution. Something based on TCP \ UDP fits perfectly. If you use the HTTP protocol, then the most common choice is php - although, as you understand, the same Erlang or something else also works.

I personally did a simple chat (I do not position it as an achievement, but I was pleased with the result in step 3), which worked through the HTTP protocol:
  1. Erlang and web server Misultin for server side.
  2. Unity3d and its WWW class for the client side.
  3. Several different types of devices: iPad and iPhone (Unity iPhone Basic), HTC Desire (Unity Android Trial), PC and Mac (in the web player, the free version of Unity) - all this worked great together and exchanged messages.

Optimization

If we talk about optimization during development on Unity, the main points here:
  1. The smaller the draw calls, the better (although this is not a panacea). Previously, it was fought with special scripts for combining geometry in one mesh (CombineChildren), crafted designs with bones were collected (for example, 1 skinned mesh, 8 bones — 8 independent sprites with animation, such an approach, for example, was used in the top iOS game ZombieVille per unit). Now the developer is assisted by static batching, dynamic batching and Umbra (a system for cutting off invisible surfaces \ occlusion culling).
  2. Without necessity, it is better not to use Find \ GetComponent and similar methods - as far as possible it is better to save the reference to the component once the script is run.
  3. It is better not to perform extra calculations inside OnGUI() and not to use more than one OnGUI() at the same time.
  4. It is necessary to monitor such a parameter as Fillrate. Several planes the size of the entire screen with translucent material can seriously kill the performance on the PC, not to mention something like the iPad.

This, of course, only a couple of points, due to which you can win performance.

Rake

You can walk a little over a couple of first rakes or incomprehensible moments that await the novice developer at the beginning of the path.
  1. In unit, there is no “game loop” 'a or single entry point, as many have become accustomed to in other engines. Those. no one bothers you to organize such a thing, but by default the principle works: each game object is a certain set of components (including scripts), and each script can trigger its own set of events ( Start() , Update() , OnMouseDown() , etc.).
  2. First of all, before breaking into the forums, you should at least try to get acquainted with the project example of the monkey Lerpc.
  3. To find a game object by name, use the GameObject.Find(“Some Object”); method GameObject.Find(“Some Object”); To get a component (including a script) on this object (which is also often called “GO”) - use the code of the type __.GetComponent<>(); .
  4. More or less advanced developers are also in danger, but they have a more sophisticated rake. For example, not everyone knows that the so widely used way of working with materials ( render.material.color = Color.White; color.material.SetColor(“_Color”) , etc.) contains a trick: With this Access creates a copy of the material in memory (instance), and objects will not work with batching (which is static and dynamic - and skinned batching, contrary to popular belief, is not supported in 3.x). Therefore, you can either work with renderer.sharedMaterial (but then the material properties will change for all objects with this material), or you can change the color of the vertices using the Mesh class and the shader that reacts to such a color change.
  5. NPOT textures are bad (textures with sides that are not a power of two). Good sizes are 64, 128, 256, etc. On iOS, due to the use of PVRTC compression, you must also use square textures. Non-square textures are washed in 3D (not applicable to GUI), and more often memory flows from such textures. Here you can also note that it is absolutely useless to store textures in a unit project in jpg format, since Wednesday clamps graphic assets into its format. I like psd most of all for local development, and if the work goes remotely and I need to drive a lot of resources back and forth through the asset server \ mercurial \ svn, then I start to like png more.

Interesting additions to Unity3d

Let's look at some interesting additions to the unit.

From the latest interesting materials on the subject of Unity3d, you can note the selection of presentations from Unite'2010 posted on the official website.

Minuses

You can talk about the cons. For example:
  1. For a long time, Unitek promises to fasten a normal GUI, and that's all. But I believe in a bright future. On the other hand, everything is not so deadly - if UnityGUI really got you, you can use some lotion developed in the community that draws everything in 1 draw call and does not eat much CPU time (here, of course, there is plenty of room for finishing). I'd love to see a literate WYSIWYG for GUIs in a unit. If there is a time / desire - this can, of course, be arranged independently, since The possibilities for modifying the Editor IDE in a unit are truly enormous.
  2. You can easily crack songs made on Unity. You can reflect the code (though, untypical JS and Boo can often save the author). You can unpack bundle and webplayer compositions. You can load scenes and resources in almost their original form back into the editor. The code, of course, can be protected using obfuscation, but with resources it is more and more difficult (especially in the webplayer). On the other hand, this can not be considered a problem - a very subjective point.
  3. At the moment there is no support for displaying html inside the web player (which may change, because WebKit was seen in the triple editor, which is used in the Asset Store). If you need to render html and you can use the standalone application on a unit, you can see it here.

Conclusion


Cons can be found everywhere if you dig. On the topic of problems and problems in Unity can be discussed for a very long time, there is almost always a way to solve the problem. I think that unit is a wonderful tool, and if in 2011m Unity Technologies does not disappoint, the whole community will dance and rejoice in “how good that favorite tool develops!”.

On the nose of Unity 3.2 - join the unitologists!

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


All Articles