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
1
Question by Zoelovezle · Jan 05, 2016 at 07:39 PM · networkinglistsynctypescritping

SyncList TO

I asked question about using SyncList< TO > before, but unfortunately no one answered.

But Hey , Dont Worry. I read almost all networking documentation and off course this but i dont got the hint to declare SyncList< TO > .

So i read the **(UnityEngine.Networking)** script and then i got the hint :P .

Here we go :) Hope this helps you out .

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

3 Replies

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

Answer by Zoelovezle · Jan 05, 2016 at 07:53 PM

 using UnityEngine;
 using System.Collections;
 using UnityEngine.Networking ;
 
 public class MySyncVars : NetworkBehaviour {
  // I am declaring Vector3 Sync LIst , for that small hint 
    
     public class SyncListVector : SyncList<Vector3> {
         
         protected override void SerializeItem(NetworkWriter writer, Vector3 item)
         {
             writer.Write(item);
         }
 
         protected override Vector3 DeserializeItem(NetworkReader reader)
         {
             return reader.ReadVector3();
         }
 
     }
     
     public SyncListVectors myVector3 = new SyncListVectors() ;
 }
 
 //After this class now we can just create a SyncList of type Vector3 as ,
 
 public SyncListVector3 mySyncVectorList = new SyncListVector3() ;
 
 //And its done now , 
 public Vector3 someVector ;
 void Start() 
 {
      mySyncVectorList.Add(someVector) ;
 //Now this will sync and work same as other SyncList
 } 

Documentations for Reference :

  • SyncList< TO >

  • UNet SyncState

  • Network Writer

  • Network Reader

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 ntrubkin · Jan 18, 2017 at 08:25 PM 0
Share

Great solution. But list with vectors will not be syncronized for new client. New client has empty list at start. Default lists like SyncListString, SyncListFloat , SyncListInt etc. works fine.

avatar image
0

Answer by svendkiloo · Jan 12, 2017 at 09:03 AM

Thank you @Zoelovezle. I've used the solution from your answer above to keep a list of Vector3 objects synced, and it works fine. However, I get these warnings whenever the project compiles:

 UNetWeaver warning: The class / struct SyncListVector3 has no public or non-static fields to serialize

Since it works, I presume the warning is wrong?

If I add a public field, say:

 public bool boolThatMakesNoDifference1;

the warnings go away, but I'd rather not do that. Is this a "bug" in UNetWeaver that it warns, or am I doing something "cheeky"? :)

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

Answer by Alturis2 · Aug 01, 2017 at 01:26 AM

No, it looks to me like you are not using your SyncListVector class at all but instead the built in SyncListVector3

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

48 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

Related Questions

Why Does Adding to My SyncListStruct Break SyncVar? 0 Answers

Networking: how to sync complex objects 0 Answers

A node in a childnode? 1 Answer

How to Sync List 1 Answer

SyncVar on objects in a list 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