小编Fua*_*dov的帖子

Unity 3d 场景正在加载/未加载

我的场景一直说正在加载未加载,我无法正常播放

图片1

图像2

我没有收到任何错误消息或警告。不知道代码有没有错误(如果有,我不知道这里导入哪个部分,因为太长了),我不认为这是一个常见的事情,因为我找不到论坛中与此问题相关的任何内容。如果有办法解决,请帮忙。它工作正常,直到我将其添加到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)

c# unity-game-engine

1
推荐指数
1
解决办法
1330
查看次数

标签 统计

c# ×1

unity-game-engine ×1