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 tydygunn · Sep 04, 2012 at 05:44 PM · networkingphoton

Photon Cloud Networking: OnPhotonSerializeView Not Firing

Hello everyone, let me start by saying that I'm having the exact same problem as this fellow:

http://forum.unity3d.com/threads/103953-Problem-using-PhotonViews-from-the-Photon-Plugin

I recognize "tobiass" is one of the Photon engineers and I would much rather post in their forums, but the registration email isn't getting sent to me so hopefully he'll find his way here, eh?

Just like that guy in the forum I linked, my OnPhotonSerializeView of the Observed "PlayerNetwork.cs" script is not getting fired. I don't really understand Tobiass' answer: "If you actually implemented "OnPhotonSerializeNetwork", it's no wonder it's not called." What does he mean by 'implemented'? I know I'm missing something super-simple, but combing the tutorials hasn't fixed anything yet.

I'm converting my existing single-player game based on the Marco Polo tutorial from Photon as well as by examining the Viking Demo they've put together. In the Viking Demo, the Observed script on PhotonView has an OnPhotonSerializeView function, and it's getting called.

  • "playerMain" is the prefab; it's in the Resources folder and it instantiates fine using PhotonNetwork.Instantiate();

  • The prefab has a "PhotonView" script, and that script obseves "PlayerNetwork.cs" which contains the OnPhotonSerializeView that isn't firing.

  • OnPhotonSerializeView is spelled correctly in the code.

Thank you guys so much for any help you could offer.

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

9 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by luckruns0ut · Sep 23, 2013 at 08:53 PM

I don't mean to gravedig, but as this is the first page that google shows I'll post:

you drag the actual component drop-down in the inspector onto the photonview, i just spent ages finding out why dragging the script wouldnt work.

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 tydygunn · Sep 23, 2013 at 08:57 PM 0
Share

This is correct. You need to drag the actual component from the inspector onto that variable on the same object. When I asked this, I still had no idea I could do that! Hahaha.

avatar image
6
Wiki

Answer by FuZZbaLL_b · Feb 25, 2013 at 08:02 AM

I think i had the same problem. I solved it by rereading the Marco Polo tutorial. It says

We need another script. Create a “NetworkCharacter” C# script in the Marco Polo folder. Add it to the “monsterprefab” and make it the observed component of the PhotonView(drag & drop).

This means that we first have to have a PhotonView on our prefab, then we need to add this NetworkCharacter script to our prefab and then we need to drag this NetworkCharacter script to the Observe property of our PhotonView.

Now the Observe property will look like this

Observe: (NetworkCharacter) [] CarPrefab

Instead of this

Observe: (UnityEngine.Transform) [] CarPrefab

Now the OnPhotonSerializeView will fire

I hope this helps

Comment
Add comment · Show 2 · 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 atomworks · Mar 23, 2014 at 07:28 PM 0
Share

I've not got the rep to upvote this yet; It solved the problem perfectly for me. $$anonymous$$uch clearer explanation than all the others too!

avatar image tracer5 · Apr 11, 2014 at 03:40 AM 0
Share

Just to add, you have to drag the component from the header (checkbox area) not from the script reference itself within the component.

avatar image
3

Answer by MikeHergaarden · Sep 05, 2012 at 09:34 AM

"implementing it" means that you must have a C# script with the following code in it:

 void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
 {
 //Your code here..
 }

Furthermore, make sure that this script is set as "observed" for that PhotonView. It looks like you have already done so.

Also note that it is only called when at least 1 other player is connected, maybe this is what you're missing?

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 Daedin · Apr 11, 2015 at 12:21 PM 0
Share

Thanks for your last point, I didn't realize it would be only called when at least one other player is connecter

avatar image
1

Answer by nikita68 · Feb 08, 2013 at 02:39 PM

first put the prefab into the scene.

then make the script get observed in the inspector.

then apply the changes to the prefab and destroy the object in the scene.

After those steps the script should work fine.

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 iceberg · Mar 09 at 08:19 AM 0
Share

as unlikely as this solution sounds, it is the only one that worked for me.

avatar image
0

Answer by Yuu-Interactive · Jan 14, 2013 at 05:25 AM

I have the same problem, i cant get observed my prefab, it has all components needed, i checked the code many times and dont work.

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
  • 1
  • 2
  • ›

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

19 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

Related Questions

Player names all displayed as local player 1 Answer

Networking already instantiated assets 1 Answer

Photon Virtual Joystick won't work after another player has joined the network...? 1 Answer

(C#) Help with Multiplayer Features - Photon Unity Networking 0 Answers

Strange IP and Port when using Network.Connect() 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