Unity5 Official tutorial Note (2D Rogue like) 06--soundmanager and Loader

Source: Internet
Author: User

As a support unit, Soundmanager and loader play a very important role in the game. Since these two things are relatively simple, they will be explained in this article.

First say Soundmanager:

Soundmanager and Gamemanager, just need one at the same time, so also set as singleton mode. So in the awake method and Gamemanager basically the same.

It can be noted that in unity it is not entirely simple to select a sound clip and then play it, but to bind a sound to a "audiosource".

Audiosource can be understood as a "DJ", a DJ that can add effects to the sound and decide when to play a sound. At the same time for some 3d games, the relationship between the DJ's location and your location, as well as the placement of your scene will affect the sound you hear (of course, this effect is rarely used by our God-viewing game)

It is worth noting that the Randomizesfx method in this:

In addition to randomly choose a play from a few sound effects, but also add the pitch effect, in here is to add a little bit of sound pitch changes, so that the sound seems more random.

Again, say loader:

This class is very, very simple, and the only purpose now is to instantiate the Gamemanager. "Why does a similar soundmanager not have to be instantiated in code?" "Because there's already a soundmanager in the hierarchy view that we dragged in, kid! ”

In fact, there are other things that can be done in addition to instantiating Gamemanager, but in this case there is not much work to do, so this is the only thing to do here first.

In addition, if a script wants to run, the one thing necessary is to cling to a gameobject, and here we choose Maincamera as the object of this attachment. The main reason I personally think it may be because this object is not easily destroyed, and for the other objects we create basically no dependency, high independence, so it is appropriate to do this kind of guided work.

Well, the whole story is almost over, and the last one we'll talk about the UI, basically this thing even finished, and then if there is anything else that needs to be added will also open the article alone.

Unity5 Official tutorial Note (2D Rogue like) 06--soundmanager and Loader

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.