public static ColorTransform ReadColorTransform(byte[] data, Cursor cursor){ ColorTransform ctr = new ColorTransform(); ctr.add = new Color (0, 0, 0 ,0); ctr.multiply = new Color32 (0, 0, 0, 0); int mtype = Utils.ReadInt32(data, cursor); if (mtype==1) { ctr.multiply = new Color(1, 1, 1, 1); }else if (mtype==2){ Color color = new Color(); color.r = Utils.ReadFloat(data, cursor); color.g = Utils.ReadFloat(data, cursor); color.b = Utils.ReadFloat(data, cursor); color.a = Utils.ReadFloat(data, cursor); ctr.multiply = color; } int atype = Utils.ReadInt32(data, cursor); if (atype==1) { ctr.add = new Color(255, 255, 255, 255); }else if (atype==2){ Color32 color = new Color(); color.r = Utils.ReadByte(data, cursor); color.g = Utils.ReadByte(data, cursor); color.b = Utils.ReadByte(data, cursor); color.a = Utils.ReadByte(data, cursor); ctr.add = color; } return ctr; }
public PlaceObject(byte[] data, Cursor cursor){ int dataLength = Utils.ReadInt32 (data, cursor); int nextIndex = cursor.index + dataLength; //parse hasMatrix = Utils.ReadByte (data, cursor) == 0 ? false : true; hasCharacter = Utils.ReadByte (data, cursor) == 0 ? false : true; hasColorTransform = Utils.ReadByte (data, cursor) == 0 ? false : true; isHidden = Utils.ReadByte (data, cursor) == 0 ? false : true; depth = Utils.ReadInt32(data, cursor); characterId = Utils.ReadInt32 (data, cursor); if (hasMatrix) { position = Utils.ReadVector2(data, cursor); rotation = Utils.ReadFloat(data, cursor); scaleX = Utils.ReadFloat(data, cursor); scaleY = Utils.ReadFloat(data, cursor); }else{ position = Vector2.zero; rotation = 0; scaleX = 1; scaleY = 1; } if(hasColorTransform) colorTransform = Utils.ReadColorTransform(data, cursor); else colorTransform = new ColorTransform(Color.white, Color.black); instanceName = Utils.ReadString(data, cursor); cursor.index = nextIndex; }