using FishNet.Managing.Object;
using FishNet.Object;
using UnityEngine;
namespace FishNet.Managing
{
public partial class NetworkManager : MonoBehaviour
{
#region Serialized.
///
///
///
[Tooltip("Collection to use for spawnable objects.")]
[SerializeField]
private PrefabObjects _spawnablePrefabs;
///
/// Collection to use for spawnable objects.
///
public PrefabObjects SpawnablePrefabs { get => _spawnablePrefabs; set => _spawnablePrefabs = value; }
#endregion
///
/// Gets the index a prefab uses. Can be used in conjuction with GetPrefab.
///
///
/// True if to get from the server collection.
/// Returns index if found, and -1 if not found.
public int GetPrefabIndex(GameObject prefab, bool asServer)
{
int count = SpawnablePrefabs.GetObjectCount();
for (int i = 0; i < count; i++)
{
GameObject go = SpawnablePrefabs.GetObject(asServer, i).gameObject;
if (go == prefab)
return i;
}
//Fall through, not found.
return -1;
}
///
/// Gets the NetworkObject prefab for index. Can be used in conjuction with GetPrefabIndex.
///
/// True if to get from the server collection.
///
///
public NetworkObject GetPrefab(int index, bool asServer)
{
return SpawnablePrefabs.GetObject(asServer, index);
}
}
}