如何统一启用音频源?

时间:2018-01-25 07:15:51

标签: c# unity3d unity5

我正在尝试为我的团结练习项目添加一些声音,我已经应用了声音并准备了必要的脚本......但是现在每当我通过统一播放器测试它时音频都不起作用..每次我我收到此错误日志。

  

“无法播放已禁用的音频源UnityEngine.AudioSource:播放()   coinhandler:OnCollisionEnter2D(Collision2D)(at   资产/脚本/硬币/ coinhandler.cs:24)“

我的Coinhandler.cs脚本

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Audio;

public class coinhandler : MonoBehaviour {

public Transform particles;
public AudioSource coinCollectS;
// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}

void OnCollisionEnter2D (Collision2D collider)
{
    if (collider.gameObject.tag == "Player")
        coinCollectS.Play ();
    {
        Instantiate (particles, new Vector3 (transform.position.x, transform.position.y, -0.2f), Quaternion.identity);
        shooterMain.IncreaseSpeed ();
        shooterMain.increasePoint ();
        GameObject.FindWithTag ("points").GetComponent<Text>().text = shooterMain.getPoints ().ToString ();  
        Destroy (gameObject);
    }

    }

}

0 个答案:

没有答案