PUN Classic (v1), PUN 2 and Bolt are in maintenance mode. PUN 2 will support Unity 2019 to 2022, but no new features will be added. Of course all your PUN & Bolt projects will continue to work and run with the known performance in the future.
For any upcoming or new projects: please switch to Photon Fusion or Quantum.
Prefab ID
Each prefab which is compiled gets a unique id which is also referred as the "Prefab ID".
Uses of the Prefab ID
The prefab id can be used for instantiating bolt prefabs with their ID.
If you would like to make a drop system for objects in your game
and you want to transmit a prefab in an event then you just add a new property to your event.
Let's say "ItemToDrop" and define him as "Prefab id" and then do something like:
C#
void DropItem()
{
using(var evnt = DropItemEvent.Raise(Bolt.GlobalTargets.Server))
{
evnt.ItemToDrop = Item.DropPrefab.GetCompoment<BoltEntity>().ModifySettings().prefabid;
//ModifySettings - this isnt for editing the entity, its for getting the modifysettings of it.
}
}
override OnEvent(DropItemEvent evnt)
{
BoltNetwork.Instantiate(evnt.ItemToDrop); //Instantiate a prefab with the prefab id that we transmited in the event.
}
Back to top