First, the basic knowledge
1, the project needs to have Audiolistener, the player plays the sound is the Audiolistener component sits in the position hears the sound. The default audiolistener is placed on the main camera. There is no sound to be heard without audiolistener. Generally, the default is on the camera.
2, drag the music into the assets, select the game object to play the music (if the chicken, tank explosion and other sounds generally put on the chicken, tank these game objects, and background music, etc. are generally placed on the camera), click the main menu: Component→audio→audio source Add the audio component to the Gameobject, and then drag the music file onto the audio clip property of the component. Mute settings are muted, play on awake for AutoPlay, Loop Loop, volumn for volume.
Ii. examples
1, use the box example: http://www.cnblogs.com/bjlhx/p/8214277.html
2, check whether the main camera contains, Audiolistener, if missing, you can add the menu component
3, add music material, directly from the local drag to the assets directory.
4, add background music, usually added by default on the main camera, Component→audio→audio source
5, add sound effects, add to specific things.
This is added to the ground, triggering the sound each time the sphere launches. Using Scripting to control
Public classInit:monobehaviour {PrivateGameobject Goplane; //Use this for initialization voidStart () {Goplane= Gameobject.find ("Plane"); for(inti =0; I <4; i++) { for(intj =0; J <4; J + +) {Gameobject go=gameobject.createprimitive (Primitivetype.cube); Go.transform.position=NewVector3 (I, J,-1); if(J%2==0) {go. Getcomponent<Renderer> (). Material.color =color.red; } go. AddComponent<Rigidbody>(); Go. AddComponent<AutoDestory>(); } } } //Update is called once per frame voidUpdate () {if(Input.getmousebuttondown (0) {gameobject gonew=gameobject.createprimitive (Primitivetype.sphere); GoNew.transform.position=Camera.main.transform.position; Gonew.addcomponent<Rigidbody>(); Gonew.addcomponent<AutoDestory>(); Goplane.getcomponent<AudioSource>(). Play (); Vector3 Targetpos= Camera.main.ScreenToWorldPoint (NewVector3 (input.mouseposition.x, INPUT.MOUSEPOSITION.Y,3)); Gonew.getcomponent<Rigidbody> (). Addforce ((targetpos-camera.main.transform.position) *Ten, Forcemode.impulse); } }}
View Code
Note The Goplane in the code.
Three, the Sky box
Sky Box A total of six faces, you can set the map individually, you can import some of the built-in free skybox.
Before version 5.0
Right-click on Project and select: Import package→characters→skyboxs. Then in the main menu select: Edit→render Settings, then in the Inspector panel, modify Skybox Meterial, select the imported footage.
After version 5.0
Default has been added
If modified, the main menu →windows→lighting
005-unity3d Add background music, sound effects and Sky boxes