Skip to content

Commit 259bbb2

Browse files
committed
Added prefab helper methods
1 parent 8fde6c5 commit 259bbb2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

MLAPI/NetworkingManagerComponents/Core/SpawnManager.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,26 @@ public static int GetNetworkedPrefabIndexOfHash(ulong hash)
124124

125125
return -1;
126126
}
127+
128+
/// <summary>
129+
/// Returns the prefab hash for the networked prefab with a given index
130+
/// </summary>
131+
/// <param name="index">The networked prefab index</param>
132+
/// <returns>The prefab hash for the given prefab index</returns>
133+
public static ulong GetPrefabHashFromIndex(int index)
134+
{
135+
return NetworkingManager.Singleton.NetworkConfig.NetworkedPrefabs[index].Hash;
136+
}
137+
138+
/// <summary>
139+
/// Returns the prefab hash for a given prefab hash generator
140+
/// </summary>
141+
/// <param name="generator">The prefab hash generator</param>
142+
/// <returns>The hash for the given generator</returns>
143+
public static ulong GetPrefabHashFromGenerator(string generator)
144+
{
145+
return generator.GetStableHash64();
146+
}
127147

128148
/// <summary>
129149
/// Returns the local player object or null if one does not exist

0 commit comments

Comments
 (0)