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
0
Question by cubrman · Jul 31, 2016 at 03:38 PM · networkingserialization

NetworkBehaviour.OnDeserialize() does not get called on player prefabs

While OnSerialize() is called, I cannot see any calls to OnDeserialize() on my player prefabs. I tried overriding both methods and setting a breakpoint inside them. I tried on both local client and locan server.

What I basically need is a way to create a custom spawning code for my .isLocalPlayer = false objects (I already know how to custom spawn isLocalPlayer = true objects). I thought I can add extra information that i need (it is netId-s of GameObject-s the scripts on my player prefab are referencing) into the writer in OnSerialize() and read it in OnDeserialize() but the latter never gets called on any peer.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Eagles_rule_der · Jan 28, 2018 at 07:56 AM

Hey man :-) As a note, I would imagine that you are running on the unity editor as host. The thing is that when you spawn as a client, being the spawnER you should 'know' what the object looks like, so it gets OnSerialise() such that the server (as one of the spawnEEs) needs to determine its state. As a server you dont actually need to deserialise the object, just store it for when other player connects and need to copy the object so its in the same state as the server, but it woul never return to the spawnER with an OnDeserialise call

Not sure what the design structure is, but as a few ways to help see whats happening

  1. Build the project, and on the built version start as host, and inside the unity editor start as client

  2. Alternatively, run SetDirtyBit(1) in an Update(), this registers the object needs an 'update' and triggers OnSerialise(..., false) and see what pulls out with this

Note however that whatever functionality you are trying to pull really shouldnt be handled in an OnDeserialise as the intent is to send the changes moreover implement them (Think how you would for example Foo(bool) {doSomeThing(bool); CmdFoo(bool);} for this exact same reason)

Therefore you could always try and test this by implementing in a function and calling via OnDeserialise AND Awake (for eg)

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

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

Related Questions

Photon (PUN) Type Serialization Error on RPC 2 Answers

M2H auth example moveDirection 1 Answer

UNet Network Behevior On DeSerialization/Serialization Help 1 Answer

OnDeserialize is not being called on by client. 0 Answers

Client to client Serialization 1 Answer


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