Skip to main content

Visibility

A class in Root.Township, Alta.Scrapper.

Network behaviour that turns a set of mesh renderers on or off from a hashed VisibilityData asset, saved with the entity and synced to players when they join.

Constructors​

MemberWhat it is
Visibility()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

3 private and internal fields
MemberWhat it is
private VisibilityData dataThe visibility asset in use. If a save has none, load picks a random one.
private MeshRenderer[] meshRenderersRenderers it shows or hides.
private MethodSync syncThe sync for the asset.

Methods​

MemberWhat it is
override void Initialize()Sets up the sync on SyncScrapper.
override void OnConnected(Player player)Sends the current asset to the joining player.
void Serialize(Stream stream)Writes or reads the asset by hash; remote clients take the read value.
3 private and internal methods
MemberWhat it is
private void ApplyData()Sets every renderer's enabled to the asset's value.
private void OnValidate()Does nothing.
private void Sync(IPlayer player, Stream stream)Message handler: serializes the asset and applies it on remote clients.