mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-03-22 01:34:22 -05:00
26 lines
679 B
C#
26 lines
679 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using MLAPI;
|
|
using MLAPI.Messaging;
|
|
|
|
public class ObjectCleanup : NetworkBehaviour {
|
|
|
|
void Start() {
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
|
|
[ServerRpc(RequireOwnership = false)]
|
|
public void DestroyPersistingNetObjectsServerRPC() {
|
|
NetworkObject[] networkObjects = FindObjectsOfType<NetworkObject>();
|
|
Debug.Log("Here");
|
|
foreach (NetworkObject nObj in networkObjects) {
|
|
GameObject netObj = nObj.gameObject;
|
|
|
|
if (netObj == gameObject) { continue; }
|
|
|
|
netObj.GetComponent<NetworkObject>().Despawn(true);
|
|
}
|
|
}
|
|
}
|