How should I serialize this in a right way?
It's an array btw , sorry for the title.

Code:
        private SkillClass[] m_skillClasses;
        [CommandProperty(AccessLevel.GameMaster)]
        public SkillClass[] skillClasses
        {
            get { return m_skillClasses; }
            set { m_skillClasses = value; }
        }
 
Last edited:
Well since I have no idea how you defined SkillClass nor how you would serialize / deserialize it I left that part kinda abstract :p but you would go this route usually

For writing
Code:
	writer.write(m_skillClasses.Length);
	foreach(var sc in m_skillClasses)
		writer.write(sc);

for reading
Code:
	int scCount = reader.ReadInt();
	m_skillClasses = new SkillClass[scCount];
	for(int i = 0; i < scCount; i++)
	    m_skillClasses[i] = reader.ReadSkillClass();
 
Oh thanks for replying , SkillClass is an enum btw.
[doublepost=1543622854][/doublepost]Just did this
Code:
   writer.Write(24); // version
            writer.Write(m_skillClasses.Length);
            foreach (var sc in m_skillClasses)
                writer.Write((int)sc);
and

Code:
            int scCount = reader.ReadInt();
            m_skillClasses = new SkillClass[scCount];
            for (int i = 0; i < scCount; i++)
                m_skillClasses[i] = (SkillClass)reader.ReadInt();

But didn't work quitely :/ am I missing something?
 
I'm working on BaseCreature.cs it doesn't have Switch-Case in the deserialize method , I increase version. +1 in serialize method but didn't do anything in deserialize just writing it under the version reader. What should I Do ? Thanks for your help.
 
Code:
if(version >= 24)
{
	int scCount = reader.ReadInt();
	m_skillClasses = new SkillClass[scCount];
	for (int i = 0; i < scCount; i++)
	m_skillClasses[i] = (SkillClass)reader.ReadInt();
}
should do
 
Thanks for your help , will try.
[doublepost=1543676075][/doublepost]Still having problems while saving.. Don't know what is the problem but thank you for your help.
 
Back