Home c# application architecture (games) on unity

application architecture (games) on unity

Author

Date

Category

began to develop unity games. When creating began to occur with the “cleanliness” and “literacy” of scripts. I can not find or think of a maximum competent scheme for building architecture.

Tell me where to read the most useful tips on this topic. Or, write your thoughts and tips on this.

p.s. I suspect that for different games – different architectures, but it seems to me that the similarity will still be similar. For the convenience of understanding my problem, take as an example such a genre as an isometric shooter: a character, zombies, houses, weapons and other charms.

Thanks in advance


Answer 1

Having read the komenti …. In general, I do not agree with the opinion that in the case of UNITi will help “Pure Code”. Unity has its own characteristics and they literally force the programmer to write incorrectly or build the project is incorrectly. I read a clean code and the unity I still forced me in many places to write wrong and studying on your own mistakes.

I am sure that it is better to read concrete literature that will tell specifically about UNITI. Moreover, it is impossible to write a code that did not contradict some patterns. Even reading the “clean code” you can see many rules that contradict one second within one book (which, by the way, the author also allocated!). There is no universal proper approach – there will always be compromises when writing code.

From the fact that you can remember on the issue (not quite about the architecture, rather in general, the tips) is:

  • Do not use the old GUI, but only a new Youth on Canvas
  • Do not use the accelerated control buttons, for this there is an Input Manager or something like that
  • As you need to use DontDestroyonload – for example, when you always need to keep the current settings in the memory during the transition between the levels. All you need in different scenes should not be unloaded from the memory. To re-boot.
  • Use asynchronous loading of scenes
  • minimally use the inspector fields in which you attach an object on stage or prefab. Better if you are looking for them in a script at Start / Awake on the stage or in the Schedule itself, see the prefab code. Will constantly fall off if the project is a little more one-day and you will spend a lot of time.
  • Use Movements Based on Physics – you will go around a lot of bugs. Go to the non-physical movement exclusively in extreme cases.
  • look for scripts-components always in Start / Awake. If you do getComponent & lt; & gt; In another place – practically probably you do something wrong and it will lead to brakes
  • If you need to manage objects – it is better to keep the link to them in some script manager. Get an object from this manager faster than re-look for the same object on the stage in most cases.
  • Never use Try Catch – brakes from scratch. Replace on if else
  • Use attributes to the parameters (like [Range (1, 6)] ) – they facilitate life. But remember the features of UNITY – using the attribute you can see unexpected behavior. For example, changing the default value in the code, it will not change in the inspector.
  • If one components requires the availability of another – be sure to use the Required COMPONENT attribute
  • the less connectedness between objects – the better.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions