polygone/Library/PackageCache/com.unity.multiplayer.mlapi@3e3aef6aa0/Runtime/Configuration/NetworkPrefab.cs
2021-08-02 05:44:37 -04:00

52 lines
1.4 KiB
C#

using System;
using MLAPI.Logging;
using UnityEngine;
namespace MLAPI.Configuration
{
/// <summary>
/// A class that represents a NetworkPrefab
/// </summary>
[Serializable]
public class NetworkPrefab
{
internal ulong Hash
{
get
{
if (Prefab == null)
{
if (NetworkLog.CurrentLogLevel <= LogLevel.Normal)
{
NetworkLog.LogWarning($"{nameof(NetworkPrefab)} is not assigned");
}
return 0;
}
var networkObject = Prefab.GetComponent<NetworkObject>();
if (networkObject == null)
{
if (NetworkLog.CurrentLogLevel <= LogLevel.Normal)
{
NetworkLog.LogWarning($"{nameof(NetworkPrefab)} {Prefab.name} does not have a {nameof(NetworkObject)}");
}
return 0;
}
return networkObject.PrefabHash;
}
}
/// <summary>
/// The gameobject of the prefab
/// </summary>
public GameObject Prefab;
/// <summary>
/// Whether or not this is a playerPrefab
/// </summary>
public bool PlayerPrefab;
}
}