Search Unity

[Server] vs isServer

Discussion in 'Multiplayer' started by Deleted User, Jul 1, 2015.

  1. Deleted User

    Deleted User

    Guest

    What is the difference in using the [Server] attribute vs having the following at the top of a function?

    if (!isServer)
    return;
     
  2. Necromantic

    Necromantic

    Joined:
    Feb 11, 2013
    Posts:
    116
    isServer is obviously more flexible because you can separate parts of a method while the ServerAttribute affects the whole method. Unless you use the ServerCallbackAttribute the ServerAttribute will also throw a warning to the console when the method is called on a client.
    So if you are really just returning immediately if it's not run on the Server one of the Attributes is probably the better choice. It also makes that design choice more visible.
     
    Deleted User likes this.