public static void CreateMapInfo(UnityEngine.Object[] sprites, string savepath) { CharInfoA[] tmp = new CharInfoA[16]; for (int i = 0; i < 16; i++) { tmp[i] = new CharInfoA(); tmp[i].len = i + 1; } CharUV uv = new CharUV(); unsafe { fixed(byte *bp = &buff[0]) { for (int i = 0; i < sprites.Length; i++) { var sp = sprites[i] as Sprite; if (sp != null) { int len = AddSpriteInfo(sp); var dat = tmp[len - 1].dat; char *cp = (char *)bp; for (int j = 0; j < len; j++) { dat.Add(*cp); cp++; } CalculUV(sp.rect, sp.texture.width, sp.texture.height, ref uv); tmp[len - 1].uvs.Add(uv); } } } } DataBuffer db = new DataBuffer(); FakeStruct fake = new FakeStruct(db, 16); for (int i = 0; i < 16; i++) { var t = tmp[i]; FakeStruct fs = new FakeStruct(db, 3); fs[0] = t.len; if (tmp[i].dat.Count > 0) { fs[1] = db.AddArray <char>(t.dat.ToArray()); fs[2] = db.AddArray <CharUV>(t.uvs.ToArray()); } fake.SetData(i, fs); } db.fakeStruct = fake; byte[] data = db.ToBytes(); File.WriteAllBytes(savepath, data); Debug.Log("emoji info create done"); }
public override unsafe FakeStruct LoadFromObject(Component com, DataBuffer buffer) { var obj = com as EdgeCollider2D; if (obj == null) { return(null); } FakeStruct fake = new FakeStruct(buffer, EdgeColliderData.ElementSize); EdgeColliderData *ec = (EdgeColliderData *)fake.ip; if (obj.sharedMaterial != null) { ec->sharedMaterial = buffer.AddData(obj.sharedMaterial.name); } ec->offset = obj.offset; ec->usedByEffector = obj.usedByEffector; ec->isTrigger = obj.isTrigger; ec->density = obj.density; ec->edgeRadius = obj.edgeRadius; if (obj.points != null) { ec->points = buffer.AddArray <Vector2>(obj.points); } return(fake); }
public static unsafe FakeStruct LoadFromObject(Component com, DataBuffer buffer) { var obj = com as PolygonCollider2D; if (obj == null) { return(null); } FakeStruct fake = new FakeStruct(buffer, PolygonColliderData.ElementSize); PolygonColliderData *ec = (PolygonColliderData *)fake.ip; if (obj.sharedMaterial != null) { ec->sharedMaterial = buffer.AddData(obj.sharedMaterial.name); } ec->offset = obj.offset; ec->usedByEffector = obj.usedByEffector; ec->isTrigger = obj.isTrigger; ec->density = obj.density; ec->autoTiling = obj.autoTiling; ec->pathCount = obj.pathCount; if (obj.points != null) { ec->points = buffer.AddArray <Vector2>(obj.points); } return(fake); }
public void SendData(byte type, ushort messageID, byte[] data, ushort size) { DataBuffer dataBuffer = new DataBuffer(); dataBuffer.Add(signature); dataBuffer.Add(type); dataBuffer.Add(messageID); dataBuffer.AddArray(data, 0, size); SendData(dataBuffer.GetBuffer(), (ushort)dataBuffer.GetBufferSize()); }
public unsafe override void ToBufferData(DataBuffer db, UITransfromData *data) { if (Points != null) { FakeStruct fs = new FakeStruct(db, 2); fs[0] = (int)EventColliderType.Polygon; fs[1] = db.AddArray <Vector2>(Points); data->eve = db.AddData(fs); } }
public unsafe override void ToBufferData(DataBuffer db, huqiang.Core.UIData.UIElementData *data) { if (Points != null) { FakeStruct fs = new FakeStruct(db, 2); fs[0] = (int)EventColliderType.Polygon; if (Points != null) { if (Points.Length > 2) { fs[1] = db.AddArray <Vector2>(Points); } } int type = db.AddData("PolygonEventHelper"); int index = db.AddData(fs); data->eve = type << 16 | index; } }
public FakeStruct Save(DataBuffer db) { FakeStruct fake = new FakeStruct(db, 11); fake[0] = db.AddData(this.GetType().Name, DataType.String); fake[1] = db.AddData(a, DataType.Int32Array); if (b != null) { fake[2] = db.AddData(new FakeStringArray(b), DataType.FakeStringArray); } if (c != null) { if (c.Length > 0) { Int16[] c_b = new Int16[c.Length]; for (int i = 0; i < c.Length; i++) { var c_t = c[i]; if (c_t != null) { c_b[i] = (Int16)db.AddData(c_t.Save(db)); } } fake[3] = db.AddData(c_b, DataType.Int16Array); } } if (d != null) { if (d.Count > 0) { fake[4] = db.AddData(d.ToArray(), DataType.Int32Array); } } if (e != null) { if (e.Count > 0) { fake[5] = db.AddData(new FakeStringArray(e.ToArray()), DataType.FakeStringArray); } } if (f != null) { if (f.Count > 0) { Int16[] f_b = new Int16[f.Count]; for (int i = 0; i < f.Count; i++) { var f_t = f[i]; if (f_t != null) { f_b[i] = (Int16)db.AddData(f_t.Save(db)); } } fake[6] = db.AddData(f_b, DataType.Int16Array); } } fake[7] = (int)scroll; if (v2 != null) { fake[8] = db.AddArray <Vector2>(v2); } if (v3 != null) { fake[9] = db.AddArray <Vector3>(v3); } if (v4 != null) { fake[10] = db.AddArray <Vector4>(v4.ToArray()); } return(fake); }