Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Unity Multiplayer Using Mirror when Offline

Discussion in 'Multiplayer' started by Kokowolo, Dec 24, 2020.

  1. Kokowolo


    Mar 26, 2020
    I have this scene where a player can edit a map offline before taking the scene online to play with other clients. The problem is I don't want the players to be able to edit the map (and it's characters) once they are online, but be able to do so when they are offline. Here is an example:

    Code (CSharp):
    1. [Server]
    2. public void ServerExampleFunction()
    3. {
    4.     // code I want to run when offline but not online...
    5. }
    The function ServerExampleFunction() can only execute on the Server at the moment. When the scene is offline, any call to this function will fail. How do I get it to run offline while ensuring that a malicious client can't hack the game when it's taken online? Do I have to make the offline player a host of his own lobby when offline to give them permission to call the function? Is there a way to toggle the [Server] attribute when offline and enable it once the game is taken online?

    I know this is a confusing question, but any pointers would be really helpful.
    Last edited: Dec 24, 2020