githubEdit

Methods

Methods are written in PascalCase. For example DoSomething().

chevron-rightMethods that are used as the OnChange callback of a [SyncVar]hashtag

Should have the Sync prefix, as in:

[SyncVar(OnChange = nameof(SyncUsername))] string _username;
private void SyncUsername(string oldUsername, string newUsername, bool asServer) {}
chevron-rightMethods that listen to an eventhashtag

Should have the prefix Handle, as in:

clownBomb.OnExploded += HandleClownBombExploded;
private void HandleClownBombExploded() 
{
    Honk();
}
chevron-rightMethods that are preceded by the [Server] attributehashtag

Do not need to have the Server prefix on them. This is still something we are thinking about, both uses are fine for now.

As in:

[Server]
public void ServerKillPlayer() {}
[Server]
public void KillPlayer() {}
chevron-rightMethods that are preceded by the [ServerRpc] attributehashtag

Need to have the Cmd prefix on them, as in:

[ServerRpc]
public void CmdSpawnItem(GameItems item) 
{
    SpawnItem(item);
}
chevron-rightMethods that are preceded by the [ObserversRpc] attributehashtag

Need to have the Rpc prefix on them, as in:

[ObserversRpc]
private void RpcSpawnVisualProjectives() 
{
   _particleSystem.Play();   
}

Last updated

Was this helpful?