我在代码中包含了以下行,但AudioController
突出显示为红色,因此我搜索了相应的命名空间,但似乎UnityEngine
就足够了。
我还应该包括哪些才能使用它?
private AudioController audioController;
以下是完整的相关代码:
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Collections;
public class MenuScript : MonoBehaviour
{
private AudioController audioController;
void Awake()
{
DontDestroyOnLoad( this.gameObject );
}
void Start()
{
audioController = GameObject.FindWithTag("AudioController").GetComponent<AudioController> ();
}
public void LoadLevel( string sceneName )
{
audioController.PlayMenuClick();
StartCoroutine( LoadSceneAsync( sceneName ) );
}
private IEnumerator LoadSceneAsync( string levelName )
{
yield return new WaitForSeconds( 0.2f );
Application.LoadLevel( levelName );
}
public void startSimulation()
{
LoadLevel( "mainScene" );
}
}