Unity Kick玩家汽车游戏

时间:2016-10-15 00:14:28

标签: unity3d

有人可以告诉我如何加入这个 码 进入下面一个? 我真的不知道自己在做什么;它不起作用,只是冻结。我希望玩家能够在不冻结游戏的情况下离开。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void OnPlayerDisconnected(NetworkPlayer player) {
    Debug.Log("Clean up after player " + player);
    Network.RemoveRPCs(player);
    Network.DestroyPlayerObjects(player);
    }
}


using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;
using UnityEngine.Networking;

public class RG_Disconnect : MonoBehaviour {

    // Use this for initialization
    void Start () {
        GameObject lobbyManager;
        lobbyManager = GameObject.Find ("LobbyManager");
        if (lobbyManager != null)
            Destroy(lobbyManager);
        NetworkManager.Shutdown ();
    }

    // Update is called once per frame
    void Update () {
        SceneManager.LoadScene ("Garage");
    }
}

1 个答案:

答案 0 :(得分:1)

当然冻结了。您正在每帧更新中加载名为“Garage”的场景。

https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadScene.html LoadScene仅用于加载特定场景一次。