mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-23 20:43:04 +00:00
23 lines
520 B
C#
23 lines
520 B
C#
|
using System;
|
|||
|
using UnityEngine;
|
|||
|
using Object = UnityEngine.Object;
|
|||
|
|
|||
|
namespace SanAndreasUnity.Utilities
|
|||
|
{
|
|||
|
public class DestroyWhenNotOnServer : MonoBehaviour
|
|||
|
{
|
|||
|
public Component[] componentsToDestroy = Array.Empty<Component>();
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
if (!NetUtils.IsServer)
|
|||
|
{
|
|||
|
foreach (var component in this.componentsToDestroy)
|
|||
|
{
|
|||
|
Object.Destroy(component);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|