forked from cgvr/DeltaVR
Created a single prefab to incorporate all the networking stuff. This is the only networking prefab required in the scene. We will see if git breaks it.
This commit is contained in:
40
Assets/_PROJECT/Multiplayer/CustomNetworkManager.cs
Normal file
40
Assets/_PROJECT/Multiplayer/CustomNetworkManager.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using FishNet.Component.Spawning;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Valve.Newtonsoft.Json.Converters;
|
||||
using static UnityEditor.ShaderGraph.Internal.KeywordDependentCollection;
|
||||
|
||||
public class CustomNetworkManager : MonoBehaviour
|
||||
{
|
||||
|
||||
public static CustomNetworkManager instance = null;
|
||||
|
||||
public PlayerSpawner playerSpawner;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (!instance) { instance = this; }
|
||||
else if (instance != this) { Destroy(gameObject); }
|
||||
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (playerSpawner.Spawns.Length == 0) {
|
||||
Debug.LogWarning("Player spawns undefined. Assign a player spawn to PlayerSpawner!");
|
||||
} else {
|
||||
bool hasSpawn = false;
|
||||
foreach (Transform spawn in playerSpawner.Spawns)
|
||||
{
|
||||
hasSpawn |= spawn != null;
|
||||
}
|
||||
if (!hasSpawn)
|
||||
{
|
||||
Debug.LogWarning("Player spawns undefined. Assign a player spawn to PlayerSpawner!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user