Custom SyncListStruct constructor

public struct BuildingData
{
public Vector3 position;
public Quaternion rotation;

    public BuildingData(Vector3 pos, Quaternion rot)
    {
        this.position = pos;
        this.rotation = rot;
    }
}

public class SyncListBuildingData : SyncListStruct<BuildingData>
{
    public SyncListBuildingData(List<BuildingData> buildingData)
    {
        foreach (BuildingData bData in buildingData)
        {
            this.Add(new BuildingData(bData.position, bData.rotation));
        }
    }
}

Hello! I need to pass list of data to [Command] function, so I need to make SyncList for passing data. But I can’t find any examples which will show how to make custom constructor for my SyncListStruct class. I want to use it like:

CmdBuild(new SyncListBuildingData(List<BuildingData> buildingsList));

But I have no idea how I can initialize and fill new list in SyncListBuildingData() constructor. Can someone help?

@shoo can you post the SyncListStruct?

Normally I reccommend just using List and add new data based on the struct… however …?
Just so I can see what’s exactly going on here.

-Edit "Maybe use a array instead to loop threw the list.

For example :

public class StructData
{
    public long type;
    public long[] myArray = new long[50];
    public string text;
}

StructData[] datas = new StructData[100];

for (int i = 0; i < datas.Length; i++)
{
    datas *= new StructData();*

}
[Discussion on Arrays (Stack Overflow)][1]
[1]: c# - Create an array/List of structures when structure contains an array/List - Stack Overflow
However I would build based on classes to make things easier in the future.
If were storing just the rotation position this fine … but when were going to sync our level …
To a data file… it might be wise to use class structure…
and to simply things use a public list that way we can easily visually see whats going on… from the editor point of view…
public class BuildingData
{
//Values of the building…
}

public class MainClass
{
public List buildingList = new List();
BuildingData newBuilding01 = new BuildingData();
newBuilding01.pos = someposition;
newBuilding01.roatation = somerotation;
buildingList.Add(newBuilding01);
//then sync the list in a for loop for the length of the list to the data file if im right.

}
“hope this helped”