我的场景一直说正在加载和未加载,我无法正常播放
我没有收到任何错误消息或警告。不知道代码有没有错误(如果有,我不知道这里导入哪个部分,因为太长了),我不认为这是一个常见的事情,因为我找不到论坛中与此问题相关的任何内容。如果有办法解决,请帮忙。它工作正常,直到我将其添加到Update()功能中:
if (health <= 0)
{
RestartGame();
}
Run Code Online (Sandbox Code Playgroud)
并将其添加到 void OnControllerColliderHit (ControllerColliderHit c)
if (c.gameObject.tag == "enemy")
{
AudioSource audio1 = GetComponent<AudioSource>();
audio1.PlayOneShot(hurt);
health -= 25;
}
Run Code Online (Sandbox Code Playgroud)
我以前有这个:
void RestartGame()
{
StartCoroutine(Wait3secs());
Application.LoadLevel(Application.loadedLevel);
}
Run Code Online (Sandbox Code Playgroud)
完整代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class detect_collision : MonoBehaviour
{
private int health;
public bool isGun;
private bool isKey;
private bool isMatches;
private int usedGun = 0;
public AudioClip soundCollectedObject;
public AudioClip …Run Code Online (Sandbox Code Playgroud)