Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
4
Question by marcelop · Oct 30, 2015 at 09:03 PM · networkingmultiplayeronlineoffline

UNET: Is it possible to use the same scene for online and offline play? (without disabling my NetworkIdentity objects)

If I have a scene that is shared between online and offline games, it works fine for when the game is online (because the server activates the disabled NetworkIdentity objects). However, once I load this scene offline, all the GameObjects that contain NetworkIdentity are disabled. How should I do this? Creating a copy of the scene is just illogical, prone to error and horrible maintenance. Also, lots of my objects are prefabs, so creating copies of prefabs for offline play makes even less sense.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image M0rph3v5 · Nov 12, 2015 at 09:16 AM 0
Share

Wondering the same thing, have you come to a solution yet?

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by seanr · Nov 12, 2015 at 01:26 PM

For "offline" mode, you can just run the game as a host with no clients.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image anamta · Aug 05, 2016 at 10:37 AM 0
Share

doesn't work in many of the cases

avatar image
0

Answer by jankrib · Apr 07, 2018 at 07:41 AM

I know this is an old question, but this is something I always struggle with. I managed to get a decent setup now where I do as @seanr suggests and create a host when running offline.

Still, I couldn't run scenes for debugging without going through the main menu of the game because unity would disable all my game objects with a NetworkIdentity. My solution was to create a PostProcessor for the scene. This creates a dummy NetworkManager if there is not one already.

 public class MyScenePostprocessor
 {
     [PostProcessSceneAttribute(2)]
     public static void OnPostprocessScene()
     {
         if (!Debug.isDebugBuild)
             return;

         var networkManager = Object.FindObjectOfType<NetworkManager>();
 
         if (networkManager == null)
         {
             networkManager = new GameObject("DummyNetwork").AddComponent<NetworkManager>();
             networkManager.playerPrefab = Resources.Load<GameObject>("Player");
 
             networkManager.StartHost();
 
         }
     }
 }
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Mathyx · Aug 09, 2018 at 03:16 PM 0
Share

I used your solution and I works sofar that it spawns the playerPrefab. But still all my NetworkIdentity objects that are part of the scene are beeing disabled and I can't get them to be activated

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

NetworkIdentity Disabling GameObjects 1 Answer

How to use an RPC to send an animation over the network? 2 Answers

Should I be using peer-to-peer networking for my 1v1 game? 1 Answer

Popular Multiplayer Framework/Services? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges