I recently started working on a project that was developed with single-player play in mind for around 3 months. To add multiplayer functionality (simple 1v1 server-client connection) I chose Unet, following mostly Unity tutorials and examples. I was able to change the single player scripts to multiplayer format, but the issue I have right now, is that they work only in multiplayer now (GameObjects with Network Identity component become disabled by default). From what I can determine, I have the following options:
- Have different scripts/prefabs/logic for both online and offline modes. This is probably the easiest solution, but one that's the worst (e.g when making changes on the offline prefab/script I have to manually change the online one too)
- Since most changes of the scripts involve simply changing inheritance from MonoBehaviour to NetworkBehaviour, I could either find the way to change the inheritance during the runtime (which i don't think is possible) or create 2 versions of the scripts, with the correct one being attached when the prefab is spawned.
- Consider offline/singleplayer mode as the same thing as online, only with a solo player as a host. Unfortunately, I'm not so good with networking, having used only built-in HLAPI stuff like network transforms / modified scripts from Unity examples, so if you have any good entry level guides to more advanced network scripting, I would greatly appreciate it.
What's the best way to approach this kind of problem? If you have any other suggestions, feel free to share.