public static void DecodeInto(this string data, RectTransform tf) { var cody = new StdDecoder(data); foreach (var tag in cody) { var d = cody.GetData(); switch (tag) { case "tfBase": d.DecodeInto(tf.transform); break; case "aPos": tf.anchoredPosition = d.ToVector2(); break; case "aPos3D": tf.anchoredPosition3D = d.ToVector3(); break; case "aMax": tf.anchorMax = d.ToVector2(); break; case "aMin": tf.anchorMin = d.ToVector2(); break; case "ofMax": tf.offsetMax = d.ToVector2(); break; case "ofMin": tf.offsetMin = d.ToVector2(); break; case "pvt": tf.pivot = d.ToVector2(); break; case "deSize": tf.sizeDelta = d.ToVector2(); break; } } }
public static void DecodeInto(this string data, Transform tf) { var cody = new StdDecoder(data); bool local = false; foreach (var tag in cody) { var d = cody.GetData(); switch (tag) { case "loc": local = d.ToBool(); break; case "pos": if (local) { tf.localPosition = d.ToVector3(); } else { tf.position = d.ToVector3(); } break; case "size": tf.localScale = d.ToVector3(); break; case "rot": if (local) { tf.localRotation = d.ToQuaternion(); } else { tf.rotation = d.ToQuaternion(); } break; } } }
public static Color ToColor(this string data) { var cody = new StdDecoder(data); Color c = new Color(); foreach (var tag in cody) { var d = cody.GetData(); switch (tag) { case "r": c.r = d.ToFloat(); break; case "g": c.g = d.ToFloat(); break; case "b": c.b = d.ToFloat(); break; case "a": c.a = d.ToFloat(); break; default: cody.GetData(); break; } } return(c); }
public static void DecodeInto(this string data, out BoneWeight b) { var cody = new StdDecoder(data); b = new BoneWeight(); foreach (var tag in cody) { var d = cody.GetData(); switch (tag) { case "i0": b.boneIndex0 = d.ToInt(); break; case "w0": b.weight0 = d.ToFloat(); break; case "i1": b.boneIndex1 = d.ToInt(); break; case "w1": b.weight1 = d.ToFloat(); break; case "i2": b.boneIndex2 = d.ToInt(); break; case "w2": b.weight2 = d.ToFloat(); break; case "i3": b.boneIndex3 = d.ToInt(); break; case "w3": b.weight3 = d.ToFloat(); break; } } }
public static void DecodeInto(this string data, out Dictionary <int, string> dic) { var cody = new StdDecoder(data); dic = new Dictionary <int, string>(); while (cody.GotData) { dic.Add(cody.GetTag().ToInt(), cody.GetData()); } }
public static List <int> DecodeInto(this string data, out List <int> l) { l = new List <int>(); StdDecoder cody = new StdDecoder(data); foreach (var tag in cody) { l.Add(cody.GetData().ToInt()); } return(l); }
// ToListOfSTD public static bool TryDecodeInto <T>(this string data, List <T> val) { if (val != null) { var cody = new StdDecoder(data); while (cody.GotData) { var ind = cody.GetTag().ToIntFromTextSafe(-1); cody.GetData().TryDecodeInto(val.TryGet(ind)); } return(true); } return(false); }
public static void DecodeInto(this string data, out Matrix4x4 m) { var cody = new StdDecoder(data); m = new Matrix4x4(); foreach (var tag in cody) { var d = cody.GetData(); switch (tag) { case "00": m.m00 = d.ToFloat(); break; case "01": m.m01 = d.ToFloat(); break; case "02": m.m02 = d.ToFloat(); break; case "03": m.m03 = d.ToFloat(); break; case "10": m.m10 = d.ToFloat(); break; case "11": m.m11 = d.ToFloat(); break; case "12": m.m12 = d.ToFloat(); break; case "13": m.m13 = d.ToFloat(); break; case "20": m.m20 = d.ToFloat(); break; case "21": m.m21 = d.ToFloat(); break; case "22": m.m22 = d.ToFloat(); break; case "23": m.m23 = d.ToFloat(); break; case "30": m.m30 = d.ToFloat(); break; case "31": m.m31 = d.ToFloat(); break; case "32": m.m32 = d.ToFloat(); break; case "33": m.m33 = d.ToFloat(); break; default: Debug.Log("Uncnown component: " + tag); break; } } // return m; }
public static List <List <T> > DecodeInto <T>(this string data, out List <List <T> > l) where T : ISTD, new() { l = new List <List <T> >(); var cody = new StdDecoder(data); while (cody.GotData) { cody.GetTag(); List <T> el; cody.GetData().DecodeInto(out el); l.Add(el); } return(l); }
public static List <T> DecodeInto <T>(this string data, out List <T> l) where T : ISTD, new() { StdDecoder cody = new StdDecoder(data); l = new List <T>(); List <Type> tps = typeof(T).TryGetDerrivedClasses(); foreach (var tag in cody) { var d = cody.GetData(); var isNull = tag == StdEncoder.nullTag; if (isNull) { l.Add(default(T)); } else { if (tps != null) { var type = tps.TryGet(tag.ToIntFromTextSafe(-1)); if (type == null) { type = tps[0]; #if UNITY_EDITOR Debug.Log("Couldn't decode class no: " + tag + " for " + typeof(T).ToString()); #endif } if (type != null) { l.Add(d.DecodeInto <T>(type)); } } else { l.Add(d.DecodeInto <T>()); } } } return(l); }
public static Rect ToRect(this string data) { StdDecoder cody = new StdDecoder(data); Rect rect = new Rect(); foreach (var tag in cody) { var d = cody.GetData(); switch (tag) { case "pos": rect.position = d.ToVector2(); break; case "size": rect.size = d.ToVector2(); break; } } return(rect); }
public static Vector2 ToVector2(this string data) { StdDecoder cody = new StdDecoder(data); Vector2 v2 = new Vector3(); foreach (var tag in cody) { var d = cody.GetData(); switch (tag) { case "x": v2.x = d.ToFloat(); break; case "y": v2.y = d.ToFloat(); break; } } return(v2); }
public static Vector4 ToVector4(this string data) { StdDecoder cody = new StdDecoder(data); Vector4 v4 = new Vector4(); foreach (var tag in cody) { var d = cody.GetData(); switch (tag) { case "x": v4.x = d.ToFloat(); break; case "y": v4.y = d.ToFloat(); break; case "z": v4.z = d.ToFloat(); break; case "w": v4.w = d.ToFloat(); break; default: Debug.Log("Uncnown component: " + tag); break; } } return(v4); }
public static Quaternion ToQuaternion(this string data) { StdDecoder cody = new StdDecoder(data); Quaternion q = new Quaternion(); foreach (var tag in cody) { var d = cody.GetData(); switch (tag) { case "x": q.x = d.ToFloat(); break; case "y": q.y = d.ToFloat(); break; case "z": q.z = d.ToFloat(); break; case "w": q.w = d.ToFloat(); break; default: Debug.Log("Uncnown component: " + cody.GetType()); break; } } return(q); }