声音不能在Android游戏中统一构建5

时间:2015-11-15 20:48:07

标签: android unity3d

我正在制作游戏,当我在团结编辑器中或通过"构建和运行" android的选项。

然而,当我使用apk文件并在手机上安装游戏时,声音似乎无法正常工作。

在通过Unity 5进行开发时,有人可以给我一个解决Android上声音问题的参考吗?我的工作是在Windows 10上完成的。

脚本:

using UnityEngine;
using System.Collections;

public class PlayerControl : MonoBehaviour{

bool check = false; 
AudioSource sounds;
public AudioClip coin;
public AudioClip treasure;
public AudioClip power;
public AudioClip g_power;
public AudioClip spring_up;
public AudioClip cheerUp;

void Start ()
{
    sounds = GetComponent<AudioSource> (); 
}

void Update ()
{ 
    if (!check && Movement.gameStart) {
        check = true;
    }   

} 

void OnCollisionStay2D (Collision2D col)
{
    if (col.gameObject.tag == "box" && GetComponent<Rigidbody2D> ().velocity.y <= 0)  
        Movement.inAir = false;    
}


void OnTriggerEnter2D (Collider2D col)
{
    if (UI.sfx) {
        if (col.gameObject.tag == "coin") 
            sounds.PlayOneShot (coin, 1f);
        else if (col.gameObject.tag == "treasure") {
            sounds.PlayOneShot (treasure, 1f); 
            sounds.PlayOneShot (cheerUp, 1f); 
        } 
        if (GetComponent<Rigidbody2D> ().velocity.y <= 0) {
            if (col.gameObject.tag == "green") {
                sounds.PlayOneShot (g_power, 1f);
                sounds.PlayOneShot (spring_up, 1f);
            } else if (col.gameObject.tag == "blue") {
                sounds.PlayOneShot (power, 1f);
                sounds.PlayOneShot (spring_up, 1f);
            }
        }
    }
}}

0 个答案:

没有答案