The Bug:
The project contains a player class, which has a SyncListStruct of type Skill. The synclist is NOT synced to clients if the Skill struct is in a file with the name Skill.cs, but it works with other files names (the struct name itself always remains ‘Skill’). Here are the file names that I tested. Red means the bug happens, green means everything is fine:
Skill.cs
SkillFix.cs
S_kill.cs
SkillCopy.cs
FuSkill.cs
FSkill.cs
XSkill.cs
xSkill.cs
WTFSkill.cs
BuggySkill.cs
ItemCopy.cs
Let me repeat this: the code (and name) for the skill struct is always the same:
using UnityEngine;
using UnityEngine.Networking;
[System.Serializable]
public struct Skill {
public string name;
public bool learned;
public float castTimeEnd;
public float cooldownEnd;
}
public class SyncListSkill : SyncListStruct<Skill> { }
How to reproduce:
Open the attached project, open the scene file, build the project.
Select “LAN Server” in the build
Select “LAN Client” in the Editor
Take a look at the Player object in the Inspector and see how the SyncList is empty, even though it should have one entry (this is the bug)
Close the build, stop the Editor
Rename the Skill.cs file to BuggySkill.cs and repeat the process to see how the SyncList now has one entry as it should
Test Environment:
Linux Mint 17.2 64 bit with Unity for Linux Version 5.3.1f1.
A very similar file name related bug was already reported as #737241 in FogBugz last October, without any response.
It would be really nice if someone from the UNET team fixes this bug or at least confirms it.
WOW! I was struggling my head because I thought that I was doing something wrong to the synclist but you’re right, I’ve changed mi filename from playerStruct.cs to SPlayer.cs and it worked perfectly!!
You are welcome. Someone from the Q&A team also confirmed it a few days ago. He said he’ll forward it to a developer. It would be really interesting to know what caused it.
Thanks for posting this. I couldn’t for the life of me figure out why one list worked but my other list didn’t. They both were using the same struct for their list. The Add command would show it fired but nothing would be added. After renaming the struct and the SyncListStruct it works.
THIS NEEDS TO BE FIXED. THIS PROBLEM HAS TOOK ABOUT A MONTH OF MY LIFE, JUST TO SYNC A LIST OF STRUCTS. THIS IS UNACCEPTABLE AND IF THIS IS NOT ADDRESSED AND FIXED SOON, I WILL GIVE UP ON UNITY ENGINE AND MOVE TO UNREAL.
Threatening to move to Unreal won’t get the problem fixed any faster. The developers have MANY aspects of the engine to work on, not just UNet. Besides, ONE person with a SINGLE forum post switching to Unreal won’t really hurt them in the long run. If you were a more reputable member of the community with some published professional works, then maybe they’d feel like losing you is a big deal.