Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Ranom · Dec 05, 2012 at 06:56 PM · networkingnetworkview

Persisting NetworkView across Scene change does not work

I have two scenes set-up as follows:

Scene A |_ ObjectA |_NetworkView (pointing at ScriptA) |_ScriptA

Scene B | ObjectB | NetworkView (pointing at ScriptB) |_ ScriptB

In Scene A I call Object.DontDestroyOnLoad(ObjectA). This prevents the object from being destroyed when I transition to Scene B.

Using ObjectA.networkView.RPC("SomeMethod", RPCMode.Others, params) correctly calls the RPC method on all networked clients.

I then transition to scene B and end up with the following set-up:

Scene B
|_ Object A
    |_NetworkView (pointing at Script A)
    |_Script A
|_ Object B
    |_ NetworkView (pointing at Script B)
    |_ Script B

Using ObjectA.networkView.RPC(...) still works.

Using ObjectB.networkView.RPC(...) does not work giving the error "RPC call failed because the function 'ObjectBTest' does not exist in any script attached to 'ObjectA'

If I load straight in to Scene B (so I don't end up with ObjectA) it works correctly.

It looks like Unity3D isn't ensuring unique NetworkViewIDs across scene changes.

I found the following bug that describes the same problem https://fogbugz.unity3d.com/default.asp?288477_235rid2h but I can't see what the resolution was.

Am I doing something wrong or do I have to work around this?

Comment
Add comment · Show 2
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 Ranom · Dec 05, 2012 at 06:58 PM 0
Share

Possible solutions I've come across:

  1. Splitting the object in two parts, the persisted object and a dummy object containing the networkview. The dummy object handles all RPCs (with the scene allocated NetworkViewID) and forwards them on to the persisted object.

  2. Having a master object, persisted across scenes, that allocates all NetworkViewIDs to the server and the clients. Quite a pain to synchronise.

avatar image maraoz · Dec 24, 2012 at 08:28 PM 0
Share

I'm having the same problem. :(

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by maraoz · Dec 24, 2012 at 08:43 PM

Found this:

The whole idea behind SetLevelPrefix is to differentiate NetworkViewIDs defined in different scenes. When you put a Network View in a scene, it's automatically attributed a View ID. But this View ID is guaranteed to be unique only in this very scene, not in your whole project. So you may end up having the same ViewID in different NetworkViews if you load scenes with LoadLevelAdditive or mark gameObjects with DontDestroyOnLoad. When this happens, RPCs to one may land in the other, and you'll be in for a lot of pain.

So maybe the solution is to use Network.SetLevelPrefix()

Comment
Add comment · 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

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

11 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 avatar image

Related Questions

Multiplayer Flashlight Issue 1 Answer

View ID AllocatedID: ### not found during lookup. Strange behaviour may occur 0 Answers

How to send UDP updates form server to each Client? 0 Answers

why if i destroy gameobject in 1st player and the other player is not? 0 Answers

State synchronization non-functional after mode change? 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