Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

[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.