void ReadTimelineObject(XmlElement element, SpriterTimelineKey key, VariableType variableType)
{
SpriterTimelineObject obj = new SpriterTimelineObject();
key.objects.Add(obj);
Vector2 position = Vector2.zero, pivot = new Vector2(0,1), scale = Vector2.one;
Color color = Color.white;
foreach(XmlAttribute attribute in element.Attributes)
{
// atlas
if (attribute.Name.Equals("atlas"))
obj.atlas = int.Parse(attribute.Value);
// folder
else if (attribute.Name.Equals("folder"))
obj.folder = int.Parse(attribute.Value);
// file
else if (attribute.Name.Equals("file"))
obj.file = int.Parse(attribute.Value);
// name
else if (attribute.Name.Equals("name"))
obj.name = attribute.Value;
// x, y
else if (attribute.Name.Equals("x"))
position.x = float.Parse(attribute.Value);
else if (attribute.Name.Equals("y"))
position.y = float.Parse(attribute.Value);
// pivot_x, pivot_y
else if (attribute.Name.Equals("pivot_x"))
pivot.x = float.Parse(attribute.Value);
else if (attribute.Name.Equals("pivot_y"))
pivot.y = float.Parse(attribute.Value);
// angle
else if (attribute.Name.Equals("angle"))
obj.angle = float.Parse(attribute.Value);
// w, h
else if (attribute.Name.Equals("w"))
obj.pixelWidth = int.Parse(attribute.Value);
else if (attribute.Name.Equals("h"))
obj.pixelHeight = int.Parse(attribute.Value);
// scale_x, scale_y
else if (attribute.Name.Equals("scale_x"))
scale.x = float.Parse(attribute.Value);
else if (attribute.Name.Equals("scale_y"))
scale.y = float.Parse(attribute.Value);
// color
else if (attribute.Name.Equals("r"))
color.r = float.Parse(attribute.Value);
else if (attribute.Name.Equals("g"))
color.g = float.Parse(attribute.Value);
else if (attribute.Name.Equals("b"))
color.b = float.Parse(attribute.Value);
else if (attribute.Name.Equals("a"))
color.a = float.Parse(attribute.Value);
// blend_mode
else if (attribute.Name.Equals("blend_mode"))
{
obj.blendModeRaw = attribute.Value;
obj.blendMode = SpriterDataHelpers.ParseSpriterEnum<BlendMode>(obj.blendModeRaw);
}
// value
else if (attribute.Name.Equals("value"))
obj.value = ReadVariable(variableType, attribute.Value);
// min, max
else if (attribute.Name.Equals("min"))
obj.min = ReadVariable(variableType, attribute.Value);
else if (attribute.Name.Equals("max"))
obj.max = ReadVariable(variableType, attribute.Value);
// animation
else if (attribute.Name.Equals("animation"))
obj.entityAnimation = int.Parse(attribute.Value);
// t
else if (attribute.Name.Equals("t"))
obj.entityT = float.Parse(attribute.Value);
// volume
else if (attribute.Name.Equals("volume"))
obj.volume = float.Parse(attribute.Value);
// panning
else if (attribute.Name.Equals("panning"))
obj.panning = float.Parse(attribute.Value);
}
foreach(XmlElement child in element)
{
// meta_data
if (child.Name.Equals("meta_data"))
ReadMetaData(child, obj.metaData);
}
// Assign vector values
obj.position = position;
obj.pivot = pivot;
obj.scale = scale;
obj.color = color;
// Object references
obj.targetAtlas = m_Data.FindAtlas(obj.atlas);
obj.targetFile = m_Data.FindFile(obj.folder, obj.file);
}