public static SerializeEntity Serialize(this Transform trans) { SerializeEntity se = new SerializeEntity(); if (trans is RectTransform) { se.Type = "RectTrans"; } else { se.Type = "Trans"; } if (trans is RectTransform) { var rTrans = trans as RectTransform; se.Add("AnMin", SerializeUitls.S_Vector2(rTrans.anchorMin)); se.Add("AnMax", SerializeUitls.S_Vector2(rTrans.anchorMax)); se.Add("pivot", SerializeUitls.S_Vector2(rTrans.pivot)); se.Add("W", rTrans.rect.width); se.Add("H", rTrans.rect.height); } se.Add("p", SerializeUitls.S_Vector3(trans.localPosition)); se.Add("r", SerializeUitls.S_Vector3(trans.localEulerAngles)); se.Add("s", SerializeUitls.S_Vector3(trans.localScale)); se.Add("active", trans.gameObject.activeSelf); return(se); }
public SerializeEntity Serialize() { SerializeEntity se = new SerializeEntity(); se.Type = "Text"; se.Add("info", text); //TODO 字体和字体暂时不支持序列化,后期自定义字体时再做支持 se.Add("FStyle", fontStyle.ToString()) .Add("FSize", fontSize) .Add("LS", lineSpacing) .Add("RT", supportRichText) .Add("AG", alignment.ToString()) .Add("ABG", alignByGeometry) .Add("HO", horizontalOverflow.ToString()) .Add("VO", verticalOverflow.ToString()) .Add("col", SerializeUitls.S_Color(color)) .Add("RayT", raycastTarget) .Add("BF", resizeTextForBestFit); if (resizeTextForBestFit) { se.Add("MinS", resizeTextMinSize) .Add("MaxS", resizeTextMaxSize); } return(se); }
/// <summary> /// 序列化LitRawImage /// </summary> public static SerializeEntity Ser_RawImage(this LitRawImage img) { var se = img.Ser_MaskableGraphic(); se.Type = "RImg"; se.Add("path", SerializeUitls.GetResPath(img.texture)) .Add("UV", SerializeUitls.S_Rect(img.uvRect)); return(se); }
/// <summary> /// 序列化LitImage /// </summary> public static SerializeEntity Ser_Image(this LitImage img) { var se = img.Ser_MaskableGraphic(); se.Type = "Img"; se.Add("path", SerializeUitls.GetResPath(img.sprite)) .Add("PA", img.preserveAspect); return(se); }
public static SerializeEntity Ser_MaskableGraphic(this MaskableGraphic mg) { SerializeEntity se = new SerializeEntity(); se.Add("m", SerializeUitls.GetResPath(mg.material)) .Add("col", SerializeUitls.S_Color(mg.color)) .Add("RT", mg.raycastTarget); return(se); }
public static void DeSerialize(this Transform trans, SerializeEntity data) { if (trans is RectTransform) { var rTrans = trans as RectTransform; rTrans.anchorMin = SerializeUitls.D_Vector2(data["AnMin"]); rTrans.anchorMax = SerializeUitls.D_Vector2(data["AnMax"]); rTrans.pivot = SerializeUitls.D_Vector2(data["pivot"]); rTrans.sizeDelta = new Vector2(data["W"], data["H"]); } trans.localPosition = SerializeUitls.D_Vector3(data["p"]); trans.localScale = SerializeUitls.D_Vector3(data["s"]); trans.localEulerAngles = SerializeUitls.D_Vector3(data["r"]); trans.gameObject.SetActive(data["active"]); }
public void DeSerialize(SerializeEntity data) { SerializeUitls.SetString(ref audioName, data, "AN"); SerializeUitls.SetFloat(ref clickInterval, data, "AN"); SerializeUitls.SetFloat(ref tweenDuration, data, "TD"); SerializeUitls.SetFloat(ref scaleFactor, data, "SF"); int aType = -1; SerializeUitls.SetInt(ref aType, data, "AT"); if (aType != -1) { this.animationType = (ClickAnimation)aType; } }
public void DeSerialize(SerializeEntity data) { text = data["info"]; fontStyle = (FontStyle)System.Enum.Parse(typeof(FontStyle), data["FStyle"]); fontSize = data["FSize"]; lineSpacing = data["LS"]; supportRichText = data["RT"]; alignment = (TextAnchor)System.Enum.Parse(typeof(TextAnchor), data["AG"]); alignByGeometry = data["ABG"]; horizontalOverflow = (HorizontalWrapMode)System.Enum.Parse(typeof(HorizontalWrapMode), data["HO"]); verticalOverflow = (VerticalWrapMode)System.Enum.Parse(typeof(VerticalWrapMode), data["VO"]); color = SerializeUitls.D_Color(data["col"]); raycastTarget = data["RayT"]; resizeTextForBestFit = data["BF"]; if (resizeTextForBestFit) { resizeTextMinSize = data["MinS"]; resizeTextMaxSize = data["MaxS"]; } }
public static void D_RawImage(this LitRawImage img, SerializeEntity data) { img.D_MaskableGraphic(data); img.texture = SerializeUitls.LoadObj <Texture>(data["path"]); img.uvRect = SerializeUitls.D_Rect(data["UV"]); }
public static void D_Image(this Image img, SerializeEntity data) { img.D_MaskableGraphic(data); img.sprite = SerializeUitls.LoadObj <Sprite>(data["path"]); img.preserveAspect = data["PA"]; }
public static void D_MaskableGraphic(this MaskableGraphic mg, SerializeEntity data) { mg.color = SerializeUitls.D_Color(data["col"]); mg.raycastTarget = data["RT"]; mg.material = SerializeUitls.LoadObj <Material>(data["m"]); }
public void TestImagePath() { LitLogger.Log(SerializeUitls.GetResPath(sprite)); }